Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Wed, 1 Feb 2017 02:05:11 +0000 (18:05 -0800)
committerIvan Kohler <ivan@freeside.biz>
Wed, 1 Feb 2017 02:05:11 +0000 (18:05 -0800)
FS/FS/Template_Mixin.pm
FS/FS/part_event/Condition/has_pkgpart.pm
FS/FS/part_event/Condition/pkg_pkgpart.pm

index d7add71..5e85f8e 100644 (file)
@@ -3338,19 +3338,24 @@ sub _items_cust_bill_pkg {
             && ! $cust_bill_pkg->recur_show_zero;
 
           my @d = ();
-          my $svc_label;
-
-          # always pass the svc_label through to the template, even if 
-          # not displaying it as an ext_description
-          my @svc_labels = map &{$escape_function}($_),
-            $cust_pkg->h_labels_short($self->_date,
-                                      undef,
-                                      'I',
-                                      $self->conf->{locale},
-                                     );
-          $svc_label = $svc_labels[0];
-
-          unless ( $cust_pkg->part_pkg->hide_svc_detail
+          my @svc_labels = ();
+          my $svc_label = '';
+
+          unless ( $part_pkg->hide_svc_detail ) {
+
+            # still pass the svc_label through to the template, even if 
+            # not displaying it as an ext_description
+            @svc_labels = map &{$escape_function}($_),
+              $cust_pkg->h_labels_short($self->_date,
+                                        undef,
+                                        'I',
+                                        $self->conf->{locale},
+                                       );
+            $svc_label = $svc_labels[0];
+
+          }
+
+          unless ( $part_pkg->hide_svc_detail
                 || $cust_bill_pkg->hidden )
           {
 
@@ -3427,6 +3432,7 @@ sub _items_cust_bill_pkg {
 
           my @d = ();
           my @seconds = (); # for display of usage info
+          my @svc_labels = ();
           my $svc_label = '';
 
           #at least until cust_bill_pkg has "past" ranges in addition to
@@ -3436,11 +3442,13 @@ sub _items_cust_bill_pkg {
           push @dates, $prev->sdate if $prev;
           push @dates, undef if !$prev;
 
-          my @svc_labels = map &{$escape_function}($_),
-            $cust_pkg->h_labels_short(@dates,
-                                      'I',
-                                      $self->conf->{locale});
-          $svc_label = $svc_labels[0];
+          unless ( $part_pkg->hide_svc_detail ) {
+            @svc_labels = map &{$escape_function}($_),
+              $cust_pkg->h_labels_short(@dates,
+                                        'I',
+                                        $self->conf->{locale});
+            $svc_label = $svc_labels[0];
+          }
 
           # show service labels, unless...
                     # the package is set not to display them
index 5505a99..deeb1b7 100644 (file)
@@ -27,13 +27,23 @@ sub condition {
   my $cust_main = $self->cust_main($object);
 
   my $if_pkgpart = $self->option('if_pkgpart') || {};
-  grep $if_pkgpart->{ $_->pkgpart }, $cust_main->ncancelled_pkgs;
+  grep $if_pkgpart->{ $_->pkgpart },
+         $cust_main->ncancelled_pkgs( 'skip_label_sort'=>1 );
 
 }
 
-#XXX 
-#sub condition_sql {
-#
-#}
+sub condition_sql {
+  my( $self, $table ) = @_;
+
+  'ARRAY'. $self->condition_sql_option_option_integer('if_pkgpart').
+  ' && '. #overlap (have elements in common)
+  'ARRAY( SELECT pkgpart FROM cust_pkg AS has_pkgpart_cust_pkg
+            WHERE has_pkgpart_cust_pkg.custnum = cust_main.custnum
+              AND (    has_pkgpart_cust_pkg.cancel IS NULL
+                    OR has_pkgpart_cust_pkg.cancel = 0
+                  )
+        )
+  ';
+}
 
 1;
index 6adef8e..d5b5c8d 100644 (file)
@@ -25,15 +25,16 @@ sub option_fields {
 sub condition {
   my( $self, $cust_pkg) = @_;
 
-  #XXX test
   my $if_pkgpart = $self->option('if_pkgpart') || {};
   $if_pkgpart->{ $cust_pkg->pkgpart };
 
 }
 
-#XXX 
-#sub condition_sql {
-#
-#}
+sub condition_sql {
+  my( $self, $table ) = @_;
+  
+  'cust_pkg.pkgpart IN '.
+    $self->condition_sql_option_option_integer('if_pkgpart');
+}
 
 1;