freeside/fs_selfservice/FS-SelfService/cgi agent_menu.html,NONE,1.1 provision_list.html,NONE,1.1 agent_provision.html,NONE,1.1 svc_acct.html,NONE,1.1 agent_provision_svc_acct.html,NONE,1.1 agent_delete_svc.html,NONE,1.1 agent_customer_menu.html,NONE,1.1 order_pkg.html,NONE,1.1 agent_order_pkg.html,NONE,1.1 agent_logout.html,NONE,1.1 agent.cgi,1.5,1.6 agent_main.html,1.2,1.3 list_customers.html,1.1,1.2 view_customer.html,1.1,1.2 selfservice.cgi,1.8,1.9 provision.html,1.1,1.2

ivan ivan at pouncequick.420.am
Tue Aug 24 04:17:00 PDT 2004


Update of /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi
In directory pouncequick:/tmp/cvs-serv11531/fs_selfservice/FS-SelfService/cgi

Modified Files:
	agent.cgi agent_main.html list_customers.html 
	view_customer.html selfservice.cgi provision.html 
Added Files:
	agent_menu.html provision_list.html agent_provision.html 
	svc_acct.html agent_provision_svc_acct.html 
	agent_delete_svc.html agent_customer_menu.html order_pkg.html 
	agent_order_pkg.html agent_logout.html 
Log Message:
big update for reseller interface

--- NEW FILE: agent_provision_svc_acct.html ---
<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %>
<TABLE BORDER=0 CELLPADDING=4><TR>
<%= include('agent_menu') %>
<TD VALIGN="top">
<%= $small_custview %>
<BR>
<TABLE BORDER=0 CELLPADDING=4><TR>
<%= include('agent_customer_menu') %>
<TD VALIGN="top">
<%= include('svc_acct') %>
</TD></TR></TABLE>

</TD></TR></TABLE>
<HR>
<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
</BODY></HTML>


Index: agent_main.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/agent_main.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- agent_main.html	9 Jul 2004 09:29:39 -0000	1.2
+++ agent_main.html	24 Aug 2004 11:16:56 -0000	1.3
@@ -1,10 +1,9 @@
-<HTML><HEAD><TITLE>Reseller Main</TITLE></HEAD>
-<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller Main</FONT><BR><BR>
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
 <%= $url = "$selfurl?session=$session_id;action="; ''; %>
-<TABLE BORDER=0 CELLPADDING=4><TR><TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
-<A HREF="<%= $url %>agent_main">Reseller Main</A><BR>
-<!-- <A HREF="<%= $url %>other">SomethingElse</A><BR> -->
-</TD><TD VALIGN="top">
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
 
 <%= $message
       ? "<FONT SIZE=\"+2\"><B>$message</B></FONT>"
@@ -16,20 +15,18 @@
 <TR><TD BGCOLOR="#dddddd">
 
   <B><%= $num_prospect %></B>
-  <A HREF="<%= $url %>list_customers;prospect=1">prospects</A>
+  <%= $num_prospect ? qq!<A HREF="${url}list_customers;prospect=1">! : '' %>prospects</A>
 
   <BR><FONT COLOR="#00CC00"><B><%= $num_active %></B></FONT>
-  <A HREF="<%= $url %>list_customers;active=1">active</A>
+  <%= $num_active ? qq!<A HREF="${url}list_customers;active=1">! : '' %>active</A>
 
   <BR><FONT COLOR="#FF9900"><B><%= $num_susp %></B></FONT>
-  <A HREF="<%= $url %>list_customers;susp=1">suspended</A>
+  <%= $num_susp ? qq!<A HREF="${url}list_customers;susp=1">! : '' %>suspended</A>
 
   <BR><FONT COLOR="#FF0000"><B><%= $num_cancel %></B></FONT>
