[freeside-commits] branch master updated. 8dd41f364aaba88969dfd0908feb22709025e7f6

Ivan ivan at 420.am
Thu Dec 4 10:37:23 PST 2014


The branch, master has been updated
       via  8dd41f364aaba88969dfd0908feb22709025e7f6 (commit)
       via  a2df4ef9575be1ae2f1f5b9089f121316f796bac (commit)
       via  e4b861922881a19ce2dec5090d964dd56d38cb6a (commit)
       via  2713274c36a5f7688810241157ff9cd2a3b87b1f (commit)
       via  d87d0051be0696a481ab25fffbd0d53f68af565d (commit)
       via  128cc33659b9811c9ed455275f76fbc7c50a47b7 (commit)
       via  03f11df0ddb098c448c237c6640855f55abb3755 (commit)
       via  2d7110ecd22194c00aa81c798f9ca9056d9189dd (commit)
       via  5228e2f266bce7e42ad24179da3cddb563c687a0 (commit)
       via  d4b8e45c3589f3c6489442798f5fba439d5a29c9 (commit)
       via  a582fcff5237e93aa3d61fc639c4c766e877ccac (commit)
       via  7e78fde169d6e1b25c7e82a9bbcc399d87a2fa02 (commit)
      from  bf50a8356a7344b4f75c7bc7f952019b98867f26 (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 8dd41f364aaba88969dfd0908feb22709025e7f6
Merge: a2df4ef bf50a83
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Dec 4 10:37:16 2014 -0800

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


commit a2df4ef9575be1ae2f1f5b9089f121316f796bac
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Dec 4 10:37:14 2014 -0800

    html nits

diff --git a/httemplate/misc/cancel_cust.html b/httemplate/misc/cancel_cust.html
index 3259a03..ebf1119 100644
--- a/httemplate/misc/cancel_cust.html
+++ b/httemplate/misc/cancel_cust.html
@@ -7,8 +7,7 @@
 
  <P ALIGN="center"><B><% mt('Permanently delete all services and cancel this customer?') |h %></B>
 
-<TABLE BORDER="0" CELLSPACING="2"
-STYLE="margin-left:auto; margin-right:auto">
+<TABLE BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
 <TR>
   <TD ALIGN="right">
     <INPUT TYPE="radio" NAME="now_or_later" VALUE="0" onclick="toggle(false)" CHECKED />
@@ -44,8 +43,7 @@ toggle(false);
          <INPUT TYPE="checkbox" NAME="ban" ID="ban" VALUE="1"><% mt($ban) |h %> 
 % }
 
-<TABLE BGCOLOR="#cccccc", BORDER="0" CELLSPACING="2"
-STYLE="margin-left:auto; margin-right:auto">
+<TABLE BGCOLOR="#cccccc" BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
 <& /elements/tr-select-reason.html,
              'field'          => 'reasonnum',
              'reason_class'   => 'C',

