[freeside-commits] freeside/FS/FS Conf.pm, 1.132, 1.133 cust_main.pm, 1.187, 1.188 svc_Common.pm, 1.25, 1.26 cust_main_Mixin.pm, NONE, 1.1 cust_bill.pm, 1.134, 1.135 cust_bill_event.pm, 1.11, 1.12 cust_credit.pm, 1.22, 1.23 cust_pay.pm, 1.40, 1.41

Ivan,,, ivan at wavetail.420.am
Thu Jul 14 03:52:48 PDT 2005


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv8300/FS/FS

Modified Files:
	Conf.pm cust_main.pm svc_Common.pm cust_bill.pm 
	cust_bill_event.pm cust_credit.pm cust_pay.pm 
Added Files:
	cust_main_Mixin.pm 
Log Message:
move account search (httemplate/search/svc_acct.cgi) to new template, cust-fields configuration value to control which customer fields are shown on reports

Index: cust_pay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pay.pm,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- cust_pay.pm	9 Jun 2005 00:18:35 -0000	1.40
+++ cust_pay.pm	14 Jul 2005 10:52:46 -0000	1.41
@@ -5,15 +5,16 @@
 use Date::Format;
 use Business::CreditCard;
 use Text::Template;
-use FS::Record qw( dbh qsearch qsearchs );
 use FS::Misc qw(send_email);
+use FS::Record qw( dbh qsearch qsearchs );
+use FS::cust_main_Mixin;
 use FS::cust_bill;
 use FS::cust_bill_pay;
 use FS::cust_pay_refund;
 use FS::cust_main;
 use FS::cust_pay_void;
 
- at ISA = qw( FS::Record );
+ at ISA = qw( FS::cust_main_Mixin FS::Record );
 
 $ignore_noapply = 0;
 
@@ -81,6 +82,12 @@
 =cut
 
 sub table { 'cust_pay'; }
+sub cust_linked { $_[0]->cust_main_custnum; } 
+sub cust_unlinked_msg {
+  my $self = shift;
+  "WARNING: can't find cust_main.custnum ". $self->custnum.
+  ' (cust_pay.paynum '. $self->paynum. ')';
+}
 
 =item insert
 

Index: cust_credit.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_credit.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cust_credit.pm	27 Dec 2004 10:19:26 -0000	1.22
+++ cust_credit.pm	14 Jul 2005 10:52:46 -0000	1.23
@@ -4,13 +4,14 @@
 use vars qw( @ISA $conf $unsuspendauto );
 use Date::Format;
 use FS::UID qw( dbh getotaker );
-use FS::Record qw( qsearch qsearchs );
 use FS::Misc qw(send_email);
+use FS::Record qw( qsearch qsearchs );
+use FS::cust_main_Mixin;
 use FS::cust_main;
 use FS::cust_refund;
 use FS::cust_credit_bill;
 
