[freeside-commits] branch master updated. 16e107a846556c19d837c8fd704d5e2089199597

Ivan ivan at 420.am
Fri Dec 5 14:24:13 PST 2014


The branch, master has been updated
       via  16e107a846556c19d837c8fd704d5e2089199597 (commit)
       via  e68a2a20972de41485c438c46d197b5abeee3267 (commit)
      from  d85c80937449d6ecb08b58fe8c09a37c26063410 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 16e107a846556c19d837c8fd704d5e2089199597
Merge: e68a2a2 d85c809
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Dec 5 14:24:07 2014 -0800

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit e68a2a20972de41485c438c46d197b5abeee3267
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Dec 5 14:24:01 2014 -0800

    disable agent types, RT#31446

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 91dfc5d..492f8e2 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -556,12 +556,13 @@ sub tables_hashref {
 
     'agent_type' => {
       'columns' => [
-        'typenum',   'serial',  '', '', '', '', 
-        'atype',     'varchar', '', $char_d, '', '', 
+        'typenum',  'serial',      '',      '', '', '',
+        'atype',    'varchar',     '', $char_d, '', '',
+        'disabled',    'char', 'NULL',       1, '', '',
       ],
       'primary_key' => 'typenum',
       'unique' => [],
-      'index' => [],
+      'index' => [ ['disabled'] ],
     },
 
     'type_pkgs' => {
diff --git a/FS/FS/agent_type.pm b/FS/FS/agent_type.pm
index 5d6b94e..e0f7495 100644
--- a/FS/FS/agent_type.pm
+++ b/FS/FS/agent_type.pm
@@ -45,9 +45,17 @@ FS::Record.  The following fields are currently supported:
 
 =over 4
 
-=item typenum - primary key (assigned automatically for new agent types)
+=item typenum
 
-=item atype - Text name of this agent type
+primary key (assigned automatically for new agent types)
+
+=item atype
+
+Text name of this agent type
+
+=item disabled
+
+Disabled flag, empty or 'Y'
 
 =back
 
@@ -103,8 +111,9 @@ sub check {
   my $self = shift;
 
   $self->ut_numbern('typenum')
-  or $self->ut_text('atype')
-  or $self->SUPER::check;
+    || $self->ut_text('atype')
+    || $self->ut_enum('disabled', [ '', 'Y' ] )
+    || $self->SUPER::check;
 
 }
 
diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi
index 7711dcc..0c011ce 100755
--- a/httemplate/browse/agent_type.cgi
+++ b/httemplate/browse/agent_type.cgi
@@ -1,27 +1,28 @@
-<% include( 'elements/browse.html',
-                 'title'   => 'Agent Types',
-                 'menubar'     => [ 'Agents'    =>"${p}browse/agent.cgi", ],
-                 'html_init'   => $html_init,
-                 'name'        => 'agent types',
-                 'query'       => { 'table'     => 'agent_type',
-                                    'hashref'   => {},
-                                    'order_by' => 'ORDER BY typenum', # 'ORDER BY atype',
-                                  },
-                 'count_query' => $count_query,
-                 'header'      => [ '#',
-                                    'Agent Type',
-                                    'Packages',
-                                  ],
-                 'fields'      => [ 'typenum',
-                                    'atype',
-                                    $packages_sub,
-                                  ],
-                 'links'       => [ $link,
-                                    $link,
-                                    '',
-                                  ],
-             )
-%>
+<& elements/browse.html,
+     'title'              => 'Agent Types',
+     'menubar'            => [ 'Agents' => "${p}browse/agent.cgi" ],
+     'html_init'          => $html_init,
+     'name'               => 'agent types',
+     'disableable'        => 1,
+     'disabled_statuspos' => 2,
+     'query'              => { 'table'     => 'agent_type',
+                               'hashref'   => {},
+                               'order_by' => 'ORDER BY typenum', # atype?
+                             },
+     'count_query'        => $count_query,
+     'header'             => [ '#',
+                               'Agent Type',
+                               'Packages',
+                             ],
+     'fields'             => [ 'typenum',
+                               'atype',
+                               $packages_sub,
+                             ],
+     'links'              => [ $link,
+                               $link,
+                               '',
+                             ],
+&>
 <%init>
 
 die "access denied"
@@ -36,25 +37,26 @@ my $count_query = 'SELECT COUNT(*) FROM agent_type';
 
 #false laziness w/access_user.html
 my $packages_sub = sub {
-my $agent_type = shift;
-
-[ map  {
-         my $type_pkgs = $_;
-         #my $part_pkg = $type_pkgs->part_pkg;
-         [
-           {
-             #'data'  => $part_pkg->pkg. ' - '. $part_pkg->comment,
-             'data'  => encode_entities($type_pkgs->pkg). ' - '.
-                        ( $type_pkgs->custom ? '(CUSTOM) ' : '' ).
-                        encode_entities($type_pkgs->comment),
-             'align' => 'left',
-             'link'  => $p. 'edit/part_pkg.cgi?'. $type_pkgs->pkgpart,
-           },
-         ];
-       }
-
-  $agent_type->type_pkgs_enabled
-];
+  my $agent_type = shift;
+  my @type_pkgs = $agent_type->type_pkgs_enabled;
+  return '(lots; edit agent type to view)' if scalar(@type_pkgs) > 32;
+
+  [ map {
+          my $type_pkgs = $_;
+          #my $part_pkg = $type_pkgs->part_pkg;
+          [
+            {
+              #'data'  => $part_pkg->pkg. ' - '. $part_pkg->comment,
+              'data'  => encode_entities($type_pkgs->pkg). ' - '.
+                         ( $type_pkgs->custom ? '(CUSTOM) ' : '' ).
+                         encode_entities($type_pkgs->comment),
+              'align' => 'left',
+              'link'  => $p. 'edit/part_pkg.cgi?'. $type_pkgs->pkgpart,
+            },
+          ];
+        }
+      @type_pkgs
+  ];
 
 };
 
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index 1eb55c8..87aa792 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -77,11 +77,11 @@ if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
 $cgi->delete('classnum');
 
 if ( $cgi->param('missing_recur_fee') ) {
-  push @where, "0 = ( SELECT COUNT(*) FROM part_pkg_option
-                        WHERE optionname = 'recur_fee'
-                          AND part_pkg_option.pkgpart = part_pkg.pkgpart
-                          AND CAST( optionvalue AS NUMERIC ) > 0
-                    )";
+  push @where, "NOT EXISTS ( SELECT 1 FROM part_pkg_option
+                               WHERE optionname = 'recur_fee'
+                                 AND part_pkg_option.pkgpart = part_pkg.pkgpart
+                                 AND CAST( optionvalue AS NUMERIC ) > 0
+                           )";
 }
 
 if ( $cgi->param('family') =~ /^(\d+)$/ ) {
@@ -419,7 +419,8 @@ push @fields, sub {
 #agent type
 if ( $acl_edit_global ) {
   #really we just want a count, but this is fine unless someone has tons
-  my @all_agent_types = map {$_->typenum} qsearch('agent_type',{});
+  my @all_agent_types = map {$_->typenum}
+                          qsearch('agent_type', { 'disabled'=>'' });
   if ( scalar(@all_agent_types) > 1 ) {
     push @header, 'Agent types';
     my $typelink = $p. 'edit/agent_type.cgi?';
diff --git a/httemplate/edit/agent.cgi b/httemplate/edit/agent.cgi
index 15da2f0..c4963e4 100755
--- a/httemplate/edit/agent.cgi
+++ b/httemplate/edit/agent.cgi
@@ -35,7 +35,7 @@
     <TH ALIGN="right">Agent type</TH>
     <TD>
       <SELECT NAME="typenum" SIZE=1>
-%       foreach my $agent_type (qsearch('agent_type',{})) { 
+%       foreach my $agent_type ( qsearch('agent_type', { 'disabled'=>'' }) ) { 
 
           <OPTION VALUE="<% $agent_type->typenum %>"<% ( $agent->typenum && ( $agent->typenum == $agent_type->typenum ) ) ? ' SELECTED' : '' %>>
     <% $agent_type->getfield('typenum') %>: <% $agent_type->getfield('atype') %>
diff --git a/httemplate/edit/agent_type.cgi b/httemplate/edit/agent_type.cgi
index b75757f..f16d76c 100755
--- a/httemplate/edit/agent_type.cgi
+++ b/httemplate/edit/agent_type.cgi
@@ -7,15 +7,31 @@
 
 <FORM ACTION="<% popurl(1) %>process/agent_type.cgi" METHOD=POST>
 <INPUT TYPE="hidden" NAME="typenum" VALUE="<% $agent_type->typenum %>">
+
+<FONT CLASS="fsinnerbox-title">
 Agent Type #<% $agent_type->typenum || "(NEW)" %>
+</FONT>
+
+<TABLE CLASS="fsinnerbox">
+
+  <TR>
+    <TH ALIGN="right">Agent Type</TH>
+    <TD><INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<% $agent_type->atype %>"></TD>
+  </TR>
+
+  <TR>
+    <TH ALIGN="right">Disable</TH>
+    <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y" <% $agent_type->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
+  </TR>
+
+<TABLE>
 <BR>
 
-Agent Type
-<INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<% $agent_type->atype %>">
-<BR><BR>
+<FONT CLASS="fsinnerbox-title">
+Package definitions that agents of this type can sell
+</FONT>
 
-Select which packages agents of this type may sell to customers<BR>
-<% ntable("#cccccc", 2) %><TR><TD>
+<TABLE CLASS="fsinnerbox"><TR><TD>
 <% include('/elements/checkboxes-table.html',
               'source_obj'    => $agent_type,
               'link_table'    => 'type_pkgs',
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index 2ae9df3..c4db83a 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -654,8 +654,7 @@ my $new_callback = sub {
   my $conf = new FS::Conf; 
 
   if ( $conf->exists('agent_defaultpkg') ) {
-    #my @all_agent_types = map {$_->typenum} qsearch('agent_type',{});
-    @agent_type = map {$_->typenum} qsearch('agent_type',{});
+    @agent_type = map {$_->typenum} qsearch('agent_type', { 'disabled'=>'' });
   }
 
   $options{'suspend_bill'}=1 if $conf->exists('part_pkg-default_suspend_bill');
diff --git a/httemplate/elements/tr-select-agent_type.html b/httemplate/elements/tr-select-agent_type.html
index 9ea943b..3e6ce07 100644
--- a/httemplate/elements/tr-select-agent_type.html
+++ b/httemplate/elements/tr-select-agent_type.html
@@ -7,11 +7,10 @@
   <TR>
     <TD ALIGN="right"><% $opt{'label'} || 'Agent Type' %></TD>
     <TD>
-      <% include( '/elements/select-agent_type.html',
-                     'curr_value'  => $typenum,
-                     %opt,
-                 )
-      %>
+      <& /elements/select-agent_type.html,
+           'curr_value'  => $typenum,
+           %opt,
+      &>
     </TD>
   </TR>
 
@@ -22,6 +21,6 @@
 my %opt = @_;
 my $typenum = $opt{'curr_value'} || $opt{'value'};
 
-my @agent_types = qsearch('agent_type', {});
+my @agent_types = qsearch('agent_type', { 'disabled' => '' });
 
 </%init>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Schema.pm                               |    7 +-
 FS/FS/agent_type.pm                           |   17 +++--
 httemplate/browse/agent_type.cgi              |   88 +++++++++++++------------
 httemplate/browse/part_pkg.cgi                |   13 ++--
 httemplate/edit/agent.cgi                     |    2 +-
 httemplate/edit/agent_type.cgi                |   26 ++++++--
 httemplate/edit/part_pkg.cgi                  |    3 +-
 httemplate/elements/tr-select-agent_type.html |   11 ++--
 8 files changed, 97 insertions(+), 70 deletions(-)




More information about the freeside-commits mailing list