commit e4b861922881a19ce2dec5090d964dd56d38cb6a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Dec 4 10:36:58 2014 -0800

    fix invoice sorting by package category, RT#31272

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 0928ee5..5af5b27 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -2153,9 +2153,9 @@ sub _items_sections {
         } else {
           $section->{'category'} = $sectionname;
           $section->{'description'} = &{ $escape }($sectionname);
-          if ( _pkg_category($_) ) {
-            $section->{'sort_weight'} = _pkg_category($_)->weight;
-            if ( _pkg_category($_)->condense ) {
+          if ( _pkg_category($sectionname) ) {
+            $section->{'sort_weight'} = _pkg_category($sectionname)->weight;
+            if ( _pkg_category($sectionname)->condense ) {
               $section = { %$section, $self->_condense_section($opt{format}) };
             }
           }

commit 2713274c36a5f7688810241157ff9cd2a3b87b1f
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Dec 4 10:36:12 2014 -0800

    contact reports

diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index f26882b..3236bc1 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -89,10 +89,16 @@ my $curuser = $FS::CurrentUser::CurrentUser;
 
 #XXX Active tickets not assigned to a customer
 
-tie my %report_prospects, 'Tie::IxHash',
-  'List prospects' => [ $fsurl. 'search/prospect_main.html', '' ],
-  'Advanced prospect reports' => [ $fsurl. 'search/report_prospect_main.html', '' ],
-;
+tie my %report_prospects, 'Tie::IxHash';
+if ( $curuser->access_right('List prospects') ) {
+  $report_prospects{'List prospects'} = [ $fsurl. 'search/prospect_main.html', '' ];
+  $report_prospects{'Advanced prospect reports'} = [ $fsurl. 'search/report_prospect_main.html', '' ];
+}
+$report_prospects{'separator'} = ''
+  if $curuser->access_right('List prospects')
+  && $curuser->access_right('List contacts');
+$report_prospects{'Prospect contacts'} = [ $fsurl. 'search/report_contact.html?link=prospect_main', '' ]
+  if $curuser->access_right('List contacts');
 
 tie my %report_quotations, 'Tie::IxHash',
   'List quotations' => [ $fsurl. 'search/quotation.html', '' ],
@@ -118,6 +124,10 @@ $report_customers{'Customer churn report'} =  [ $fsurl.'graph/report_cust_churn.
 $report_customers{'Signup date report'}        = [ $fsurl. 'graph/report_signupdate.html',     'Signup date report (by date of signup)' ];
 $report_customers{'Advanced customer reports'} = [ $fsurl. 'search/report_cust_main.html',     'by status, signup date, agent, etc.' ]
   if $curuser->access_right('Advanced customer search');
+if ( $curuser->access_right('List contacts') ) {
+  $report_customers{'separator'} = '';
+  $report_customers{'Customer contacts'} = [ $fsurl. 'search/report_contact.html?link=cust_main' ];
+}
 
 tie my %report_invoices_open, 'Tie::IxHash',
   'All open invoices' => [ $fsurl.'search/cust_bill.html?OPEN_date', 'All invoices with an unpaid balance' ],
@@ -399,11 +409,13 @@ $report_logs{'Outgoing messages'} = [ $fsurl.'search/cust_msg.html', 'View outgo
 
 tie my %report_menu, 'Tie::IxHash';
 $report_menu{'Prospects'}      = [ \%report_prospects, 'Prospect reports' ]
-  if $curuser->access_right('List prospects');
+  if $curuser->access_right('List prospects')
+  || $curuser->access_right('List contacts');
 $report_menu{'Quotations'}     = [ \%report_quotations, 'Quotation reports' ]
   if $curuser->access_right('List quotations');
 $report_menu{'Customers'}      = [ \%report_customers, 'Customer reports'  ]
-  if $curuser->access_right('List customers');
+  if $curuser->access_right('List customers')
+  || $curuser->access_right('List contacts');
 $report_menu{'Invoices'}       =  [ \%report_invoices,  'Invoice reports'   ]
   if $curuser->access_right('List invoices');
 $report_menu{'Discounts'}      =  [ \%report_discounts, 'Discount reports'  ]

commit d87d0051be0696a481ab25fffbd0d53f68af565d
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Dec 4 10:35:56 2014 -0800

    html nits

diff --git a/httemplate/misc/suspend_cust.html b/httemplate/misc/suspend_cust.html
index e0d17f3..8eedd0a 100644
--- a/httemplate/misc/suspend_cust.html
+++ b/httemplate/misc/suspend_cust.html
@@ -7,8 +7,7 @@
 
  <P ALIGN="center"><B><% mt('Suspend this customer?') |h %></B>
 
-<TABLE BORDER="0" CELLSPACING="2"
-STYLE="margin-left:auto; margin-right:auto">
+<TABLE BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
 <TR>
   <TD ALIGN="right">
     <INPUT TYPE="radio" NAME="now_or_later" VALUE="0" onclick="toggle(false)" CHECKED />
@@ -36,8 +35,7 @@ function toggle(val) {
 toggle(false);
 </SCRIPT> 
 
-<TABLE BGCOLOR="#cccccc", BORDER="0" CELLSPACING="2"
-STYLE="margin-left:auto; margin-right:auto">
+<TABLE BGCOLOR="#cccccc" BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
 <& /elements/tr-select-reason.html,
              'field'          => 'reasonnum',
              'reason_class'   => 'S',

commit 128cc33659b9811c9ed455275f76fbc7c50a47b7
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 20 12:02:14 2014 -0800

    optimize

diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm
index a6da3d1..ec3bb12 100644
--- a/FS/FS/tax_rate.pm
+++ b/FS/FS/tax_rate.pm
@@ -1366,11 +1366,14 @@ sub _remember_tax_products {
 
   my ( $imported, $last, $min_sec ) = _progressbar_foo();
 
-  my $extra_sql = "WHERE taxproductnum IS NOT NULL OR ".
-                  "0 < ( SELECT count(*) from part_pkg_option WHERE ".
-                  "       part_pkg_option.pkgpart = part_pkg.pkgpart AND ".
-                  "       optionname LIKE 'usage_taxproductnum_%' AND ".
-                  "       optionvalue != '' )";
+  my $extra_sql = "
+    WHERE taxproductnum IS NOT NULL
+       OR EXISTS ( SELECT 1 from part_pkg_option
+                     WHERE part_pkg_option.pkgpart = part_pkg.pkgpart
+                      AND optionname LIKE 'usage_taxproductnum_%'
+                      AND optionvalue != ''
+                 )
+  ";
   my @items = qsearch( { table => 'part_pkg',
                          select  => 'DISTINCT pkgpart,taxproductnum',
                          hashref => {},

commit 03f11df0ddb098c448c237c6640855f55abb3755
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 20 12:02:08 2014 -0800

    optimize

diff --git a/FS/FS/cust_pkg/Search.pm b/FS/FS/cust_pkg/Search.pm
index 9cd1ff0..aacd387 100644
--- a/FS/FS/cust_pkg/Search.pm
+++ b/FS/FS/cust_pkg/Search.pm
@@ -312,10 +312,10 @@ sub search {
   if (@report_option) {
     # this will result in the empty set for the dangling comma case as it should
     push @where, 
-      map{ "0 < ( SELECT count(*) FROM part_pkg_option
-                    WHERE part_pkg_option.pkgpart = part_pkg.pkgpart
-                    AND optionname = 'report_option_$_'
-                    AND optionvalue = '1' )"
+      map{ "EXISTS ( SELECT 1 FROM part_pkg_option
+                       WHERE part_pkg_option.pkgpart = part_pkg.pkgpart
+                       AND optionname = 'report_option_$_'
+                       AND optionvalue = '1' )"
          } @report_option;
   }
 
@@ -331,10 +331,10 @@ sub search {
     if (@report_option_any) {
       # this will result in the empty set for the dangling comma case as it should
       push @where, ' ( '. join(' OR ',
-        map{ "0 < ( SELECT count(*) FROM part_pkg_option
-                      WHERE part_pkg_option.pkgpart = part_pkg.pkgpart
-                      AND optionname = 'report_option_$_'
-                      AND optionvalue = '1' )"
+        map{ "EXISTS ( SELECT 1 FROM part_pkg_option
+                         WHERE part_pkg_option.pkgpart = part_pkg.pkgpart
+                         AND optionname = 'report_option_$_'
+                         AND optionvalue = '1' )"
            } @report_option_any
       ). ' ) ';
     }

commit 2d7110ecd22194c00aa81c798f9ca9056d9189dd
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 20 11:57:38 2014 -0800

    optimize

diff --git a/FS/FS/Misc/prune.pm b/FS/FS/Misc/prune.pm
index 3f0c79d..ce72405 100644
--- a/FS/FS/Misc/prune.pm
+++ b/FS/FS/Misc/prune.pm
@@ -44,34 +44,34 @@ sub prune_applications {
 
   my $ccr = <<EOW;
     WHERE
-         0 = (select count(*) from cust_credit
+         NOT EXISTS (select 1 from cust_credit
                where cust_credit_refund.crednum = cust_credit.crednum)
       or 
-         0 = (select count(*) from cust_refund
+         NOT EXISTS (select 1 from cust_refund
                where cust_credit_refund.refundnum = cust_refund.refundnum)
 EOW
   my $ccb = <<EOW;
     WHERE
-         0 = (select count(*) from cust_credit
+         NOT EXISTS (select 1 from cust_credit
                where cust_credit_bill.crednum = cust_credit.crednum)
       or 
-         0 = (select count(*) from cust_bill
+         NOT EXISTS (select 1 from cust_bill
                where cust_credit_bill.invnum = cust_bill.invnum)
 EOW
   my $cbp = <<EOW;
     WHERE
-         0 = (select count(*) from cust_bill
+         NOT EXISTS (select 1 from cust_bill
                where cust_bill_pay.invnum = cust_bill.invnum)
       or 
-         0 = (select count(*) from cust_pay
+         NOT EXISTS (select 1 from cust_pay
                where cust_bill_pay.paynum = cust_pay.paynum)
 EOW
   my $cpr = <<EOW;
     WHERE
-         0 = (select count(*) from cust_pay
+         NOT EXISTS (select 1 from cust_pay
                where cust_pay_refund.paynum = cust_pay.paynum)
       or 
-         0 = (select count(*) from cust_refund
+         NOT EXISTS (select 1 from cust_refund
                where cust_pay_refund.refundnum = cust_refund.refundnum)
 EOW
 

commit 5228e2f266bce7e42ad24179da3cddb563c687a0
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 20 11:55:36 2014 -0800

    optimize

diff --git a/FS/FS/Cron/notify.pm b/FS/FS/Cron/notify.pm
index 1859fca..6d70654 100644
--- a/FS/FS/Cron/notify.pm
+++ b/FS/FS/Cron/notify.pm
@@ -28,52 +28,52 @@ sub notify_flat_delay {
 
   # select * from cust_pkg where
   my $where_pkg = <<"END";
-    where ( cancel is null or cancel = 0 )
-      and ( bill > 0 )
-      and
-      0 < ( select count(*) from part_pkg
-              where cust_pkg.pkgpart = part_pkg.pkgpart
-                and part_pkg.plan = 'flat_delayed'
-                and 0 < ( select count(*) from part_pkg_option
-                            where part_pkg.pkgpart = part_pkg_option.pkgpart
-                              and part_pkg_option.optionname = 'recur_notify'
-                              and CAST( part_pkg_option.optionvalue AS $integer ) > 0
-                              and 0 <= ( $time
-                                         + CAST( part_pkg_option.optionvalue AS $integer )
-                                           * 86400
-                                         - cust_pkg.bill
-                                       )
-                              and ( cust_pkg.expire is null
-                                or  cust_pkg.expire > ( $time
-                                                        + CAST( part_pkg_option.optionvalue AS $integer )
-                                                          * 86400
-                                                      )
+    WHERE ( cancel IS NULL OR cancel = 0 )
+      AND ( bill > 0 )
+      AND EXISTS (
+        SELECT 1 FROM part_pkg
+          WHERE cust_pkg.pkgpart = part_pkg.pkgpart
+            AND part_pkg.plan = 'flat_delayed'
+            AND EXISTS ( SELECT 1 from part_pkg_option
+                           WHERE part_pkg.pkgpart = part_pkg_option.pkgpart
+                             AND part_pkg_option.optionname = 'recur_notify'
+                             AND CAST( part_pkg_option.optionvalue AS $integer ) > 0
+                             AND 0 <= ( $time
+                                        + CAST( part_pkg_option.optionvalue AS $integer )
+                                          * 86400
+                                        - cust_pkg.bill
+                                      )
+                             AND (    cust_pkg.expire is null
+                                   OR cust_pkg.expire > ( $time
+                                                          + CAST( part_pkg_option.optionvalue AS $integer )
+                                                            * 86400
+                                                        )
 END
 
-#/*                            and ( cust_pkg.adjourn is null
-#                                or  cust_pkg.adjourn > $time
+#/*                           and (     cust_pkg.adjourn is null
+#                                    or cust_pkg.adjourn > $time
 #-- Should notify suspended ones  + cast(part_pkg_option.optionvalue as $integer)
-#                                    * 86400
+#                                          * 86400
 #*/
 
   $where_pkg .= <<"END";
-                                  )
-                        )
-          )
-      and
-      0 = ( select count(*) from cust_pkg_option
-              where cust_pkg.pkgnum = cust_pkg_option.pkgnum
-                and cust_pkg_option.optionname = 'impending_recur_notification_sent'
-                and CAST( cust_pkg_option.optionvalue AS $integer ) = 1
-          )
+                                 )
+                       )
+      )
+      AND NOT EXISTS (
+        SELECT 1 from cust_pkg_option
+          WHERE cust_pkg.pkgnum = cust_pkg_option.pkgnum
+            AND cust_pkg_option.optionname = 'impending_recur_notification_sent'
+            AND CAST( cust_pkg_option.optionvalue AS $integer ) = 1
+      )
 END
   
   if ($opt{a}) {
     $where_pkg .= <<END;
-      and 0 < ( select count(*) from cust_main
-                  where cust_pkg.custnum = cust_main.custnum
-                    and cust_main.agentnum IN ( $opt{a} )
-              )
+      AND EXISTS ( SELECT 1 from cust_main
+                     WHERE cust_pkg.custnum = cust_main.custnum
+                       AND cust_main.agentnum IN ( $opt{a} )
+                 )
 END
   }
   

commit d4b8e45c3589f3c6489442798f5fba439d5a29c9
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 20 11:48:06 2014 -0800

    optimize

diff --git a/FS/FS/cust_main/Billing_Discount.pm b/FS/FS/cust_main/Billing_Discount.pm
index 9dda389..d437740 100644
--- a/FS/FS/cust_main/Billing_Discount.pm
+++ b/FS/FS/cust_main/Billing_Discount.pm
@@ -42,11 +42,13 @@ sub _discount_pkgs_and_bill {
   push @where, "part_pkg.freq = '1'";
   push @where, "(cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0)";
   push @where, "(cust_pkg.susp   IS NULL OR cust_pkg.susp   = 0)";
-  push @where, "0<(SELECT count(*) FROM part_pkg_discount
-                  WHERE part_pkg.pkgpart = part_pkg_discount.pkgpart)";
+  push @where, "EXISTS( SELECT 1 FROM part_pkg_discount
+                          WHERE part_pkg.pkgpart = part_pkg_discount.pkgpart )";
   push @where,
-    "0=(SELECT count(*) FROM cust_bill_pkg_discount
-         WHERE cust_bill_pkg.billpkgnum = cust_bill_pkg_discount.billpkgnum)";
+    "NOT EXISTS (
+       SELECT 1 FROM cust_bill_pkg_discount
+         WHERE cust_bill_pkg.billpkgnum = cust_bill_pkg_discount.billpkgnu:
+    )";
 
   my $extra_sql = 'WHERE '. join(' AND ', @where);
 

commit a582fcff5237e93aa3d61fc639c4c766e877ccac
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 20 11:44:58 2014 -0800

    optimize

diff --git a/FS/FS/TicketSystem/RT_External.pm b/FS/FS/TicketSystem/RT_External.pm
index c2aac2d..9f07732 100644
--- a/FS/FS/TicketSystem/RT_External.pm
+++ b/FS/FS/TicketSystem/RT_External.pm
@@ -175,12 +175,11 @@ sub _from_customer {
 
     } else {
 
-      $where =
-               "AND 0 = ( SELECT COUNT(*) FROM ObjectCustomFieldValues
-                           WHERE ObjectId    = Tickets.id
-                             AND ObjectType  = 'RT::Ticket'
-                             AND $customfield_sql
-                        )
+      $where = " AND NOT EXISTS ( SELECT 1 FROM ObjectCustomFieldValues
+                                    WHERE ObjectId    = Tickets.id
+                                      AND ObjectType  = 'RT::Ticket'
+                                      AND $customfield_sql
+                                )
                ";
     }
 

commit 7e78fde169d6e1b25c7e82a9bbcc399d87a2fa02
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 20 11:42:22 2014 -0800

    optimize once_percust condition

diff --git a/FS/FS/part_event/Condition/once_percust.pm b/FS/FS/part_event/Condition/once_percust.pm
index 67767f9..2773ca0 100644
--- a/FS/FS/part_event/Condition/once_percust.pm
+++ b/FS/FS/part_event/Condition/once_percust.pm
@@ -52,13 +52,13 @@ sub condition_sql {
 
   my $pkey = $pkey{$table};
 
-  "0 = ( SELECT COUNT(*) FROM cust_event
-           WHERE cust_event.eventpart = part_event.eventpart
-             AND cust_event.tablenum IN (
-               SELECT $pkey FROM $table AS once_percust
-                 WHERE once_percust.custnum = cust_main.custnum )
-             AND status != 'failed'
-       )
+  "NOT EXISTS ( SELECT 1 FROM cust_event
+                  WHERE cust_event.eventpart = part_event.eventpart
+                    AND cust_event.tablenum IN (
+                      SELECT $pkey FROM $table AS once_percust
+                        WHERE once_percust.custnum = cust_main.custnum )
+                    AND status != 'failed'
+              )
   ";
 
 }

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

Summary of changes:
 FS/FS/Cron/notify.pm                       |   72 ++++++++++++++--------------
 FS/FS/Misc/prune.pm                        |   16 +++----
 FS/FS/Template_Mixin.pm                    |    6 +--
 FS/FS/TicketSystem/RT_External.pm          |   11 ++---
 FS/FS/cust_main/Billing_Discount.pm        |   10 ++--
 FS/FS/cust_pkg/Search.pm                   |   16 +++----
 FS/FS/part_event/Condition/once_percust.pm |   14 +++---
 FS/FS/tax_rate.pm                          |   13 +++--
 httemplate/elements/menu.html              |   24 +++++++---
 httemplate/misc/cancel_cust.html           |    6 +--
 httemplate/misc/suspend_cust.html          |    6 +--
 11 files changed, 103 insertions(+), 91 deletions(-)




More information about the freeside-commits mailing list