-  <A HREF="<%= $url %>list_customers;cancel=1">cancelled</A>
+  <%= $num_cancel ? qq!<A HREF="${url}list_customers;cancel=1">! : '' %>cancelled</A>
 
 </TD></TR></TABLE>
-
-<BR><A HREF="<%= $url %>signup">New customer<!--/prospect--></A>
 
 </TD></TR></TABLE>
 <HR>

--- NEW FILE: order_pkg.html ---
<SCRIPT TYPE="text/javascript">
function enable_order_pkg () {
  if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
    document.OrderPkgForm.submit.disabled = false;
  } else {
    document.OrderPkgForm.submit.disabled = true;
  }
}
</SCRIPT>
<FONT SIZE=4>Purchase additional package</FONT><BR><BR>
<%= if ( $error ) {
  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">$error</FONT><BR><BR>!;
} ''; %>
<FORM NAME="OrderPkgForm" ACTION="<%= $selfurl %>" METHOD=POST>
<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
<INPUT TYPE="hidden" NAME="action" VALUE="process_order_pkg">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
<TR>
  <TD COLSPAN=2><SELECT NAME="pkgpart" onChange="enable_order_pkg()">
  <OPTION VALUE="">

  <%=
    foreach my $part_pkg ( @part_pkg ) {
      $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
      $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
      $OUT .= '>'. $part_pkg->{'pkg'};
    }
  %>

  </SELECT></TD>
</TR>
<TR>
  <TD ALIGN="right">Username</TD>
  <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
</TR>
<TR>
  <TD ALIGN="right">Password</TD>
  <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $_password %>"></TD>
</TR>
<TR>
  <TD ALIGN="right">Re-enter Password</TD>
  <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $_password2 %>"></TD>
</TR>
<%=
  if ( $security_phrase ) {
    $OUT .= <<ENDOUT;
<TR>
  <TD ALIGN="right">Security Phrase</TD>
  <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
  </TD>
</TR>
ENDOUT
  } else {
    $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
  }
%>
<%=
  if ( @svc_acct_pop ) {
    $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
            popselector( 'popnum'        => $popnum,
                         'pops'          => \@svc_acct_pop,
                         'init_popstate' => $init_popstate,
                         'popac'         => $popac,
                         'acstate'       => $acstate,
                       ).
            '</TD></TR>';
  } else {
    $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
  }
%>
</TABLE>
<INPUT NAME="submit" TYPE="submit" VALUE="Purchase" disabled>
</FORM>


--- NEW FILE: agent_delete_svc.html ---
<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
<%= $url = "$selfurl?session=$session_id;action="; ''; %>
<TABLE BORDER=0 CELLPADDING=4><TR>
<%= include('myaccount_menu') %>
<TD VALIGN="top">
<%= $small_custview %>
<BR>
<%= if ( $error ) {

  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error: $error</FONT>!;
} else {
  $OUT .= "<FONT SIZE=4>$svc removed.</FONT>";
} %>

</TD></TR></TABLE>
<HR>
<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
</BODY></HTML>


--- NEW FILE: agent_order_pkg.html ---
<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %>
<TABLE BORDER=0 CELLPADDING=4><TR>
<%= include('agent_menu') %>
<TD VALIGN="top">
<%= $small_custview %>
<BR>

<TABLE BORDER=0 CELLPADDING=4><TR>
<%= include('agent_customer_menu') %>
<TD VALIGN="top">
<%= include('order_pkg') %>
</TD></TR></TABLE>

</TD></TR></TABLE>
<HR>
<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
</BODY></HTML>

Index: list_customers.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/list_customers.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- list_customers.html	10 Jun 2004 12:31:31 -0000	1.1
+++ list_customers.html	24 Aug 2004 11:16:56 -0000	1.2
@@ -1,10 +1,9 @@
-<HTML><HEAD><TITLE>Reseller Main</TITLE></HEAD>
-<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller Main</FONT><BR><BR>
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
 <%= $url = "$selfurl?session=$session_id;action="; ''; %>