- at ISA = qw( FS::Record );
+ at ISA = qw( FS::cust_main_Mixin FS::Record );
 
 #ask FS::UID to run this stuff for us later
 $FS::UID::callback{'FS::cust_credit'} = sub { 
@@ -75,6 +76,12 @@
 =cut
 
 sub table { 'cust_credit'; }
+sub cust_linked { $_[0]->cust_main_custnum; } 
+sub cust_unlinked_msg {
+  my $self = shift;
+  "WARNING: can't find cust_main.custnum ". $self->custnum.
+  ' (cust_credit.crednum '. $self->crednum. ')';
+}
 
 =item insert
 

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- cust_main.pm	30 Jun 2005 12:44:46 -0000	1.187
+++ cust_main.pm	14 Jul 2005 10:52:46 -0000	1.188
@@ -3160,11 +3160,53 @@
 
 sub name {
   my $self = shift;
-  my $name = $self->get('last'). ', '. $self->first;
+  my $name = $self->bill_contact;
   $name = $self->company. " ($name)" if $self->company;
   $name;
 }
 
+=item ship_name
+
+Returns a name string for this (service/shipping) contact, either
+"Company (Last, First)" or "Last, First".
+
+=cut
+
+sub ship_name {
+  my $self = shift;
+  if ( $self->get('ship_last') ) { 
+    my $name = $self->ship_contact;
+    $name = $self->ship_company. " ($name)" if $self->ship_company;
+    $name;
+  } else {
+    $self->name;
+  }
+}
+
+=item contact
+
+Returns this customer's full (billing) contact name only, "Last, First"
+
+=cut
+
+sub contact {
+  my $self = shift;
+  $self->get('last'). ', '. $self->first;
+}
+
+=item ship_contact
+
+Returns this customer's full (shipping) contact name only, "Last, First"
+
+=cut
+
+sub ship_contact {
+  my $self = shift;
+  $self->get('ship_last')
+    ? $self->get('ship_last'). ', '. $self->ship_first
+    : $self->bill_contact;
+}
+
 =item status
 
 Returns a status string for this customer, currently:

--- NEW FILE: cust_main_Mixin.pm ---
package FS::cust_main_Mixin;

use strict;
use FS::cust_main;

=head1 NAME

FS::cust_main_Mixin - Mixin class for records that contain fields from cust_main

=head1 SYNOPSIS

package FS::some_table;
use vars qw(@ISA);
@ISA = qw( FS::cust_main_Mixin FS::Record );

=head1 DESCRIPTION

This is a mixin class for records that contain fields from the cust_main table,
for example, from a JOINed search.  See httemplate/search/ for examples.

=head1 METHODS

=over 4

=item name

Given an object that contains fields from cust_main (say, from a JOINed
search; see httemplate/search/ for examples), returns the equivalent of the
FS::cust_main I<name> method, or "(unlinked)" if this object is not linked to
a customer.

=cut

sub cust_unlinked_msg { '(unlinked)'; }
sub cust_linked { $_[0]->custnum; }

sub name {
  my $self = shift;
  $self->cust_linked
    ? FS::cust_main::name($self)
    : $self->cust_unlinked_msg;
}

=item ship_name

Given an object that contains fields from cust_main (say, from a JOINed
search; see httemplate/search/ for examples), returns the equivalent of the
FS::cust_main I<ship_name> method, or "(unlinked)" if this object is not
linked to a customer.

=cut

sub ship_name {
  my $self = shift;
  $self->cust_linked
    ? FS::cust_main::ship_name($self)
    : $self->cust_unlinked_msg;
}

=item contact

Given an object that contains fields from cust_main (say, from a JOINed
search; see httemplate/search/ for examples), returns the equivalent of the
FS::cust_main I<contact> method, or "(unlinked)" if this object is not linked
to a customer.

=cut

sub contact {
  my $self = shift;
  $self->cust_linked
    ? FS::cust_main::contact($self)
    : $self->cust_unlinked_msg;
}

=item ship_contact

Given an object that contains fields from cust_main (say, from a JOINed
search; see httemplate/search/ for examples), returns the equivalent of the
FS::cust_main I<ship_contact> method, or "(unlinked)" if this object is not
linked to a customer.

=cut

sub ship_contact {
  my $self = shift;
  $self->cust_linked
    ? FS::cust_main::ship_contact($self)
    : $self->cust_unlinked_msg;
}

=back

=head1 BUGS

=head1 SEE ALSO

L<FS::cust_main>, L<FS::Record>

=cut

1;


Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- Conf.pm	30 Jun 2005 13:20:33 -0000	1.132
+++ Conf.pm	14 Jul 2005 10:52:46 -0000	1.133
@@ -1545,6 +1545,23 @@
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'cust-fields',
+    'section'     => 'UI',
+    'description' => 'Which customer fields to display on reports',
+    'type'        => 'select',
+    'select_enum' => [
+      'Customer: Last, First</b> or</i> Company (Last, First)</b>',
+      'Cust# | Customer: custnum | Last, First or Company (Last, First)',
+      'Name | Company: Last, First | Company',
+      'Cust# | Name | Company: custnum | Last, First | Company',
+      '(bill) Customer | (service) Customer: Last, First or Company (Last, First) | (same for service address if present)',
+      'Cust# | (bill) Customer | (service) Customer:  custnum | Last, First or Company (Last, First) | (same for service address if present)',
+      '(bill) Name | (bill) Company | (service) Name | (service) Company: Last, First | Company | (same for service address if present)',
+      'Cust# | (bill) Name | (bill) Company | (service) Name | (service) Company: custnum | Last, First | Company | (same for service address if present)',
+    ],
+  },
+
 );
 
 1;

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- cust_bill.pm	9 Jul 2005 15:41:18 -0000	1.134
+++ cust_bill.pm	14 Jul 2005 10:52:46 -0000	1.135
@@ -11,8 +11,9 @@
 use HTML::Entities;
 use Locale::Country;
 use FS::UID qw( datasrc );
