Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Mon, 6 Jun 2016 17:21:09 +0000 (10:21 -0700)
committerIvan Kohler <ivan@freeside.biz>
Mon, 6 Jun 2016 17:21:09 +0000 (10:21 -0700)
FS/FS/cust_payby.pm
FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm [new file with mode: 0644]
FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm [new file with mode: 0644]
httemplate/elements/cust_payby.html
httemplate/search/cust_bill_pay_pkg.html
httemplate/search/cust_pay.html
httemplate/search/elements/cust_pay_or_refund.html

index 623a44e..62fa9be 100644 (file)
@@ -715,6 +715,9 @@ sub cgi_hash_callback {
     'CARD' => 'DCRD',
     'CHEK' => 'DCHK',
   );
+  # the payby selector gives the choice of CARD or CHEK (or others, but
+  # those are the ones with auto and on-demand versions). if the user didn't
+  # choose a weight, then they mean DCRD/DCHK.
   $hashref->{payby} = $noauto{$hashref->{payby}}
     if ! $hashref->{weight} && exists $noauto{$hashref->{payby}};
 
diff --git a/FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm b/FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm
new file mode 100644 (file)
index 0000000..353e646
--- /dev/null
@@ -0,0 +1,44 @@
+package FS::part_event::Condition::hasnt_pkg_class_cancelled;
+use base qw( FS::part_event::Condition );
+
+use strict;
+
+sub description {
+  'Customer does not have canceled package with class';
+}
+
+sub eventtable_hashref {
+    { 'cust_main' => 1,
+      'cust_bill' => 1,
+      'cust_pkg'  => 1,
+    };
+}
+
+#something like this
+sub option_fields {
+  (
+    'pkgclass'  => { 'label'    => 'Package Class',
+                     'type'     => 'select-pkg_class',
+                     'multiple' => 1,
+                   },
+    'age'       => { 'label'      => 'Cancellation in last',
+                     'type'       => 'freq',
+                   },
+  );
+}
+
+sub condition {
+  my( $self, $object, %opt ) = @_;
+
+  my $cust_main = $self->cust_main($object);
+
+  my $age = $self->option_age_from('age', $opt{'time'} );
+
+  #XXX test
+  my $hashref = $self->option('pkgclass') || {};
+  ! grep { $hashref->{ $_->part_pkg->classnum } && $_->get('cancel') > $age }
+    $cust_main->cancelled_pkgs;
+}
+
+1;
+
diff --git a/FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm b/FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm
new file mode 100644 (file)
index 0000000..b4ff6c3
--- /dev/null
@@ -0,0 +1,46 @@
+package FS::part_event::Condition::hasnt_pkgpart_cancelled;
+use base qw( FS::part_event::Condition );
+
+use strict;
+
+sub description { 'Customer does not have canceled specific package(s)'; }
+
+sub eventtable_hashref {
+    { 'cust_main' => 1,
+      'cust_bill' => 1,
+      'cust_pkg'  => 1,
+    };
+}
+
+sub option_fields {
+  ( 
+    'if_pkgpart' => { 'label'    => 'Packages: ',
+                      'type'     => 'select-part_pkg',
+                      'multiple' => 1,
+                    },
+    'age'        => { 'label'      => 'Cancellation in last',
+                      'type'       => 'freq',
+                    },
+  );
+}
+
+sub condition {
+  my( $self, $object, %opt ) = @_;
+
+  my $cust_main = $self->cust_main($object);
+
+  my $age = $self->option_age_from('age', $opt{'time'} );
+
+  my $if_pkgpart = $self->option('if_pkgpart') || {};
+  ! grep { $if_pkgpart->{ $_->pkgpart } && $_->get('cancel') > $age }
+    $cust_main->cancelled_pkgs;
+
+}
+
+#XXX 
+#sub condition_sql {
+#
+#}
+
+1;
+
index 60e6eb8..f30d185 100644 (file)
@@ -298,8 +298,17 @@ if ( $curr_value ) {
   $cust_payby = new FS::cust_payby {};
 }
 my $sel_payby = $cgi->param($name.'_payby') || $cust_payby->payby;
-$sel_payby = 'CARD' if $sel_payby eq 'DCRD' || $sel_payby eq '';
-$sel_payby = 'CHEK' if $sel_payby eq 'DCHK';
+# convert DCRD to CARD + no weight, and the same for DCHK/CHEK
+if ($sel_payby eq 'DCRD') {
+  $sel_payby = 'CARD';
+  $cust_payby->weight('');
+} elsif ($sel_payby eq 'DCHK') {
+  $sel_payby = 'CHEK';
+  $cust_payby->weight('');
+} elsif (!$sel_payby) {
+  # default
+  $sel_payby = 'CARD';
+}
 
 my @payby = FS::payby->cust_payby;
 my %conf_payby = map { $_=>1 } $conf->config('payby');
index 5a3be75..7c231a6 100644 (file)
@@ -14,6 +14,7 @@
 
                    #payment
                    'Date',
+                   'Order Number',
                    'By',
 
                    #application
@@ -43,6 +44,7 @@
                            ? cardtype($cust_pay->paymask) : '';
                        },
                    sub { time2str('%b %d %Y', shift->get('cust_pay_date') ) },
+                   sub { shift->cust_bill_pay->cust_pay->order_number },
                    sub { shift->cust_bill_pay->cust_pay->otaker },
 
                    sub { sprintf($money_char.'%.2f', shift->amount ) },
@@ -64,6 +66,7 @@
                    '', #payinfo/paymask
                    '', #cardtype
                    'cust_pay_date',
+                   '', #order_number
                    '', #'otaker',
                    '', #amount
                    '', #line item description
@@ -85,6 +88,7 @@
                    '',
                    '',
                    '',
+                   '',
                    @post_desc_null,
                    $ilink,
                    $ilink,
@@ -92,7 +96,7 @@
                          FS::UI::Web::cust_header()
                    ),
                ],
-               'align' => 'rcrlrlrlll',
+               'align' => 'rcrlrrlrlll',
 #original value before cardtype & package were added
 #why are there 13 cols?
 #'rcrrlrlllrrcl'.
                               '',
                               '',
                               '',
+                              '',
                               @post_desc_null,
                               '',
                               '',
                               '',
                               '',
                               '',
+                              '',
                               @post_desc_null,
                               '',
                               '',
index e466f6a..536ab29 100755 (executable)
@@ -4,4 +4,5 @@
                 'name_singular' => emt('payment'),
                 'name_verb'     => emt('paid'),
                 'show_card_type' => 1,
+                'show_order_number' => 1,
 &>
index b07f5e9..9f725bb 100755 (executable)
@@ -211,6 +211,14 @@ push @links, '';
 push @fields, sub { time2str('%b %d %Y', shift->_date ) };
 push @sort_fields, '_date';
 
+if ($opt{'show_order_number'}) {
+  push @header, emt('Order Number');
+  $align .= 'r';
+  push @links, '';
+  push @fields, 'order_number';
+  push @sort_fields, 'order_number';
+}
+
 unless ( $opt{'disable_by'} ) {
   push @header, emt('By');
   $align .= 'c';