[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 38bd65e50f8976c2423691fea64e70420ff1ea39

Mark Wells mark at 420.am
Wed Mar 28 17:44:56 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  38bd65e50f8976c2423691fea64e70420ff1ea39 (commit)
      from  614e3b25ba49614b644f2a65910db1522f0cd524 (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 38bd65e50f8976c2423691fea64e70420ff1ea39
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Mar 28 17:14:27 2012 -0700

    customer tag event condition, #15116

diff --git a/FS/FS/part_event/Condition.pm b/FS/FS/part_event/Condition.pm
index ef3d0b5..c759908 100644
--- a/FS/FS/part_event/Condition.pm
+++ b/FS/FS/part_event/Condition.pm
@@ -344,7 +344,7 @@ sub condition_sql_option_option {
 
 }
 
-#used for part_event/Condition/cust_bill_has_service.pm
+#used for part_event/Condition/cust_bill_has_service.pm and has_cust_tag.pm
 #a little false laziness w/above and condition_sql_option_integer
 sub condition_sql_option_option_integer {
   my( $class, $option, $driver_name ) = @_;
diff --git a/FS/FS/part_event/Condition/has_cust_tag.pm b/FS/FS/part_event/Condition/has_cust_tag.pm
new file mode 100644
index 0000000..cde9338
--- /dev/null
+++ b/FS/FS/part_event/Condition/has_cust_tag.pm
@@ -0,0 +1,49 @@
+package FS::part_event::Condition::has_cust_tag;
+
+use strict;
+
+use base qw( FS::part_event::Condition );
+use FS::Record qw( qsearch );
+
+sub description {
+  'Customer has tag',
+}
+
+sub eventtable_hashref {
+    { 'cust_main' => 1,
+      'cust_bill' => 1,
+      'cust_pkg'  => 1,
+    };
+}
+
+#something like this
+sub option_fields {
+  (
+    'tagnum'  => { 'label'    => 'Customer tag',
+                   'type'     => 'select-cust_tag',
+                   'multiple' => 1,
+                 },
+  );
+}
+
+sub condition {
+  my( $self, $object ) = @_;
+
+  my $cust_main = $self->cust_main($object);
+
+  my $hashref = $self->option('tagnum') || {};
+  grep $hashref->{ $_->tagnum }, $cust_main->cust_tag;
+}
+
+sub condition_sql {
+  my( $self, $table ) = @_;
+
+  my $matching_tags = 
+    "SELECT tagnum FROM cust_tag WHERE cust_tag.custnum = $table.custnum".
+    " AND cust_tag.tagnum IN ".
+    $self->condition_sql_option_option_integer('tagnum');
+
+  "EXISTS($matching_tags)";
+}
+
+1;
diff --git a/httemplate/elements/tr-select-cust_tag.html b/httemplate/elements/tr-select-cust_tag.html
index b2b6d96..5312644 100644
--- a/httemplate/elements/tr-select-cust_tag.html
+++ b/httemplate/elements/tr-select-cust_tag.html
@@ -28,7 +28,7 @@ my $cgi = $opt{'cgi'};
 my $is_report = $opt{'is_report'};
 
 my @curr_tagnum = ();
-if ( $cgi->param('error') ) {
+if ( $cgi && $cgi->param('error') ) {
   @curr_tagnum = $cgi->param('tagnum');
 } elsif ( $opt{'custnum'} ) {
   @curr_tagnum = map $_->tagnum,

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

Summary of changes:
 FS/FS/part_event/Condition.pm               |    2 +-
 FS/FS/part_event/Condition/has_cust_tag.pm  |   49 +++++++++++++++++++++++++++
 httemplate/elements/tr-select-cust_tag.html |    2 +-
 3 files changed, 51 insertions(+), 2 deletions(-)
 create mode 100644 FS/FS/part_event/Condition/has_cust_tag.pm




More information about the freeside-commits mailing list