-<TABLE BORDER=0 CELLPADDING=4><TR><TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
-<A HREF="<%= $url %>agent_main">Reseller Main</A><BR>
-<!-- <A HREF="<%= $url %>other">SomethingElse</A><BR> -->
-</TD><TD VALIGN="top">
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
 
 <%=
   if ( @customers ) {
@@ -37,5 +36,4 @@
 <HR>
 <FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
 </BODY></HTML>
-
 

Index: view_customer.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/view_customer.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- view_customer.html	10 Jun 2004 12:31:31 -0000	1.1
+++ view_customer.html	24 Aug 2004 11:16:56 -0000	1.2
@@ -1,10 +1,9 @@
-<HTML><HEAD><TITLE>View Customer</TITLE></HEAD>
-<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>View Customer</FONT><BR><BR>
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
 <%= $url = "$selfurl?session=$session_id;action="; ''; %>
-<TABLE BORDER=0 CELLPADDING=4><TR><TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
-<A HREF="<%= $url %>agent_main">Reseller Main</A><BR>
-<!-- <A HREF="<%= $url %>other">SomethingElse</A><BR> -->
-</TD><TD VALIGN="top">
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
 
 <%= $message
       ? "<FONT SIZE=\"+2\"><B>$message</B></FONT><BR><BR>"
@@ -13,67 +12,13 @@
 
 <%= $small_custview %>
 
-<BR>Purchase additional package
-<FORM ACTION="<%= $selfurl %>" METHOD=POST>
-<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
-<INPUT TYPE="hidden" NAME="action" VALUE="process_order_pkg">
-<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
-<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
-<TR>
-  <TD COLSPAN=2><SELECT NAME="pkgpart"><OPTION VALUE="">
+<BR>
 
-  <%=
-    foreach my $part_pkg ( @part_pkg ) {
-      $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
-      $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
-      $OUT .= '>'. $part_pkg->{'pkg'};
-    }
-  %>
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_customer_menu') %>
+<TD VALIGN="top">
 
-  </SELECT></TD>
-</TR>
-<TR>
-  <TD ALIGN="right">Username</TD>
-  <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
-</TR>
-<TR>
-  <TD ALIGN="right">Password</TD>
-  <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $_password %>"></TD>
-</TR>
-<TR>
-  <TD ALIGN="right">Re-enter Password</TD>
-  <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $_password2 %>"></TD>
-</TR>
-<%=
-  if ( $security_phrase ) {
-    $OUT .= <<ENDOUT;
-<TR>
-  <TD ALIGN="right">Security Phrase</TD>
-  <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
-  </TD>
-</TR>
-ENDOUT
-  } else {
-    $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
-  }
-%>
-<%=
-  if ( @svc_acct_pop ) {
-    $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
-            popselector( 'popnum'        => $popnum,
-                         'pops'          => \@svc_acct_pop,
-                         'init_popstate' => $init_popstate,
-                         'popac'         => $popac,
-                         'acstate'       => $acstate,
-                       ).
-            '</TD></TR>';
-  } else {
-    $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
-  }
-%>
-</TABLE>
-<INPUT TYPE="submit" VALUE="Purchase">
-</FORM>
+</TD></TR></TABLE>
 
 </TD></TR></TABLE>
 <HR>

--- NEW FILE: agent_logout.html ---
<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
You have been logged out.
</BODY></HTML>


--- NEW FILE: svc_acct.html ---
<FONT SIZE=4>Setup <%= $svc %></FONT><BR><BR>

<%= if ( $error ) {
  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error setting up $svc: $error!.
          '</FONT><BR><BR>';
} ''; %>
<FORM ACTION="<%= $selfurl %>" METHOD=POST>
<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
<INPUT TYPE="hidden" NAME="action" VALUE="process_svc_acct">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>">
<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#cccccc">
<TR>
  <TD ALIGN="right">Username</TD>
  <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
</TR>
<TR>
  <TD ALIGN="right">Password</TD>
  <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $_password %>"></TD>
</TR>
<TR>
  <TD ALIGN="right">Re-enter Password</TD>
  <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $_password2 %>"></TD>
</TR>
<%=
  if ( $security_phrase ) {
    $OUT .= <<ENDOUT;
<TR>
  <TD ALIGN="right">Security Phrase</TD>
  <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
  </TD>
</TR>
ENDOUT
  } else {
    $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
  }
%>
<%=
  if ( @svc_acct_pop ) {
    $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
            popselector( 'popnum'        => $popnum,
                         'pops'          => \@svc_acct_pop,
                         'init_popstate' => $init_popstate,
                         'popac'         => $popac,
                         'acstate'       => $acstate,
                       ).
            '</TD></TR>';
  } else {
    $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
  }
%>
</TABLE>
<INPUT TYPE="submit" VALUE="Setup">
</FORM>

--- NEW FILE: agent_menu.html ---
<%= $url = "$selfurl?session=$session_id;action="; ''; %>
<TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">

<A HREF="<%= $url %>agent_main">Overview</A><BR><BR>
<A HREF="<%= $url %>signup">New customer<!--/prospect--></A><BR><BR>
<FORM ACTION="<%= $selfurl %>">
<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
<INPUT TYPE="hidden" NAME="action" VALUE="list_customers">
<INPUT TYPE="text" NAME="search" SIZE=20><BR>
<SMALL><I>cust&nbsp;#,&nbsp;last&nbsp;name,&nbsp;or&nbsp;company</I></SMALL><BR>
<INPUT TYPE="submit" VALUE="Search customers"><BR>
</FORM>
<A HREF="<%= $url %>logout">Logout</A><BR><BR>

</TD>

Index: agent.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/agent.cgi,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- agent.cgi	15 Jul 2004 22:40:00 -0000	1.5
+++ agent.cgi	24 Aug 2004 11:16:56 -0000	1.6
@@ -9,10 +9,12 @@
 use CGI::Carp qw(fatalsToBrowser);
 use Business::CreditCard;
 use Text::Template;
-use FS::SelfService qw( agent_login agent_info
+#use HTML::Entities;
+use FS::SelfService qw( agent_login agent_logout agent_info
                         agent_list_customers
                         signup_info new_customer
-                        customer_info order_pkg
+                        customer_info list_pkgs order_pkg
+                        part_svc_info provision_acct unprovision_svc
                       );
 
 $DEBUG = 0;
@@ -65,7 +67,7 @@
 
 warn "$me checking action\n" if $DEBUG;
 $cgi->param('action') =~
-   /^(agent_main|signup|process_signup|list_customers|view_customer|process_order_pkg)$/
+   /^(agent_main|signup|process_signup|list_customers|view_customer|agent_provision|provision_svc|process_svc_acct|delete_svc|agent_order_pkg|process_order_pkg|logout)$/
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
@@ -87,6 +89,11 @@
 
 #-- 
 
+sub logout {
+  $action = 'agent_logout';
+  agent_logout( 'session_id' => $session_id );
+}
+
 sub agent_main { agent_info( 'session_id' => $session_id ); }
 
 sub signup { signup_info( 'session_id' => $session_id ); }
@@ -184,15 +191,55 @@
 }
 
 sub list_customers {
-  agent_list_customers( 'session_id' => $session_id,
-                        map { $_ => $cgi->param($_) }
-                          grep defined($cgi->param($_)),
-                               qw(prospect active susp cancel)
-                      );
+
+  my $results = 
+    agent_list_customers( 'session_id' => $session_id,
+                          map { $_ => $cgi->param($_) }
+                            grep defined($cgi->param($_)),
+                                 qw(prospect active susp cancel),
+                                 'search',
+                        );
+
+  if ( scalar( @{$results->{'customers'}} ) == 1 ) {
+    $action = 'view_customer';
+    customer_info (
+      'agent_session_id' => $session_id,
+      'custnum'          => $results->{'customers'}[0]{'custnum'},
+    );
+  } else {
+    $results;
+  }
+
 }
 
 sub view_customer {
 
+  #my $init_data = signup_info( 'session_id' => $session_id );
+  #if ( $init_data->{'error'} ) {
+  #  if ( $init_data->{'error'} eq "Can't resume session" ) { #ick
+  #    do_template('agent_login',{});
+  #    exit;
+  #  } else { #?
+  #    die $init_data->{'error'};
+  #  }
+  #}
+  #
+  #my $customer_info =
+  customer_info (
+    'agent_session_id' => $session_id,
+    'custnum'          => $cgi->param('custnum'),
+  );
+  #
+  #return {
+  #  ( map { $_ => $init_data->{$_} }
+  #        qw( part_pkg security_phrase svc_acct_pop ),
+  #  ),
+  #  %$customer_info,
+  #};
+}
+
+sub agent_order_pkg {
+
   my $init_data = signup_info( 'session_id' => $session_id );
   if ( $init_data->{'error'} ) {
     if ( $init_data->{'error'} eq "Can't resume session" ) { #ick
@@ -205,16 +252,91 @@
 
   my $customer_info = customer_info (
     'agent_session_id' => $session_id,
-    'custnum'          => $cgi->param('custnum')
+    'custnum'          => $cgi->param('custnum'),
   );
 
-
   return {
     ( map { $_ => $init_data->{$_} }
           qw( part_pkg security_phrase svc_acct_pop ),
     ),
     %$customer_info,
   };
+
+}
+
+sub agent_provision {
+  my $result = list_pkgs(
+    'agent_session_id' => $session_id,
+    'custnum'          => $cgi->param('custnum'),
+  );
+  die $result->{'error'} if exists $result->{'error'} && $result->{'error'};
+  $result;
+}
+
+sub provision_svc {
+
+  my $result = part_svc_info(
+    'agent_session_id' => $session_id,
+    map { $_ => $cgi->param($_) } qw( pkgnum svcpart custnum ),
+  );
+  die $result->{'error'} if exists $result->{'error'} && $result->{'error'};
+
+  $result->{'svcdb'} =~ /^svc_(.*)$/
+    #or return { 'error' => 'Unknown svcdb '. $result->{'svcdb'} };
+    or die 'Unknown svcdb '. $result->{'svcdb'};
+  $action .= "_$1";
+  $action = "agent_$action";
+
+  $result;
+}
+
+sub process_svc_acct {
+
+  my $result = provision_acct (
+    'agent_session_id' => $session_id,
+    map { $_ => $cgi->param($_) } qw(
+      custnum pkgnum svcpart username _password _password2 sec_phrase popnum )
+  );
+
+  if ( exists $result->{'error'} && $result->{'error'} ) { 
+    #warn "$result $result->{'error'}"; 
+    $action = 'provision_svc_acct';
+    $action = "agent_$action";
+    return {
+      $cgi->Vars,
+      %{ part_svc_info( 'agent_session_id' => $session_id,
+                        map { $_ => $cgi->param($_) } qw(pkgnum svcpart custnum)
+                      )
+      },
+      'error' => $result->{'error'},
+    };
+  } else {
+    #warn "$result $result->{'error'}"; 
+    $action = 'agent_provision';
+    return {
+      %{agent_provision()},
+      'message' => $result->{'svc'}. ' setup sucessfully.',
+    };
+  }
+
+}
+
+sub delete_svc {
+  my $result = unprovision_svc(
+    'agent_session_id' => $session_id,
+    'custnum'          => $cgi->param('custnum'),
+    'svcnum'           => $cgi->param('svcnum'),
+  );
+
+  $action = 'agent_provision';
+
+  return {
+    %{agent_provision()},
+    'message' => $result->{'error'}
+                   ? '<FONT COLOR="#FF0000">'. $result->{'error'}. '</FONT>'
+                   : $result->{'svc'}. ' removed.'
+  };
+
 }
 
 sub process_order_pkg {
@@ -223,11 +345,12 @@
 
   unless ( length($cgi->param('_password')) ) {
     my $init_data = signup_info( 'session_id' => $session_id );
-    $results = { 'error' => $init_data->{msgcat}{empty_password} }
+    #die $init_data->{'error'} if $init_data->{'error'};
+    $results = { 'error' => $init_data->{msgcat}{empty_password} };
   }
   if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
     my $init_data = signup_info( 'session_id' => $session_id );
-    $results = { error => $init_data->{msgcat}{passwords_dont_match} };
+    $results = { 'error' => $init_data->{msgcat}{passwords_dont_match} };
     $cgi->param('_password', '');
     $cgi->param('_password2', '');
   }
@@ -238,17 +361,22 @@
         qw( custnum pkgpart username _password _password2 sec_phrase popnum )
   );
 
-  $action = 'view_customer';
-  $cgi->delete( grep { $_ ne 'custnum' } $cgi->param )
-    unless $results->{'error'};
-
-  return {
-    $cgi->Vars,
-    %{view_customer()},
-    'message' => $results->{'error'}
-                   ? '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>'
-                   : 'Package order sucessful.'
-  };
+  if ( $results->{'error'} ) {
+    $action = 'agent_order_pkg';
+    return {
+      $cgi->Vars,
+      %{agent_order_pkg()},
+      #'message' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
+      'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
+    };
+  } else {
+    $action = 'view_customer';
+    #$cgi->delete( grep { $_ ne 'custnum' } $cgi->param );
+    return {
+      %{view_customer()},
+      'message' => 'Package order sucessful.',
+    };
+  }
 
 }
 
@@ -277,5 +405,23 @@
 }
 
 package FS::SelfService::_agentcgi;
