[freeside-commits] branch FREESIDE_2_3_BRANCH updated. abb6c318d73b1ae269bfe650c377d4816f84e066

Ivan ivan at 420.am
Sat Nov 3 12:25:24 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  abb6c318d73b1ae269bfe650c377d4816f84e066 (commit)
      from  60d0a2fdcf8ffbb295e6f56cbde093635b36b8dd (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 abb6c318d73b1ae269bfe650c377d4816f84e066
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Nov 3 12:25:23 2012 -0700

    adding pkg_reason_type and pkg_not_reason_type conditions, RT#20084

diff --git a/FS/FS/part_event/Condition/pkg_not_reason_type.pm b/FS/FS/part_event/Condition/pkg_not_reason_type.pm
new file mode 100644
index 0000000..3fa08b7
--- /dev/null
+++ b/FS/FS/part_event/Condition/pkg_not_reason_type.pm
@@ -0,0 +1,58 @@
+package FS::part_event::Condition::pkg_not_reason_type;
+use base qw( FS::part_event::Condition );
+
+use strict;
+use Tie::IxHash;
+#use FS::Record qw( qsearch );
+
+sub description {
+  'Package Not Reason Type';
+}
+
+sub eventtable_hashref {
+    { 'cust_main' => 0,
+      'cust_bill' => 0,
+      'cust_pkg'  => 1,
+      'svc_acct'  => 1,
+    };
+}
+
+tie my %actions, 'Tie::IxHash',
+  #'adjourn' =>
+  'susp'   => 'Suspension',
+  #'expire' =>
+  'cancel' => 'Cancellation'
+;
+
+sub option_fields {
+  (
+    'action'  => { 'label'    => 'Package Action',
+                   'type'     => 'select',
+                   'options'  => [ keys %actions ],
+                   'labels'   => \%actions,
+                 },
+    'typenum' => { 'label'    => 'Not Reason Type',
+                   'type'     => 'select-reason_type',
+                   'multiple' => 1,
+                 },
+  );
+}
+
+sub condition {
+  my( $self, $object ) = @_;
+
+  my $cust_pkg = $self->cust_pkg($object);
+
+  my $reason = $cust_pkg->last_reason( $self->option('action') )
+    or return 0;
+
+  my $hashref = $self->option('typenum') || {};
+  ! $hashref->{ $reason->reason_type };
+}
+
+#sub condition_sql {
+#  my( $self, $table ) = @_;
+#
+#}
+
+1;
diff --git a/FS/FS/part_event/Condition/pkg_reason_type.pm b/FS/FS/part_event/Condition/pkg_reason_type.pm
new file mode 100644
index 0000000..f110e1b
--- /dev/null
+++ b/FS/FS/part_event/Condition/pkg_reason_type.pm
@@ -0,0 +1,58 @@
+package FS::part_event::Condition::pkg_reason_type;
+use base qw( FS::part_event::Condition );
+
+use strict;
+use Tie::IxHash;
+#use FS::Record qw( qsearch );
+
+sub description {
+  'Package Reason Type';
+}
+
+sub eventtable_hashref {
+    { 'cust_main' => 0,
+      'cust_bill' => 0,
+      'cust_pkg'  => 1,
+      'svc_acct'  => 1,
+    };
+}
+
+tie my %actions, 'Tie::IxHash',
+  #'adjourn' =>
+  'susp'   => 'Suspension',
+  #'expire' =>
+  'cancel' => 'Cancellation'
+;
+
+sub option_fields {
+  (
+    'action'  => { 'label'    => 'Package Action',
+                   'type'     => 'select',
+                   'options'  => [ keys %actions ],
+                   'labels'   => \%actions,
+                 },
+    'typenum' => { 'label'    => 'Reason Type',
+                   'type'     => 'select-reason_type',
+                   'multiple' => 1,
+                 },
+  );
+}
+
+sub condition {
+  my( $self, $object ) = @_;
+
+  my $cust_pkg = $self->cust_pkg($object);
+
+  my $reason = $cust_pkg->last_reason( $self->option('action') )
+    or return 0;
+
+  my $hashref = $self->option('typenum') || {};
+  $hashref->{ $reason->reason_type };
+}
+
+#sub condition_sql {
+#  my( $self, $table ) = @_;
+#
+#}
+
+1;
diff --git a/httemplate/elements/select-reason_type.html b/httemplate/elements/select-reason_type.html
new file mode 100644
index 0000000..9031e58
--- /dev/null
+++ b/httemplate/elements/select-reason_type.html
@@ -0,0 +1,21 @@
+<% include( '/elements/select-table.html',
+                 'table'       => 'reason_type',
+                 'name_col'    => 'type',
+                 'value'       => $typenum,
+                 #XXX? 'empty_label' => '(none)',
+                 #XXX? 'hashref'     => { 'disabled' => '' },
+                 %opt,
+             )
+%>
+<%init>
+
+my %opt = @_;
+my $typenum = $opt{'curr_value'} || $opt{'value'};
+
+#my %hash = ();
+#$hash{'disabled'} = '' unless $opt{'showdisabled'};
+
+#$opt{'records'} = delete $opt{'reason_type'}
+#  if $opt{'reason_type'};
+
+</%init>
diff --git a/httemplate/elements/tr-select-reason_type.html b/httemplate/elements/tr-select-reason_type.html
new file mode 100644
index 0000000..9ac473c
--- /dev/null
+++ b/httemplate/elements/tr-select-reason_type.html
@@ -0,0 +1,29 @@
+% if ( scalar(@{ $opt{'reason_type'} }) == 0 ) { 
+
+  <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'typenum' %>" VALUE="">
+
+% } else { 
+
+   <& /elements/tr-td-label.html, label => $opt{'label'} || 'Reason type', %opt &>
+
+    <TD COLSPAN="<% $colspan %>">
+      <% include( '/elements/select-reason_type.html',
+                    'curr_value' => $typenum,
+                    %opt
+                )
+      %>
+    </TD>
+  </TR>
+
+% } 
+
+<%init>
+
+my %opt = @_;
+my $typenum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'reason_type'} ||= [ qsearch( 'reason_type', { disabled=>'' } ) ];
+
+my $colspan = delete($opt{'colspan'}) || 1;
+
+</%init>

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

Summary of changes:
 FS/FS/part_event/Condition/pkg_not_reason_type.pm |   58 +++++++++++++++++++++
 FS/FS/part_event/Condition/pkg_reason_type.pm     |   58 +++++++++++++++++++++
 httemplate/elements/select-reason_type.html       |   21 ++++++++
 httemplate/elements/tr-select-reason_type.html    |   29 ++++++++++
 4 files changed, 166 insertions(+), 0 deletions(-)
 create mode 100644 FS/FS/part_event/Condition/pkg_not_reason_type.pm
 create mode 100644 FS/FS/part_event/Condition/pkg_reason_type.pm
 create mode 100644 httemplate/elements/select-reason_type.html
 create mode 100644 httemplate/elements/tr-select-reason_type.html




More information about the freeside-commits mailing list