[freeside-commits] branch FREESIDE_3_BRANCH updated. d4e9d68a229b01207ee9e6f3679bb65e7f13cf08

Ivan ivan at 420.am
Sat Aug 17 22:41:51 PDT 2013


The branch, FREESIDE_3_BRANCH has been updated
       via  d4e9d68a229b01207ee9e6f3679bb65e7f13cf08 (commit)
       via  90c127d346a6999e6be4a54277339924b73eeb0e (commit)
       via  6c5faef401d21a8ddfdc0ebb2a44a886960147cd (commit)
      from  23c8996f73976d52a4380d616ed9276d9640f444 (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 d4e9d68a229b01207ee9e6f3679bb65e7f13cf08
Merge: 90c127d 23c8996
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Aug 17 22:36:45 2013 -0700

    Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH


commit 90c127d346a6999e6be4a54277339924b73eeb0e
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Aug 17 22:36:25 2013 -0700

    continue sales person work: customer and package selection, commissions, reporting.  RT#23402

diff --git a/FS/FS/Agent_Mixin.pm b/FS/FS/Agent_Mixin.pm
new file mode 100644
index 0000000..0f84ba9
--- /dev/null
+++ b/FS/FS/Agent_Mixin.pm
@@ -0,0 +1,42 @@
+package FS::Agent_Mixin;
+
+use strict;
+use FS::Record qw( qsearchs );
+use FS::agent;
+
+=head1 NAME
+
+FS::Agent_Mixin - Mixin class for objects that have an agent.
+
+=over 4
+
+=item agent
+
+Returns the agent (see L<FS::agent>) for this object.
+
+=cut
+
+sub agent {
+  my $self = shift;
+  qsearchs( 'agent', { 'agentnum' => $self->agentnum } );
+}
+
+=item agent_name
+
+Returns the agent name (see L<FS::agent>) for this object.
+
+=cut
+
+sub agent_name {
+  my $self = shift;
+  $self->agent->agent;
+}
+
+=back
+
+=head1 BUGS
+
+=cut
+
+1;
+
diff --git a/httemplate/browse/sales.html b/httemplate/browse/sales.html
new file mode 100644
index 0000000..1cdc490
--- /dev/null
+++ b/httemplate/browse/sales.html
@@ -0,0 +1,32 @@
+<& elements/browse.html,
+     'title'              => 'Sales People',
+     'name_singular'      => 'sales person',
+     'menubar'            => ['Add a new sales person' => $p.'edit/sales.html'],
+     'query'              => { 'table' => 'sales' },
+     'count_query'        => 'SELECT COUNT(*) FROM sales',
+     'header'             => \@header,
+     'fields'             => \@fields,
+     'links'              => \@links,
+     'disableable'        => 1,
+     'disabled_statuspos' => 1,
+     'agent_virt'         => 1,
+&>
+<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied" unless $curuser->access_right('Edit sales people');
+
+my @header = ( 'Sales person' );
+my @fields = ( 'salesperson' );
+my @links  = ( [$p.'edit/sales.html?', 'salesnum'] );
+
+if ( $curuser->access_right('Configuration') ) {
+  push @header, 'Agent';
+  push @fields, 'agent_name';
+  push @links,  [ $p.'edit/agent.cgi?', 'agentnum' ];
+}
+
+#Sales people bring in business.<BR><BR>
+
+</%init>
diff --git a/httemplate/edit/process/sales.html b/httemplate/edit/process/sales.html
new file mode 100644
index 0000000..b60276d
--- /dev/null
+++ b/httemplate/edit/process/sales.html
@@ -0,0 +1,12 @@
+<& elements/process.html,
+     'table'       => 'sales',
+     'viewall_dir' => 'browse',
+     'agent_virt'  => 1,
+&>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Edit sales people');
+
+</%init>
+
diff --git a/httemplate/edit/sales.html b/httemplate/edit/sales.html
new file mode 100755
index 0000000..65cddfc
--- /dev/null
+++ b/httemplate/edit/sales.html
@@ -0,0 +1,21 @@
+<& elements/edit.html,
+     'name_singular' => 'sales person',
+     'table'         => 'sales',
+     'fields'        => [ 'salesperson',
+                          { field=>'agentnum', type=>'select-agent', disable_empty=>1, },
+                          { field=>'disabled', type=>'checkbox', value=>'Y', },
+                        ],
+     'labels'        => { 'salesnum'    => 'Sales Person',
+                          'salesperson' => 'Name',
+                          'agentnum'    => 'Agent',
+                          'disabled'    => 'Disabled',
+                        },
+     'viewall_dir'   => 'browse',
+     'agent_virt'    => 1,
+&>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Edit sales people');
+
+</%init>

commit 6c5faef401d21a8ddfdc0ebb2a44a886960147cd
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Aug 17 22:34:43 2013 -0700

    continue sales person work: customer and package selection, commissions, reporting.  RT#23402

diff --git a/FS/FS/access_groupsales.pm b/FS/FS/access_groupsales.pm
deleted file mode 100644
index 31b07d9..0000000
--- a/FS/FS/access_groupsales.pm
+++ /dev/null
@@ -1,153 +0,0 @@
-package FS::access_groupsales;
-
-use strict;
-use base qw( FS::Record );
-use FS::Record qw( qsearch qsearchs );
-
-=head1 NAME
-
-FS::access_groupsales - Object methods for access_groupsales records
-
-=head1 SYNOPSIS
-
-  use FS::access_groupsales;
-
-  $record = new FS::access_groupsales \%hash;
-  $record = new FS::access_groupsales { 'column' => 'value' };
-
-  $error = $record->insert;
-
-  $error = $new_record->replace($old_record);
-
-  $error = $record->delete;
-
-  $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::access_groupsales object represents an example.  FS::access_groupsales inherits from
-FS::Record.  The following fields are currently supported:
-
-=over 4
-
-=item groupsalesnum
-
-primary key
-
-=item groupnum
-
-groupnum
-
-=item salesnum
-
-salesnum
-
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new example.  To add the example to the database, see L<"insert">.
-
-Note that this stores the hash reference, not a distinct copy of the hash it
-points to.  You can ask the object for a copy with the I<hash> method.
-
-=cut
-
-# the new method can be inherited from FS::Record, if a table method is defined
-
-sub table { 'access_groupsales'; }
-
-=item insert
-
-Adds this record to the database.  If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-# the insert method can be inherited from FS::Record
-
-=item delete
-
-Delete this record from the database.
-
-=cut
-
-# the delete method can be inherited from FS::Record
-
-=item replace OLD_RECORD
-
-Replaces the OLD_RECORD with this one in the database.  If there is an error,
-returns the error, otherwise returns false.
-
-=cut
-
-# the replace method can be inherited from FS::Record
-
-=item check
-
-Checks all fields to make sure this is a valid example.  If there is
-an error, returns the error, otherwise returns false.  Called by the insert
-and replace methods.
-
-=cut
-
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
-sub check {
-  my $self = shift;
-
-  my $error = 
-    $self->ut_numbern('groupsalesnum')
-    || $self->ut_number('groupnum')
-    || $self->ut_number('salesnum')
-  ;
-  return $error if $error;
-
-  $self->SUPER::check;
-}
-
-=back
-
-=item sales
-
-Returns the associated FS::agent object.
-
-=cut
-
-sub sales {
-  my $self = shift;
-  qsearchs('sales', { 'salesnum' => $self->salesnum } );
-}
-
-=item access_group
-
-Returns the associated FS::access_group object.
-
-=cut
-
-sub access_group {
-  my $self = shift;
-  qsearchs('access_group', { 'groupnum' => $self->groupnum } );
-}
-
-=back
-
-
-=head1 BUGS
-
-The author forgot to customize this manpage.
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/t/access_groupsales.t b/FS/t/access_groupsales.t
deleted file mode 100644
index 50993cf..0000000
--- a/FS/t/access_groupsales.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::access_groupsales;
-$loaded=1;
-print "ok 1\n";
diff --git a/httemplate/browse/sales.cgi b/httemplate/browse/sales.cgi
deleted file mode 100755
index af09812..0000000
--- a/httemplate/browse/sales.cgi
+++ /dev/null
@@ -1,100 +0,0 @@
-<% include("/elements/header.html",'Sales Listing', menubar(
-  'Add new sales person' => '../edit/sales.cgi'
-)) %>
-Sales people bring in business.<BR><BR>
-% if ( dbdef->table('sales')->column('disabled') ) { 
-
-  <% $cgi->param('showdisabled')
-      ? do { $cgi->param('showdisabled', 0);
-             '( <a href="'. $cgi->self_url. '">hide disabled sales people</a> )'; }
-      : do { $cgi->param('showdisabled', 1);
-             '( <a href="'. $cgi->self_url. '">show disabled sales people</a> )'; }
-  %>
-% } 
-
-
-<% include('/elements/table-grid.html') %>
-% my $bgcolor1 = '#eeeeee';
-%   my $bgcolor2 = '#ffffff';
-%   my $bgcolor = '';
-
-<TR>
-  <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% ( $cgi->param('showdisabled') || !dbdef->table('sales')->column('disabled') ) ? 2 : 3 %>>Sales person</TH>
-  <TH CLASS="grid" BGCOLOR="#cccccc">Agent</TH>
-  <TH CLASS="grid" BGCOLOR="#cccccc">Access Groups</TH>
-</TR>
-
-%foreach my $sales ( sort { 
-%  $a->getfield('salesnum') cmp $b->getfield('salesnum')
-%} qsearch('sales', \%search ) ) {
-%
-%  if ( $bgcolor eq $bgcolor1 ) {
-%    $bgcolor = $bgcolor2;
-%  } else {
-%    $bgcolor = $bgcolor1;
-%  }
-
-      <TR>
-
-        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-          <A HREF="<%$p%>edit/sales.cgi?<% $sales->salesnum %>"><% $sales->salesnum %></A>
-        </TD>
-
-        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-          <A HREF="<%$p%>edit/sales.cgi?<% $sales->salesnum %>"><% $sales->salesperson %></A>
-        </TD>
-
-%       if ( ! $cgi->param('showdisabled') ) { 
-          <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="center">
-            <% $sales->disabled ? '<FONT COLOR="#FF0000"><B>DISABLED</B></FONT>'
-                                : '<FONT COLOR="#00CC00"><B>Active</B></FONT>'
-            %>
-          </TD>
-%       } 
-
-%       my ($agent) = qsearch('agent', { 'agentnum' => $sales->agentnum });
-
-        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-          <A HREF="<%$p%>edit/sales.cgi?<% $sales->agentnum %>"><% $sales->agentnum %></A>
-          <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>">(<% $agent->agent %>)<BR>
-        </TD>
-
-        <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-%         foreach my $access_group (
-%           map $_->access_group,
-%               qsearch('access_groupsales', { 'salesnum' => $sales->salesnum })
-%         ) {
-            <A HREF="<%$p%>edit/access_group.html?<% $access_group->groupnum %>"><% $access_group->groupname |h %><BR>
-%         }
-        </TD>
-
-      </TR>
-% } 
-
-    </TABLE>
-
-<SCRIPT TYPE="text/javascript">
-  function areyousure(what, href) {
-    if ( confirm("Are you sure you want to " + what + "?") == true )
-      window.location.href = href;
-  }
-</SCRIPT>
-
-  </BODY>
-</HTML>
-<%init>
-
-die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-my %search;
-if ( $cgi->param('showdisabled')
-     || !dbdef->table('agent')->column('disabled') ) {
-  %search = ();
-} else {
-  %search = ( 'disabled' => '' );
-}
-
-my $conf = new FS::Conf;
-
-</%init>
diff --git a/httemplate/edit/process/sales.cgi b/httemplate/edit/process/sales.cgi
deleted file mode 100644
index edef4d6..0000000
--- a/httemplate/edit/process/sales.cgi
+++ /dev/null
@@ -1,23 +0,0 @@
-<% include( 'elements/process.html',
-              'table'       => 'sales',
-              'viewall_dir' => 'browse',
-              'viewall_ext' => 'cgi',
-              'debug'       => '1',
-              'process_m2m' => { 'link_table'   => 'access_groupsales',
-                                 'target_table' => 'access_group',
-                               },
-              'edit_ext'    => 'cgi',
-          )
-%>
-<%init>
-
-die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-if ( FS::Conf->new->exists('disable_acl_changes') ) {
-  errorpage('ACL changes disabled in public demo.');
-  die "shouldn't be reached";
-}
-
-</%init>
-
diff --git a/httemplate/edit/sales.cgi b/httemplate/edit/sales.cgi
deleted file mode 100755
index 3497de5..0000000
--- a/httemplate/edit/sales.cgi
+++ /dev/null
@@ -1,79 +0,0 @@
-<% include("/elements/header.html","$action Sales Person", menubar(
-  'View all sales people' => $p. 'browse/sales.cgi',
-)) %>
-
-<% include('/elements/error.html') %>
-
-<FORM METHOD   = POST
-      ACTION   = "<%popurl(1)%>process/sales.cgi"
->
-
-<INPUT TYPE="hidden" NAME="salesnum" VALUE="<% $sales->salesnum %>">
-Sales #<% $sales->salesnum ? $sales->salesnum : "(NEW)" %>
-
-<% &ntable("#cccccc", 2, '') %>
-
-  <TR>
-    <TH ALIGN="right">Sales</TH>
-    <TD><INPUT TYPE="text" NAME="salesperson" SIZE=32 VALUE="<% $sales->salesperson %>"></TD>
-  </TR>
-
-  <TR>
-    <TD ALIGN="right"><% emt('Agent') %></TD>
-    <TD>
-      <& /elements/select-agent.html,
-                     'curr_value' => $sales->salesnum,
-                     'disable_empty' => 1,
-      &>
-    </TD>
-  </TR>
-
-  <TR>
-    <TD ALIGN="right">Disable</TD>
-    <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $sales->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
-  </TR>
-
-  <TR>
-    <TD ALIGN="right">Access Groups</TD>
-    <TD><% include('/elements/checkboxes-table.html',
-                     'source_obj'   => $sales,
-                     'link_table'   => 'access_groupsales',
-                     'target_table' => 'access_group',
-                     'name_col'     => 'groupname',
-                     'target_link'  => $p. 'edit/access_group.html?',
-                  )
-        %>
-    </TD>
-  </TR>
-
-</TABLE>
-
-<BR>
-<INPUT TYPE="submit" VALUE="<% $sales->salesnum ? "Apply changes" : "Add sales" %>">
-
-</FORM>
-
-<% include('/elements/footer.html') %>
-
-<%init>
-
-die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-my $sales;
-if ( $cgi->param('error') ) {
-  $sales = new FS::sales ( {
-    map { $_, scalar($cgi->param($_)) } fields('sales')
-  } );
-} elsif ( $cgi->keywords ) {
-  my($query) = $cgi->keywords;
-  $query =~ /^(\d+)$/;
-  $sales = qsearchs( 'sales', { 'salesnum' => $1 } );
-} else { #adding
-  $sales = new FS::sales {};
-}
-my $action = $sales->salesnum ? 'Edit' : 'Add';
-
-my $conf = new FS::Conf;
-
-</%init>

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

Summary of changes:
 FS/FS/Agent_Mixin.pm               |   42 ++++++++++
 FS/FS/access_groupsales.pm         |  153 ------------------------------------
 FS/t/access_groupsales.t           |    5 -
 httemplate/browse/sales.cgi        |  100 -----------------------
 httemplate/browse/sales.html       |   32 ++++++++
 httemplate/edit/process/sales.cgi  |   23 ------
 httemplate/edit/process/sales.html |   12 +++
 httemplate/edit/sales.cgi          |   79 ------------------
 httemplate/edit/sales.html         |   21 +++++
 9 files changed, 107 insertions(+), 360 deletions(-)
 create mode 100644 FS/FS/Agent_Mixin.pm
 delete mode 100644 FS/FS/access_groupsales.pm
 delete mode 100644 FS/t/access_groupsales.t
 delete mode 100755 httemplate/browse/sales.cgi
 create mode 100644 httemplate/browse/sales.html
 delete mode 100644 httemplate/edit/process/sales.cgi
 create mode 100644 httemplate/edit/process/sales.html
 delete mode 100755 httemplate/edit/sales.cgi
 create mode 100755 httemplate/edit/sales.html




More information about the freeside-commits mailing list