+
+use HTML::Entities;
 use FS::SelfService qw(regionselector expselect popselector);
+
+#false laziness w/selfservice.cgi
+sub include {
+  my $name = shift;
+  my $template = new Text::Template( TYPE   => 'FILE',
+                                     SOURCE => "$main::template_dir/$name.html",
+                                     DELIMITERS => [ '<%=', '%>' ],
+                                     UNTAINT => 1,                   
+                                   )
+    or die $Text::Template::ERROR;
+
+  $template->fill_in( PACKAGE => 'FS::SelfService::_agentcgi',
+                      #HASH    => $fill_in
+                    );
+
+}
 

--- NEW FILE: provision_list.html ---
<FONT SIZE=4>Setup services</FONT><BR><BR>

<SCRIPT>
function areyousure(href, message) {
    if (confirm(message) == true)
        window.location.href = href;
}
</SCRIPT>

<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#ffffff">

<%= foreach my $pkg (
      grep {    scalar(@{$_->{part_svc}})
             || scalar(@{$_->{cust_svc}})
           } @cust_pkg
    ) {

  $OUT .= #'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#ffffff">'.
          '<TR><TH BGCOLOR="#6666ff" COLSPAN=3>'.
          $pkg->{'pkg'}.
          '</TH></TR>';

  my $col1 = "ffffff";
  my $col2 = "dddddd";
  my $col = $col1;

  foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) {
    my $td = qq!<TD BGCOLOR="#$col"!;

    $OUT .= '<TR>'.
              "$td ALIGN=right>". $cust_svc->{label}[0]. ': </TD>'.
              "$td><B>". $cust_svc->{label}[1]. '</B>';
    $OUT .= '<BR><I>password: '. encode_entities($cust_svc->{_password}). '</I>'
      if exists($cust_svc->{_password});
    $OUT .= '</TD>'.
              "$td><FONT SIZE=-1>";
              
    #if ( $cust_svc->{label}[2] eq 'svc_acct' ) {
    #  $OUT .= qq!(<A HREF="${url}changepw;svcnum=$cust_svc->{'svcnum'}">!.
    #          'change&nbsp;pw) ';
    #}

    unless ( $cust_svc->{'svcnum'} == $svcnum ) {
      $OUT .= qq!(<A HREF="javascript:areyousure('${url}delete_svc;svcnum=$cust_svc->{svcnum}', 'This will perminantly delete the $cust_svc->{label}[1] $cust_svc->{label}[0].  Are you sure?')">!.
              'delete</A>)';

    }
    $OUT .= '</FONT></TD></TR>';
    $col = $col eq $col1 ? $col2 : $col1;
  }

  $OUT .= '<TR><TD COLSPAN=3 BGCOLOR="#000000"></TD></TR>'
    if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}});

  $col = $col1;

  foreach my $part_svc ( @{ $pkg->{part_svc} } ) {

    my $td = qq!<TD BGCOLOR="#$col"!;

    $OUT .= "<TR>$td COLSPAN=3 ALIGN=center>".
            qq!<A HREF="${url}provision_svc;pkgnum=$pkg->{'pkgnum'};svcpart=$part_svc->{'svcpart'}">!.
            'Setup '. $part_svc->{'svc'}. '</A> '.
            '('. $part_svc->{'num_avail'}. ' available)'.
            '</TD></TR>';
    $col = $col eq $col1 ? $col2 : $col1;
  }

  #$OUT .= '</TABLE><BR>';
  $OUT .= '<TR><TD BGCOLOR="#eeeeee" COLSPAN=3>&nbsp;</TD></TR>';

} %>

