[freeside-commits] branch FREESIDE_3_BRANCH updated. 956f5fc611a223847baf628e596511af1d0e2b0e

Christopher Burger burgerc at freeside.biz
Tue Jun 5 06:58:06 PDT 2018


The branch, FREESIDE_3_BRANCH has been updated
       via  956f5fc611a223847baf628e596511af1d0e2b0e (commit)
       via  bce697fa3f64f1cc7f568fde28a912605cac7eb9 (commit)
      from  690b42d0311236b1c07acb5bdbae32276e20e3b9 (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 956f5fc611a223847baf628e596511af1d0e2b0e
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Jun 5 08:50:17 2018 -0400

    RT# 77917 - fixed upgrade to work when all agents were selected.

diff --git a/FS/FS/part_event_condition_option.pm b/FS/FS/part_event_condition_option.pm
index 15a6a5553..f1d1b6a15 100644
--- a/FS/FS/part_event_condition_option.pm
+++ b/FS/FS/part_event_condition_option.pm
@@ -146,14 +146,23 @@ sub _upgrade_data { #class method
   unless ( FS::upgrade_journal->is_done('agentnum_to_hash') ) {
 
     foreach my $condition_option (qsearch('part_event_condition_option', { optionname => 'agentnum', })) {
+      my %options;
       my $optionvalue = $condition_option->get("optionvalue");
       if ($optionvalue eq 'HASH' ) { next; }
+      elsif ($optionvalue eq '') {
+        foreach my $agent (qsearch('agent', {})) {
+          $options{$agent->agentnum} = '1';
+        }
+
+      }
       else {
-        my $options = {"$optionvalue" => '1',};
-        $condition_option->optionvalue(ref($options));
-        my $error = $condition_option->replace($options);
-        die $error if $error;
+        $options{$optionvalue} = '1';
       }
+
+      $condition_option->optionvalue(ref(\%options));
+      my $error = $condition_option->replace(\%options);
+      die $error if $error;
+
     }
 
     FS::upgrade_journal->set_done('agentnum_to_hash');

commit bce697fa3f64f1cc7f568fde28a912605cac7eb9
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon Jun 4 20:10:15 2018 -0400

    RT# 77917 - Updated event option Agent to allow for selection of multiple agents.
    
    Conflicts:
            FS/FS/Upgrade.pm

diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index e729896b3..f26c6a338 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -454,6 +454,10 @@ sub upgrade_data {
     #mark certain taxes as system-maintained,
     # and fix whitespace
     'cust_main_county' => [],
+
+    #upgrade part_event_condition_option agentnum to a multiple hash value
+    'part_event_condition_option' =>[],
+
   ;
 
   \%hash;
diff --git a/FS/FS/part_event/Condition/agent.pm b/FS/FS/part_event/Condition/agent.pm
index bdd4e12de..917cf468b 100644
--- a/FS/FS/part_event/Condition/agent.pm
+++ b/FS/FS/part_event/Condition/agent.pm
@@ -13,7 +13,7 @@ sub description {
 
 sub option_fields {
   (
-    'agentnum'   => { label=>'Agent', type=>'select-agent', },
+    'agentnum'   => { label=>'Agent', type=>'select-agent', multiple => '1' },
   );
 }
 
@@ -22,16 +22,15 @@ sub condition {
 
   my $cust_main = $self->cust_main($object);
 
-  my $agentnum = $self->option('agentnum');
-
-  $cust_main->agentnum == $agentnum;
+  my $hashref = $self->option('agentnum') || {};
+  grep $hashref->{ $_->agentnum }, $cust_main->agent;
 
 }
 
 sub condition_sql {
   my( $class, $table, %opt ) = @_;
 
-  "cust_main.agentnum = " . $class->condition_sql_option_integer('agentnum', $opt{'driver_name'});
+  "cust_main.agentnum IN " . $class->condition_sql_option_option_integer('agentnum', $opt{'driver_name'});
 }
 
 1;
diff --git a/FS/FS/part_event_condition_option.pm b/FS/FS/part_event_condition_option.pm
index 3256dc0bd..15a6a5553 100644
--- a/FS/FS/part_event_condition_option.pm
+++ b/FS/FS/part_event_condition_option.pm
@@ -138,6 +138,30 @@ sub optionvalue {
   }
 }
 
+use FS::upgrade_journal;
+sub _upgrade_data { #class method
+  my ($class, %opts) = @_;
+
+  # migrate part_event_condition_option agentnum to part_event_condition_option_option agentnum
+  unless ( FS::upgrade_journal->is_done('agentnum_to_hash') ) {
+
+    foreach my $condition_option (qsearch('part_event_condition_option', { optionname => 'agentnum', })) {
+      my $optionvalue = $condition_option->get("optionvalue");
+      if ($optionvalue eq 'HASH' ) { next; }
+      else {
+        my $options = {"$optionvalue" => '1',};
+        $condition_option->optionvalue(ref($options));
+        my $error = $condition_option->replace($options);
+        die $error if $error;
+      }
+    }
+
+    FS::upgrade_journal->set_done('agentnum_to_hash');
+
+  }
+
+}
+
 =back
 
 =head1 SEE ALSO

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

Summary of changes:
 FS/FS/Upgrade.pm                     |  4 ++++
 FS/FS/part_event/Condition/agent.pm  |  9 ++++-----
 FS/FS/part_event_condition_option.pm | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 5 deletions(-)




More information about the freeside-commits mailing list