-use FS::Record qw( qsearch qsearchs );
 use FS::Misc qw( send_email send_fax );
+use FS::Record qw( qsearch qsearchs );
+use FS::cust_main_Mixin;
 use FS::cust_main;
 use FS::cust_bill_pkg;
 use FS::cust_credit;
@@ -25,7 +26,7 @@
 use FS::cust_bill_pay;
 use FS::part_bill_event;
 
- at ISA = qw( FS::Record );
+ at ISA = qw( FS::cust_main_Mixin FS::Record );
 
 $DEBUG = 0;
 
@@ -105,6 +106,13 @@
 
 sub table { 'cust_bill'; }
 
+sub cust_linked { $_[0]->cust_main_custnum; } 
+sub cust_unlinked_msg {
+  my $self = shift;
+  "WARNING: can't find cust_main.custnum ". $self->custnum.
+  ' (cust_bill.invnum '. $self->invnum. ')';
+}
+
 =item insert
 
 Adds this invoice to the database ("Posts" the invoice).  If there is an error,

Index: cust_bill_event.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_event.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cust_bill_event.pm	2 Jun 2005 09:29:52 -0000	1.11
+++ cust_bill_event.pm	14 Jul 2005 10:52:46 -0000	1.12
@@ -3,10 +3,11 @@
 use strict;
 use vars qw( @ISA $DEBUG );
 use FS::Record qw( qsearch qsearchs );
+use FS::cust_main_Mixin;
 use FS::cust_bill;
 use FS::part_bill_event;
 
- at ISA = qw(FS::Record);
+ at ISA = qw(FS::cust_main_Mixin FS::Record);
 
 $DEBUG = 0;
 
@@ -70,6 +71,13 @@
 
 sub table { 'cust_bill_event'; }
 
+sub cust_linked { $_[0]->cust_main_custnum; } 
+sub cust_unlinked_msg {
+  my $self = shift;
+  "WARNING: can't find cust_main.custnum ". $self->custnum.
+  ' (cust_bill.invnum '. $self->invnum. ')';
+}
+
 =item insert
 
 Adds this record to the database.  If there is an error, returns the error,

Index: svc_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_Common.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- svc_Common.pm	2 May 2005 06:32:09 -0000	1.25
+++ svc_Common.pm	14 Jul 2005 10:52:46 -0000	1.26
@@ -3,15 +3,16 @@
 use strict;
 use vars qw( @ISA $noexport_hack $DEBUG );
 use FS::Record qw( qsearch qsearchs fields dbh );
+use FS::cust_main_Mixin;
 use FS::cust_svc;
 use FS::part_svc;
 use FS::queue;
 use FS::cust_main;
 
- at ISA = qw( FS::Record );
+ at ISA = qw( FS::cust_main_Mixin FS::Record );
 
-$DEBUG = 0;
-#$DEBUG = 1;
+#$DEBUG = 0;
+$DEBUG = 1;
 
 =head1 NAME
 
@@ -547,20 +548,6 @@
   shift;
 }
 
-=item cust_name
-
-Given a svc_ object that contains fields from cust_main (say, from a
-JOINed search.  See httemplate/search/svc_* for examples), returns the 
-equivalent of "$svc_x->cust_svc->cust_pkg->name" (but much more efficient),
-or "(unlinked)" if this service is not linked to a customer.
-
-=cut
-
-sub cust_name {
-  my $svc_x = shift;
-  $svc_x->custnum ? FS::cust_main::name($svc_x) : '(unlinked)';
-}
-
 =back
 
 =head1 BUGS



More information about the freeside-commits mailing list