</TABLE>

--- NEW FILE: agent_customer_menu.html ---
<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %>
<TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
<A HREF="<%= $url %>agent_provision">Setup services</A><BR><BR>
<A HREF="<%= $url %>agent_order_pkg">Purchase additional package</A><BR><BR>

</TD>


Index: provision.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/provision.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- provision.html	15 Jul 2004 22:40:00 -0000	1.1
+++ provision.html	24 Aug 2004 11:16:56 -0000	1.2
@@ -4,73 +4,7 @@
 <TABLE BORDER=0 CELLPADDING=4><TR>
 <%= include('myaccount_menu') %>
 <TD VALIGN="top">
-<FONT SIZE=4>Setup services</FONT><BR><BR>
-
-<SCRIPT>
-function areyousure(href, message) {
-    if (confirm(message) == true)
-        window.location.href = href;
-}
-</SCRIPT>
-
-<%= foreach my $pkg (
-      grep {    scalar(@{$_->{part_svc}})
-             || scalar(@{$_->{cust_svc}})
-           } @cust_pkg
-    ) {
-
-  $OUT .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#ffffff">'.
-          '<TR><TH BGCOLOR="#6666ff" COLSPAN=3>'.
-          $pkg->{'pkg'}.
-          '</TH></TR>';
-
-  my $col1 = "ffffff";
-  my $col2 = "dddddd";
-  my $col = $col1;
-
-  foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) {
-    my $td = qq!<TD BGCOLOR="#$col"!;
-
-    $OUT .= '<TR>'.
-              "$td ALIGN=right>". $cust_svc->{label}[0]. ': </TD>'.
-              "$td><B>". $cust_svc->{label}[1]. '</B></TD>'.
-              "$td><FONT SIZE=-1>";
-              
-    #if ( $cust_svc->{label}[2] eq 'svc_acct' ) {
-    #  $OUT .= qq!(<A HREF="${url}changepw;svcnum=$cust_svc->{'svcnum'}">!.
-    #          'change&nbsp;pw) ';
-    #}
-
-    unless ( $cust_svc->{'svcnum'} == $svcnum ) {
-      $OUT .= qq!(<A HREF="javascript:areyousure('${url}delete_svc;svcnum=$cust_svc->{svcnum}', 'This will perminantly delete the $cust_svc->{label}[1] $cust_svc->{label}[0].  Are you sure?')">!.
-              'delete</A>)';
-
-    }
-    $OUT .= '</FONT></TD></TR>';
-    $col = $col eq $col1 ? $col2 : $col1;
-  }
-
-  $OUT .= '<TR><TD COLSPAN=3 BGCOLOR="#000000"></TD></TR>'
-    if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}});
-
-  my $col = $col1;
-
-  foreach my $part_svc ( @{ $pkg->{part_svc} } ) {
-
-    my $td = qq!<TD BGCOLOR="#$col"!;
-
-    $OUT .= "<TR>$td COLSPAN=3>".
-            qq!<A HREF="${url}provision_svc;pkgnum=$pkg->{'pkgnum'};svcpart=$part_svc->{'svcpart'}">!.
-            'Setup '. $part_svc->{'svc'}. '</A> '.
-            '('. $part_svc->{'num_avail'}. ' available)'.
-            '</TD></TR>';
-    $col = $col eq $col1 ? $col2 : $col1;
-  }
-
-  $OUT .= '</TABLE><BR>';
-
-} %>
-
+<%= include('provision_list') %>
 </TD></TR></TABLE>
 <HR>
 <FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>

