tie my %tables, 'Tie::IxHash',
'cust_main' => 'Customer',
'cust_main_invoice' => 'Invoice destination',
+ 'cust_main_note' => 'Note',
'cust_pkg' => 'Package',
#? or just svc_* ? 'cust_svc' =>
'svc_acct' => 'Account',
'phone_device' => 'Phone device',
'cust_pkg_discount' => 'Discount',
#? it gets provisioned anyway 'phone_avail' => 'Phone',
+ 'cust_tag' => 'Tag',
+ 'contact' => 'Contact',
;
my $pkg_join = "JOIN cust_pkg USING ( pkgnum )";
'radius_usergroup' => $svc_join,
'phone_device' => $svc_join,
'cust_pkg_discount'=> $pkg_join,
+ 'contact' => "JOIN cust_contact USING ( contactnum )",
);
%table_join = (%table_join, map { $_ => $svc_join } @svc_tables);
local($FS::Record::nowarn_classload) = 1;
+my $extra_sql = ' AND custnum = '. $cust_main->custnum;
+
my %foundsvcs;
foreach my $table ( keys %tables ) {
+ $extra_sql = ' AND cust_contact.custnum = '. $cust_main->custnum if $table eq 'contact';
my @items = qsearch({
'table' => "h_$table",
'addl_from' => $table_join{$table},
'hashref' => { 'history_date' => { op=>'>=', value=>$newer_than }, },
- 'extra_sql' => ' AND custnum = '. $cust_main->custnum,
+ 'extra_sql' => $extra_sql,
});
%foundsvcs = (%foundsvcs, map { $_->svcnum => 1 } @items)
if $table =~ /^svc/;
# but it would spoil database optimizations on this lookup
my @svcnumobj = qsearch({
'select' => 'DISTINCT svcnum',
- 'hashref' => { 'custnum' => $cust_main->custnum,
- 'history_date' => { op=>'>=', value=>$newer_than } },
+ 'hashref' => { 'history_date' => { op=>'>=', value=>$newer_than } },
'table' => 'h_cust_svc',
'addl_from' => 'JOIN cust_pkg USING (pkgnum)',
+ 'extra_sql' => ' AND custnum = '. $cust_main->custnum,
});
# now grab those svcs explicitly