[freeside-commits] branch master updated. 8e83c67a7c8fdb375e9c48f6dac92b1fcd5b5e3a

Ivan ivan at 420.am
Fri Apr 19 13:54:10 PDT 2013


The branch, master has been updated
       via  8e83c67a7c8fdb375e9c48f6dac92b1fcd5b5e3a (commit)
       via  29040dc99217d630e87236fe7e25dd97ad8b9990 (commit)
       via  c0c1485222462c4df5aac8e209a865c984262d3c (commit)
       via  20aa565c8c1916a86a11726c33f087306f105164 (commit)
      from  b279ca3f1c66ea5f589421196b7c5fc5f7163ec4 (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 8e83c67a7c8fdb375e9c48f6dac92b1fcd5b5e3a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Apr 19 13:54:09 2013 -0700

    add "Only count paid bills" option to "Run only once for each time the package has been billed" condition, for commissions, RT#21040

diff --git a/FS/FS/part_event/Condition/once_perinv.pm b/FS/FS/part_event/Condition/once_perinv.pm
index f85a056..1ee53b8 100644
--- a/FS/FS/part_event/Condition/once_perinv.pm
+++ b/FS/FS/part_event/Condition/once_perinv.pm
@@ -12,6 +12,15 @@ sub description { "Run only once for each time the package has been billed"; }
 # Run the event, at most, a number of times equal to the number of 
 # distinct invoices that contain line items from this package.
 
+sub option_fields {
+  (
+    'paid' => { 'label' => 'Only count paid bills',
+                'type'  => 'checkbox',
+                'value' => 'Y',
+              },
+  )
+}
+
 sub eventtable_hashref {
     { 'cust_main' => 0,
       'cust_bill' => 0,
@@ -22,9 +31,15 @@ sub eventtable_hashref {
 sub condition {
   my($self, $cust_pkg, %opt) = @_;
 
-  my %invnum;
-  $invnum{$_->invnum} = 1 
-    foreach ( qsearch('cust_bill_pkg', { 'pkgnum' => $cust_pkg->pkgnum }) );
+  my @cust_bill_pkg = qsearch('cust_bill_pkg', { pkgnum=>$cust_pkg->pkgnum });
+
+  @cust_bill_pkg = grep { ($_->owed_setup + $_->owed_recur) == 0 }
+                     @cust_bill_pkg
+    if $self->option('paid');
+
+  my %invnum = ();
+  $invnum{$_->invnum} = 1 foreach @cust_bill_pkg;
+
   my @events = qsearch( {
       'table'     => 'cust_event', 
       'hashref'   => { 'eventpart' => $self->eventpart,
@@ -40,6 +55,9 @@ sub condition {
 sub condition_sql {
   my( $self, $table ) = @_;
 
+  #paid flag not yet implemented here, but that's okay, a partial optimization
+  # is better than none
+
   "( 
     ( SELECT COUNT(distinct(invnum)) 
       FROM cust_bill_pkg

commit 29040dc99217d630e87236fe7e25dd97ad8b9990
Merge: c0c1485 b279ca3
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Apr 19 13:54:03 2013 -0700

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


commit c0c1485222462c4df5aac8e209a865c984262d3c
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Apr 19 13:05:56 2013 -0700

    package contacts / "name per packages", RT#22185

diff --git a/httemplate/misc/change_pkg_contact.html b/httemplate/misc/change_pkg_contact.html
new file mode 100755
index 0000000..d9da5be
--- /dev/null
+++ b/httemplate/misc/change_pkg_contact.html
@@ -0,0 +1,70 @@
+<& /elements/header-popup.html, mt("Change Package Contact") &>
+
+<& /elements/error.html &>
+
+<FORM ACTION="<% $p %>misc/process/change_pkg_contact.html" METHOD=POST>
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+
+<% ntable('#cccccc') %>
+
+  <TR>
+    <TH ALIGN="right"><% mt('Package') |h %></TH>
+    <TD COLSPAN=7>
+      <% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %>
+    </TD>
+  </TR>
+
+% if ( $cust_pkg->contactnum ) {
+    <TR>
+      <TH ALIGN="right"><% mt('Current Contact') %></TH>
+      <TD COLSPAN=7>
+        <% $cust_pkg->contact_obj->line |h %>
+      </TD>
+    </TR>
+% }
+
+<& /elements/tr-select-contact.html,
+             'label'         => mt('New Contact'), #XXX test
+             'cgi'           => $cgi,
+             'cust_main'     => $cust_pkg->cust_main,
+&>
+
+</TABLE>
+
+<BR>
+<INPUT TYPE    = "submit"
+       VALUE   = "<% $cust_pkg->contactnum ? mt("Change contact") : mt("Add contact") |h %>"
+>
+
+</FORM>
+</BODY>
+</HTML>
+
+<%init>
+
+my $conf = new FS::Conf;
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied"
+  unless $curuser->access_right('Change customer package');
+
+my $pkgnum = scalar($cgi->param('pkgnum'));
+$pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
+$pkgnum = $1;
+
+my $cust_pkg =
+  qsearchs({
+    'table'     => 'cust_pkg',
+    'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
+    'hashref'   => { 'pkgnum' => $pkgnum },
+    'extra_sql' => ' AND '. $curuser->agentnums_sql,
+  }) or die "unknown pkgnum $pkgnum";
+
+my $cust_main = $cust_pkg->cust_main
+  or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
+         " ( pkgnum ". cust_pkg->pkgnum. ")";
+
+my $part_pkg = $cust_pkg->part_pkg;
+
+</%init>
diff --git a/httemplate/misc/process/change_pkg_contact.html b/httemplate/misc/process/change_pkg_contact.html
new file mode 100644
index 0000000..2795c11
--- /dev/null
+++ b/httemplate/misc/process/change_pkg_contact.html
@@ -0,0 +1,49 @@
+<% header(emt("Package contact $past_method")) %>
+  <SCRIPT TYPE="text/javascript">
+    window.top.location.reload();
+  </SCRIPT>
+  </BODY>
+</HTML>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Change customer package');
+
+#untaint pkgnum
+my $pkgnum = $cgi->param('pkgnum');
+$pkgnum =~ /^(\d+)$/ or die "Illegal pkgnum";
+$pkgnum = $1;
+
+my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} ); #needs agent virt
+
+my $contactnum = $cgi->param('contactnum');
+$contactnum =~ /^(-?\d*)$/ or die "Illegal contactnum";
+$contactnum = $1;
+
+my $past_method = $cust_pkg->contactnum ? 'changed' : 'added';
+
+my $error = '';
+
+if ( $contactnum == -1 ) {
+
+  #little false laziness w/edit/process/quick-cust_pkg.cgi, also the whole
+  # thing should be a single transaction
+  my $contact = new FS::contact {
+    'custnum' => $cust_pkg->custnum,
+    map { $_ => scalar($cgi->param("contactnum_$_")) } qw( first last )
+  };
+  $error = $contact->insert;
+  $cust_pkg->contactnum( $contact->contactnum );
+
+} else {
+  $cust_pkg->contactnum($contactnum);
+}
+
+$error ||= $cust_pkg->replace;
+
+if ($error) {
+  $cgi->param('error', $error);
+  print $cgi->redirect(popurl(2). "change_pkg_contact.html?". $cgi->query_string );
+}
+
+</%init>
diff --git a/httemplate/view/cust_main/packages/contact.html b/httemplate/view/cust_main/packages/contact.html
index dd78239..9312991 100644
--- a/httemplate/view/cust_main/packages/contact.html
+++ b/httemplate/view/cust_main/packages/contact.html
@@ -31,6 +31,8 @@ sub pkg_change_contact_link {
     'label'       => emt('Change'), # contact'),
     'actionlabel' => emt('Change'),
     'cust_pkg'    => $cust_pkg,
+    'width'       => 616,
+    'height'      => 220,
   );
 }
 
@@ -42,6 +44,8 @@ sub pkg_add_contact_link {
     'label'       => emt('Add contact'),
     'actionlabel' => emt('Change'),
     'cust_pkg'    => $cust_pkg,
+    'width'       => 616,
+    'height'      => 192,
   );
 }
 

commit 20aa565c8c1916a86a11726c33f087306f105164
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Apr 19 11:54:58 2013 -0700

    package contacts / "name per packages", RT#22185

diff --git a/httemplate/view/cust_main/packages/contact.html b/httemplate/view/cust_main/packages/contact.html
index c3b161b..dd78239 100644
--- a/httemplate/view/cust_main/packages/contact.html
+++ b/httemplate/view/cust_main/packages/contact.html
@@ -1,18 +1,15 @@
 % if ( $contact ) {
     <% $contact->line |h %>
+% if ( $show_link ) {
+        <FONT SIZE=-1>
+          ( <%pkg_change_contact_link($cust_pkg)%> )
+        </FONT>
+%    }
+% } elsif ( $show_link ) {
+        <FONT SIZE=-1>
+          ( <%pkg_add_contact_link($cust_pkg)%> )
+        </FONT>
 % }
-
-% if ( ! $cust_pkg->get('cancel')
-%      && $FS::CurrentUser::CurrentUser->access_right('Change customer package')
-%    )
-% {
-  <FONT SIZE=-1>
-%#XXX    ( <%pkg_change_contact_link($cust_pkg)%> )
-%#  %   if ( $cust_pkg->contactnum ) {
-%#          ( <%edit_contact_link($cust_pkg->contactnum)%> )
-%#  %   }
-  </FONT>
-% } 
 <%init>
 
 my $conf = new FS::Conf;
@@ -20,27 +17,41 @@ my %opt = @_;
 
 my $cust_pkg       = $opt{'cust_pkg'};
 
+my $show_link = 
+  ! $cust_pkg->get('cancel')
+  && $FS::CurrentUser::CurrentUser->access_right('Change customer package');
+
 my $contact = $cust_pkg->contact_obj;
 
 sub pkg_change_contact_link {
   my $cust_pkg = shift;
-  my $pkgpart = $cust_pkg->pkgpart;
+  #my $pkgpart = $cust_pkg->pkgpart;
   include( '/elements/popup_link-cust_pkg.html',
-#XXX
-    'action'      => $p. "misc/change_pkg.cgi?contactnum=-1",
-    'label'       => emt('Change contact'),
+    'action'      => $p. "misc/change_pkg_contact.html",
+    'label'       => emt('Change'), # contact'),
     'actionlabel' => emt('Change'),
     'cust_pkg'    => $cust_pkg,
   );
 }
 
-sub edit_contact_link {
-  my $contactnum = shift;
-  include( '/elements/popup_link.html',
-    'action'      => $p. "edit/cust_contact.cgi?contactnum=$contactnum",
-    'label'       => emt('Edit contact'),
-    'actionlabel' => emt('Edit'),
+sub pkg_add_contact_link {
+  my $cust_pkg = shift;
+  #my $pkgpart = $cust_pkg->pkgpart;
+  include( '/elements/popup_link-cust_pkg.html',
+    'action'      => $p. "misc/change_pkg_contact.html",
+    'label'       => emt('Add contact'),
+    'actionlabel' => emt('Change'),
+    'cust_pkg'    => $cust_pkg,
   );
 }
 
+#sub edit_contact_link {
+#  my $contactnum = shift;
+#  include( '/elements/popup_link.html',
+#    'action'      => $p. "edit/cust_contact.cgi?contactnum=$contactnum",
+#    'label'       => emt('Edit contact'),
+#    'actionlabel' => emt('Edit'),
+#  );
+#}
+
 </%init>

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

Summary of changes:
 FS/FS/part_event/Condition/once_perinv.pm          |   24 +++++++-
 .../{change_pkg.cgi => change_pkg_contact.html}    |   45 ++++++---------
 httemplate/misc/process/change_pkg_contact.html    |   49 ++++++++++++++++
 httemplate/view/cust_main/packages/contact.html    |   59 ++++++++++++-------
 4 files changed, 126 insertions(+), 51 deletions(-)
 copy httemplate/misc/{change_pkg.cgi => change_pkg_contact.html} (50%)
 create mode 100644 httemplate/misc/process/change_pkg_contact.html




More information about the freeside-commits mailing list