Index: selfservice.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/selfservice.cgi,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- selfservice.cgi	15 Jul 2004 22:40:00 -0000	1.8
+++ selfservice.cgi	24 Aug 2004 11:16:56 -0000	1.9
@@ -6,6 +6,7 @@
 use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use Text::Template;
+use HTML::Entities;
 use FS::SelfService qw( login customer_info invoice
                         payment_info process_payment 
                         list_pkgs
@@ -176,7 +177,9 @@
 }
 
 sub provision {
-  list_pkgs( 'session_id' => $session_id );
+  my $result = list_pkgs( 'session_id' => $session_id );
+  die $result->{'error'} if exists $result->{'error'} && $result->{'error'};
+  $result;
 }
 
 sub provision_svc {
@@ -204,7 +207,7 @@
   );
 
   if ( exists $result->{'error'} && $result->{'error'} ) { 
-    warn "$result $result->{'error'}"; 
+    #warn "$result $result->{'error'}"; 
     $action = 'provision_svc_acct';
     return {
       $cgi->Vars,
@@ -215,7 +218,7 @@
       'error' => $result->{'error'},
     };
   } else {
-    warn "$result $result->{'error'}"; 
+    #warn "$result $result->{'error'}"; 
     return $result;
   }
 
@@ -255,8 +258,10 @@
 package FS::SelfService::_selfservicecgi;
 
 #use FS::SelfService qw(regionselector expselect popselector);
+use HTML::Entities;
 use FS::SelfService qw(popselector);
 
+#false laziness w/agent.cgi
 sub include {
   my $name = shift;
   my $template = new Text::Template( TYPE   => 'FILE',
@@ -266,7 +271,9 @@
                                    )
     or die $Text::Template::ERROR;
 
-  $template->fill_in();
+  $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi',
+                      #HASH    => $fill_in
+                    );
 
 }
 

--- NEW FILE: agent_provision.html ---
<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %>
<TABLE BORDER=0 CELLPADDING=4><TR>
<%= include('agent_menu') %>
<TD VALIGN="top">

<%= $message
      ? "<FONT SIZE=\"+2\"><B>$message</B></FONT><BR><BR>"
      : ''
%>

<%= $small_custview %>
<BR>

<TABLE BORDER=0 CELLPADDING=4><TR>
<%= include('agent_customer_menu') %>
<TD VALIGN="top">
<%= include('provision_list') %>
</TD></TR></TABLE>

</TD></TR></TABLE>
<HR>
<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
</BODY></HTML>




More information about the freeside-commits mailing list