[freeside-commits] freeside/httemplate/search svc_acct.cgi, 1.32,
1.33 svc_forward.cgi, 1.5, 1.6 svc_domain.cgi, 1.16,
1.17 cust_bill_event.cgi, 1.6, 1.7 cust_credit.html, 1.6,
1.7 cust_pay.cgi, 1.17, 1.18 svc_www.cgi, 1.4,
1.5 report_receivables.cgi, 1.20, 1.21
Ivan,,,
ivan at wavetail.420.am
Thu Jul 14 03:52:48 PDT 2005
- Previous message: [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
- Next message: [freeside-commits] freeside/httemplate/search/elements search.html,
1.15, 1.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail:/tmp/cvs-serv8300/httemplate/search
Modified Files:
svc_acct.cgi svc_forward.cgi svc_domain.cgi
cust_bill_event.cgi cust_credit.html cust_pay.cgi svc_www.cgi
report_receivables.cgi
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: svc_domain.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_domain.cgi,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- svc_domain.cgi 5 May 2005 01:46:30 -0000 1.16
+++ svc_domain.cgi 14 Jul 2005 10:52:46 -0000 1.17
@@ -37,7 +37,6 @@
join(' AND ', map "$_ = ". dbh->quote($svc_domain{$_}),
keys %svc_domain
);
-
}
my $sql_query = {
@@ -45,12 +44,13 @@
'hashref' => \%svc_domain,
'select' => join(', ',
'svc_domain.*',
- map "cust_main.$_", qw(custnum last first company)
+ 'cust_main.custnum',
+ FS::UI::Web::cust_sql_fields(),
),
'extra_sql' => "$extra_sql $orderby",
- 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'.
- 'LEFT JOIN cust_pkg USING ( pkgnum )'.
- 'LEFT JOIN cust_main USING ( custnum )',
+ 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum ) '.
+ 'LEFT JOIN cust_pkg USING ( pkgnum ) '.
+ 'LEFT JOIN cust_main USING ( custnum ) ',
};
my $link = [ "${p}view/svc_domain.cgi?", 'svcnum' ];
@@ -69,15 +69,17 @@
'redirect' => $link,
'header' => [ '#',
'Domain',
- 'Customer',
+ FS::UI::Web::cust_header(),
],
'fields' => [ 'svcnum',
'domain',
- \&FS::svc_Common::cust_name,
+ \&FS::UI::Web::cust_fields,
],
'links' => [ $link,
$link,
- $link_cust,
+ ( map { $link_cust }
+ FS::UI::Web::cust_header()
+ ),
],
)
%>
Index: svc_www.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_www.cgi,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- svc_www.cgi 2 May 2005 06:32:10 -0000 1.4
+++ svc_www.cgi 14 Jul 2005 10:52:46 -0000 1.5
@@ -17,7 +17,8 @@
'hashref' => {},
'select' => join(', ',
'svc_www.*',
- map "cust_main.$_", qw(custnum last first company)
+ 'cust_main.custnum',
+ FS::UI::Web::cust_sql_fields(),
),
'extra_sql' => $orderby,
'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'.
@@ -44,17 +45,25 @@
'header' => [ '#',
'Zone',
'User',
- 'Customer',
+ FS::UI::Web::cust_header(),
],
'fields' => [ 'svcnum',
sub { $_[0]->domain_record->zone },
- sub { $_[0]->svc_acct->email },
- \&FS::svc_Common::cust_name,
+ sub {
+ my $svc_www = shift;
+ my $svc_acct = $svc_www->svc_acct;
+ $svc_acct
+ ? $svc_acct->email
+ : '';
+ },
+ \&FS::UI::Web::cust_fields,
],
'links' => [ $link,
'',
$ulink,
- $link_cust,
+ ( map { $link_cust }
+ FS::UI::Web::cust_header()
+ ),
],
)
%>
Index: cust_pay.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_pay.cgi,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cust_pay.cgi 30 Mar 2005 01:18:47 -0000 1.17
+++ cust_pay.cgi 14 Jul 2005 10:52:46 -0000 1.18
@@ -73,7 +73,11 @@
$sql_query = {
'table' => 'cust_pay',
- 'select' => 'cust_pay.*, cust_main.last, cust_main.first, cust_main.company',
+ 'select' => join(', ',
+ 'cust_pay.*',
+ 'cust_main.custnum as cust_main_custnum',
+ FS::UI::Web::cust_sql_fields(),
+ ),
'hashref' => {},
'extra_sql' => "$search ORDER BY _date",
'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
@@ -99,7 +103,12 @@
}
- my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
+ my $link = sub {
+ my $cust_pay = shift;
+ $cust_pay->cust_main_custnum
+ ? [ "${p}view/cust_main.cgi?", 'custnum' ]
+ : '';
+ };
%><%= include( 'elements/search.html',
'title' => $title,
@@ -107,9 +116,11 @@
'query' => $sql_query,
'count_query' => $count_query,
'count_addl' => [ '$%.2f total paid', ],
- 'header' =>
- [ qw(Payment Amount Date), 'Cust #', 'Contact name',
- 'Company', ],
+ 'header' => [ 'Payment',
+ 'Amount',
+ 'Date',
+ FS::UI::Web::cust_header(),
+ ],
'fields' => [
sub {
my $cust_pay = shift;
@@ -119,24 +130,23 @@
'E-check acct#'. $cust_pay->payinfo;
} elsif ( $cust_pay->payby eq 'BILL' ) {
'Check #'. $cust_pay->payinfo;
+ } elsif ( $cust_pay->payby eq 'PREP' ) {
+ 'Prepaid card #'. $cust_pay->payinfo;
} else {
$cust_pay->payby. ' '. $cust_pay->payinfo;
}
},
sub { sprintf('$%.2f', shift->paid ) },
sub { time2str('%b %d %Y', shift->_date ) },
- 'custnum',
- sub { $_[0]->get('last'). ', '. $_[0]->first; },
- 'company',
+ \&FS::UI::Web::cust_fields,
],
- 'align' => 'lrrrll',
+ #'align' => 'lrrrll',
+ 'align' => 'rrr',
'links' => [
'',
'',
'',
- $link,
- $link,
- $link,
+ ( map { $link } FS::UI::Web::cust_header() ),
],
)
%>
Index: cust_bill_event.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_bill_event.cgi,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cust_bill_event.cgi 9 Jun 2005 22:40:09 -0000 1.6
+++ cust_bill_event.cgi 14 Jul 2005 10:52:46 -0000 1.7
@@ -27,8 +27,8 @@
'part_bill_event.event',
'cust_bill.custnum',
'cust_bill._date AS cust_bill_date',
- map "cust_main.$_", qw(last first company)
-
+ 'cust_main.custnum AS cust_main_custnum',
+ FS::UI::Web::cust_sql_fields(),
),
'extra_sql' => "$where ORDER BY _date ASC",
'addl_from' => 'LEFT JOIN part_bill_event USING ( eventpart ) '.
@@ -71,6 +71,13 @@
"javascript:fax_process()"
if $conf->exists('hylafax');
+my $link_cust = sub {
+ my $cust_bill_event = shift;
+ $cust_bill_event->cust_main_custnum
+ ? [ "${p}view/cust_main.cgi?", 'custnum' ]
+ : '';
+};
+
%><%= include( 'elements/search.html',
'title' => $title,
'html_init' => $html_init,
@@ -78,9 +85,12 @@
'name' => 'billing events',
'query' => $sql_query,
'count_query' => $count_sql,
- 'header' => [ qw( Event Date Status ),
+ 'header' => [ 'Event',
+ 'Date',
+ 'Status',
#'Inv #', 'Inv Date', 'Cust #',
- 'Invoice', 'Cust #',
+ 'Invoice',
+ FS::UI::Web::cust_header(),
],
'fields' => [
'event',
@@ -99,9 +109,7 @@
time2str("%D", $_[0]->cust_bill_date).
')';
},
- sub { FS::cust_main::name($_[0]) },
-
-
+ \&FS::UI::Web::cust_fields,
],
'links' => [
'',
@@ -113,8 +121,7 @@
$template .= '-' if $template;
[ "${p}view/cust_bill.cgi?$template", 'invnum'];
},
- [ "${p}view/cust_main.cgi?", 'custnum' ],
- [ "${p}view/cust_main.cgi?", 'custnum' ],
+ ( map { $link_cust } FS::UI::Web::cust_header() ),
],
)
%>
Index: report_receivables.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_receivables.cgi,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- report_receivables.cgi 1 Jun 2005 21:40:59 -0000 1.20
+++ report_receivables.cgi 14 Jul 2005 10:52:46 -0000 1.21
@@ -118,14 +118,16 @@
my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';
+ my $align = join('', map { /#/ ? 'r' : 'l' } FS::UI::Web::cust_header() ).
+ 'crrrrr';
+
%><%= include( 'elements/search.html',
'title' => 'Accounts Receivable Aging Summary',
'name' => 'customers',
'query' => $sql_query,
'count_query' => $count_sql,
'header' => [
- '#',
- 'Customer',
+ FS::UI::Web::cust_header(),
'Status', # (me)',
#'Status', # (cust_main)',
'0-30',
@@ -135,8 +137,12 @@
'Total',
],
'footer' => [
- '',
'Total',
+ ( map '',
+ ( 1 ..
+ scalar(FS::UI::Web::cust_header()-1)
+ )
+ ),
'',
#'',
sprintf( $money_char.'%.2f',
@@ -151,8 +157,7 @@
$row->{'owed_total'} ),
],
'fields' => [
- 'custnum',
- 'name',
+ \&FS::UI::Web::cust_fields,
sub {
my $row = shift;
my $status = 'Cancelled';
@@ -191,14 +196,15 @@
'',
],
#'align' => 'rlccrrrrr',
- 'align' => 'rlcrrrrr',
+ 'align' => $align,
#'size' => [ '', '', '-1', '-1', '', '', '', '', '', ],
#'style' => [ '', '', 'b', 'b', '', '', '', '', 'b', ],
- 'size' => [ '', '', '-1', '', '', '', '', '', ],
- 'style' => [ '', '', 'b', '', '', '', '', 'b', ],
+ 'size' => [ ( map '', FS::UI::Web::cust_header() ),
+ '-1', '', '', '', '', '', ],
+ 'style' => [ ( map '', FS::UI::Web::cust_header() ),
+ 'b', '', '', '', '', 'b', ],
'color' => [
- '',
- '',
+ ( map '', FS::UI::Web::cust_header() ),
sub {
my $row = shift;
my $status = 'Cancelled';
Index: cust_credit.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_credit.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cust_credit.html 6 Mar 2005 03:04:29 -0000 1.6
+++ cust_credit.html 14 Jul 2005 10:52:46 -0000 1.7
@@ -46,13 +46,22 @@
my $sql_query = {
'table' => 'cust_credit',
- 'select' => 'cust_credit.*, cust_main.last, cust_main.first, cust_main.company',
+ 'select' => join(', ',
+ 'cust_credit.*',
+ 'cust_main.custnum as cust_main_custnum',
+ FS::UI::Web::cust_sql_fields(),
+ ),
'hashref' => {},
'extra_sql' => $where,
'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
};
- my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
+ my $clink = sub {
+ my $cust_bill = shift;
+ $cust_bill->cust_main_custnum
+ ? [ "${p}view/cust_main.cgi?", 'custnum' ]
+ : '';
+ };
%><%= include( 'elements/search.html',
'title' => $title,
@@ -61,26 +70,26 @@
'count_query' => $count_query,
'count_addl' => [ '$%.2f total credited', ],
#'redirect' => $link,
- 'header' =>
- [ qw(Amount Date), 'Cust #', 'Contact name',
- qw(Company By Reason) ],
+ 'header' => [ 'Amount',
+ 'Date',
+ FS::UI::Web::cust_header(),
+ 'By',
+ 'Reason'
+ ],
'fields' => [
#'crednum',
sub { sprintf('$%.2f', shift->amount ) },
sub { time2str('%b %d %Y', shift->_date ) },
- 'custnum',
- sub { $_[0]->get('last'). ', '. $_[0]->first; },
- 'company',
+ \&FS::UI::Web::cust_fields,
'otaker',
'reason',
],
- 'align' => 'rrrllll',
+ #'align' => 'rrrllll',
+ 'align' => 'rr',
'links' => [
'',
'',
- $clink,
- $clink,
- $clink,
+ ( map { $clink } FS::UI::Web::cust_header() ),
'',
'',
],
Index: svc_forward.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_forward.cgi,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- svc_forward.cgi 2 May 2005 06:32:10 -0000 1.5
+++ svc_forward.cgi 14 Jul 2005 10:52:46 -0000 1.6
@@ -17,7 +17,8 @@
'hashref' => {},
'select' => join(', ',
'svc_forward.*',
- map "cust_main.$_", qw(custnum last first company)
+ 'cust_main.custnum',
+ FS::UI::Web::cust_sql_fields(),
),
'extra_sql' => $orderby,
'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'.
@@ -75,7 +76,7 @@
$svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';
};
-%><%= include ('elements/search.html',
+%><%= include( 'elements/search.html',
'title' => "Mail forward Search Results",
'name' => 'mail forwards',
'query' => $sql_query,
@@ -84,17 +85,19 @@
'header' => [ '#',
'Mail to',
'Forwards to',
- 'Customer',
+ FS::UI::Web::cust_header(),
],
'fields' => [ 'svcnum',
$format_src,
$format_dst,
- \&FS::svc_Common::cust_name,
+ \&FS::UI::Web::cust_fields,
],
'links' => [ $link,
$link_src,
$link_dst,
- $link_cust,
+ ( map { $link_cust }
+ FS::UI::Web::cust_header()
+ ),
],
- )
+ )
%>
Index: svc_acct.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_acct.cgi,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- svc_acct.cgi 28 Jan 2004 01:45:31 -0000 1.32
+++ svc_acct.cgi 14 Jul 2005 10:52:46 -0000 1.33
@@ -1,250 +1,37 @@
<%
-my $conf = new FS::Conf;
-my $maxrecords = $conf->config('maxsearchrecordsperpage');
-
-my $orderby = ''; #removeme
-
-my $limit = '';
-$limit .= "LIMIT $maxrecords" if $maxrecords;
-
-my $offset = $cgi->param('offset') || 0;
-$limit .= " OFFSET $offset" if $offset;
-
-my $total;
+my $orderby = 'ORDER BY svcnum';
my($query)=$cgi->keywords;
$query ||= ''; #to avoid use of unitialized value errors
-my $unlinked = '';
+my $cjoin = '';
+my @extra_sql = ();
if ( $query =~ /^UN_(.*)$/ ) {
$query = $1;
- my $empty = driver_name eq 'Pg' ? qq('') : qq("");
- if ( driver_name eq 'mysql' ) {
- $unlinked = "LEFT JOIN cust_svc ON cust_svc.svcnum = svc_acct.svcnum
- WHERE cust_svc.pkgnum IS NULL
- OR cust_svc.pkgnum = 0
- OR cust_svc.pkgnum = $empty";
- } else {
- $unlinked = "
- WHERE 0 <
- ( SELECT count(*) FROM cust_svc
- WHERE cust_svc.svcnum = svc_acct.svcnum
- AND ( pkgnum IS NULL OR pkgnum = 0 )
- )
- ";
- }
+ $cjoin = 'LEFT JOIN cust_svc USING ( svcnum )';
+ push @extra_sql, 'pkgnum IS NULL';
}
-my $tblname = driver_name eq 'mysql' ? 'svc_acct.' : '';
-my(@svc_acct, $sortby);
if ( $query eq 'svcnum' ) {
- $sortby=\*svcnum_sort;
- $orderby = "ORDER BY ${tblname}svcnum";
+ #$orderby = "ORDER BY svcnum";
} elsif ( $query eq 'username' ) {
- $sortby=\*username_sort;
- $orderby = "ORDER BY ${tblname}username";
+ $orderby = "ORDER BY LOWER(username)";
} elsif ( $query eq 'uid' ) {
- $sortby=\*uid_sort;
- $orderby = ( $unlinked ? ' AND' : ' WHERE' ).
- " ${tblname}uid IS NOT NULL ORDER BY ${tblname}uid";
+ $orderby = "ORDER BY uid";
+ push @extra_sql, "uid IS NOT NULL";
} elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) {
- $unlinked .= ( $unlinked ? 'AND' : 'WHERE' ).
- " popnum = $1";
- $sortby=\*username_sort;
- $orderby = "ORDER BY ${tblname}username";
+ push @extra_sql, "popnum = $1";
+ $orderby = "ORDER BY LOWER(username)";
} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
- $unlinked .= ( $unlinked ? ' AND' : ' WHERE' ).
- " $1 = ( SELECT svcpart FROM cust_svc ".
- " WHERE cust_svc.svcnum = svc_acct.svcnum ) ";
- $sortby=\*uid_sort;
- #$sortby=\*svcnum_sort;
-} else {
- $sortby=\*uid_sort;
- @svc_acct = @{&usernamesearch};
-}
-
-
-if ( $query eq 'svcnum'
- || $query eq 'username'
- || $query eq 'uid'
- || $cgi->param('popnum') =~ /^(\d+)$/
- || $cgi->param('svcpart') =~ /^(\d+)$/
- ) {
-
- my $statement = "SELECT COUNT(*) FROM svc_acct $unlinked";
- my $sth = dbh->prepare($statement)
- or die dbh->errstr. " doing $statement";
- $sth->execute or die "Error executing \"$statement\": ". $sth->errstr;
-
- $total = $sth->fetchrow_arrayref->[0];
-
- @svc_acct = qsearch('svc_acct', {}, '', "$unlinked $orderby $limit");
-
-}
-
-if ( scalar(@svc_acct) == 1 ) {
- my($svcnum)=$svc_acct[0]->svcnum;
- print $cgi->redirect(popurl(2). "view/svc_acct.cgi?$svcnum"); #redirect
- #exit;
-} elsif ( scalar(@svc_acct) == 0 ) { #error
-%>
-<!-- mason kludge -->
-<%
- idiot("Account not found");
+ $cjoin ||= 'LEFT JOIN cust_svc USING ( svcnum )';
+ push @extra_sql, "svcpart = $1";
+ $orderby = "ORDER BY uid";
+ #$orderby = "ORDER BY svcnum";
} else {
-%>
-<!-- mason kludge -->
-<%
- $total ||= scalar(@svc_acct);
-
- #begin pager
- my $pager = '';
- if ( $total != scalar(@svc_acct) && $maxrecords ) {
- unless ( $offset == 0 ) {
- $cgi->param('offset', $offset - $maxrecords);
- $pager .= '<A HREF="'. $cgi->self_url.
- '"><B><FONT SIZE="+1">Previous</FONT></B></A> ';
- }
- my $poff;
- my $page;
- for ( $poff = 0; $poff < $total; $poff += $maxrecords ) {
- $page++;
- if ( $offset == $poff ) {
- $pager .= qq!<FONT SIZE="+2">$page</FONT> !;
- } else {
- $cgi->param('offset', $poff);
- $pager .= qq!<A HREF="!. $cgi->self_url. qq!">$page</A> !;
- }
- }
- unless ( $offset + $maxrecords > $total ) {
- $cgi->param('offset', $offset + $maxrecords);
- $pager .= '<A HREF="'. $cgi->self_url.
- '"><B><FONT SIZE="+1">Next</FONT></B></A> ';
- }
- }
- #end pager
-
- print header("Account Search Results",menubar('Main Menu'=>popurl(2))),
- "$total matching accounts found<BR><BR>$pager",
- &table(), <<END;
- <TR>
- <TH><FONT SIZE=-1>#</FONT></TH>
- <TH><FONT SIZE=-1>Username</FONT></TH>
- <TH><FONT SIZE=-1>Domain</FONT></TH>
- <TH><FONT SIZE=-1>UID</FONT></TH>
- <TH><FONT SIZE=-1>Service</FONT></TH>
- <TH><FONT SIZE=-1>Cust#</FONT></TH>
- <TH><FONT SIZE=-1>(bill) name</FONT></TH>
- <TH><FONT SIZE=-1>company</FONT></TH>
-END
- if ( defined dbdef->table('cust_main')->column('ship_last') ) {
- print <<END;
- <TH><FONT SIZE=-1>(service) name</FONT></TH>
- <TH><FONT SIZE=-1>company</FONT></TH>
-END
- }
- print "</TR>";
-
- my(%saw,$svc_acct);
- my $p = popurl(2);
- foreach $svc_acct (
- sort $sortby grep(!$saw{$_->svcnum}++, @svc_acct)
- ) {
- my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $svc_acct->svcnum })
- or die "No cust_svc record for svcnum ". $svc_acct->svcnum;
- my $part_svc = qsearchs('part_svc', { 'svcpart' => $cust_svc->svcpart })
- or die "No part_svc record for svcpart ". $cust_svc->svcpart;
-
- my $domain;
- my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc });
- if ( $svc_domain ) {
- $domain = "<A HREF=\"${p}view/svc_domain.cgi?". $svc_domain->svcnum.
- "\">". $svc_domain->domain. "</A>";
- } else {
- die "No svc_domain.svcnum record for svc_acct.domsvc: ".
- $svc_acct->domsvc;
- }
- my($cust_pkg,$cust_main);
- if ( $cust_svc->pkgnum ) {
- $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_svc->pkgnum })
- or die "No cust_pkg record for pkgnum ". $cust_svc->pkgnum;
- $cust_main = qsearchs('cust_main', { 'custnum' => $cust_pkg->custnum })
- or die "No cust_main record for custnum ". $cust_pkg->custnum;
- }
- my($svcnum, $username, $uid, $svc, $custnum, $last, $first, $company) = (
- $svc_acct->svcnum,
- $svc_acct->getfield('username'),
- $svc_acct->getfield('uid'),
- $part_svc->svc,
- $cust_svc->pkgnum ? $cust_main->custnum : '',
- $cust_svc->pkgnum ? $cust_main->getfield('last') : '',
- $cust_svc->pkgnum ? $cust_main->getfield('first') : '',
- $cust_svc->pkgnum ? $cust_main->company : '',
- );
- my($pcustnum) = $custnum
- ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\"><FONT SIZE=-1>$custnum</FONT></A>"
- : "<I>(unlinked)</I>"
- ;
- my $pname = $custnum ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\">$last, $first</A>" : '';
- my $pcompany = $custnum ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\">$company</A>" : '';
- my($pship_name, $pship_company);
- if ( defined dbdef->table('cust_main')->column('ship_last') ) {
- my($ship_last, $ship_first, $ship_company) = (
- $cust_svc->pkgnum ? ( $cust_main->ship_last || $last ) : '',
- $cust_svc->pkgnum ? ( $cust_main->ship_last
- ? $cust_main->ship_first
- : $first
- ) : '',
- $cust_svc->pkgnum ? ( $cust_main->ship_last
- ? $cust_main->ship_company
- : $company
- ) : '',
- );
- $pship_name = $custnum ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\">$ship_last, $ship_first</A>" : '';
- $pship_company = $custnum ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\">$ship_company</A>" : '';
- }
- print <<END;
- <TR>
- <TD><A HREF="${p}view/svc_acct.cgi?$svcnum"><FONT SIZE=-1>$svcnum</FONT></A></TD>
- <TD><A HREF="${p}view/svc_acct.cgi?$svcnum"><FONT SIZE=-1>$username</FONT></A></TD>
- <TD><FONT SIZE=-1>$domain</FONT></TD>
- <TD><A HREF="${p}view/svc_acct.cgi?$svcnum"><FONT SIZE=-1>$uid</FONT></A></TD>
- <TD><FONT SIZE=-1>$svc</FONT></TH>
- <TD><FONT SIZE=-1>$pcustnum</FONT></TH>
- <TD><FONT SIZE=-1>$pname<FONT></TH>
- <TD><FONT SIZE=-1>$pcompany</FONT></TH>
-END
- if ( defined dbdef->table('cust_main')->column('ship_last') ) {
- print <<END;
- <TD><FONT SIZE=-1>$pship_name<FONT></TH>
- <TD><FONT SIZE=-1>$pship_company</FONT></TH>
-END
- }
- print "</TR>";
-
- }
-
- print "</TABLE>$pager<BR>".
- '</BODY></HTML>';
-
-}
-
-sub svcnum_sort {
- $a->getfield('svcnum') <=> $b->getfield('svcnum');
-}
-
-sub username_sort {
- $a->getfield('username') cmp $b->getfield('username');
-}
-
-sub uid_sort {
- $a->getfield('uid') <=> $b->getfield('uid');
-}
-
-sub usernamesearch {
+ $orderby = "ORDER BY uid";
- my @svc_acct;
+ my @username_sql;
my %username_type;
foreach ( $cgi->param('username_type') ) {
@@ -254,17 +41,13 @@
$cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text
my $username = $1;
- if ( $username_type{'Exact'} || $username_type{'Fuzzy'} ) {
- push @svc_acct, qsearch( 'svc_acct',
- { 'username' => { 'op' => 'ILIKE',
- 'value' => $username } } );
- }
+ push @username_sql, "username ILIKE '$username'"
+ if $username_type{'Exact'}
+ || $username_type{'Fuzzy'};
- if ( $username_type{'Substring'} || $username_type{'All'} ) {
- push @svc_acct, qsearch( 'svc_acct',
- { 'username' => { 'op' => 'ILIKE',
- 'value' => "%$username%" } } );
- }
+ push @username_sql, "username ILIKE '\%$username\%'"
+ if $username_type{'Substring'}
+ || $username_type{'All'};
if ( $username_type{'Fuzzy'} || $username_type{'All'} ) {
&FS::svc_acct::check_and_rebuild_fuzzyfiles;
@@ -280,15 +63,78 @@
#if ($username_type{'Sound-alike'}) {
#}
- foreach ( keys %username ) {
- push @svc_acct, qsearch('svc_acct',{'username'=>$_});
- }
+ push @username_sql, "username = '$_'"
+ foreach (keys %username);
}
- #[ qsearch('svc_acct',{'username'=>$username}) ];
- \@svc_acct;
+ push @extra_sql, '( '. join( ' OR ', @username_sql). ' )';
}
+my $extra_sql =
+ scalar(@extra_sql)
+ ? ' WHERE '. join(' AND ', @extra_sql )
+ : '';
+
+my $count_query = "SELECT COUNT(*) FROM svc_acct $cjoin $extra_sql";
+#if ( keys %svc_acct ) {
+# $count_query .= ' WHERE '.
+# join(' AND ', map "$_ = ". dbh->quote($svc_acct{$_}),
+# keys %svc_acct
+# );
+#}
+
+my $sql_query = {
+ 'table' => 'svc_acct',
+ 'hashref' => {}, # \%svc_acct,
+ 'select' => join(', ',
+ 'svc_acct.*',
+ 'cust_main.custnum',
+ FS::UI::Web::cust_sql_fields(),
+ ),
+ 'extra_sql' => "$extra_sql $orderby",
+ 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum ) '.
+ 'LEFT JOIN part_svc USING ( svcpart ) '.
+ 'LEFT JOIN cust_pkg USING ( pkgnum ) '.
+ 'LEFT JOIN cust_main USING ( custnum ) ',
+};
+
+my $link = [ "${p}view/svc_acct.cgi?", 'svcnum' ];
+my $link_cust = sub {
+ my $svc_acct = shift;
+ if ( $svc_acct->custnum ) {
+ [ "${p}view/cust_main.cgi?", 'custnum' ];
+ } else {
+ '';
+ }
+};
+
+%><%= include( 'elements/search.html',
+ 'title' => 'Account Search Results',
+ 'name' => 'accounts',
+ 'query' => $sql_query,
+ 'count_query' => $count_query,
+ 'redirect' => $link,
+ 'header' => [ '#',
+ 'Account',
+ 'UID',
+ 'Service',
+ FS::UI::Web::cust_header(),
+ ],
+ 'fields' => [ 'svcnum',
+ 'email',
+ 'uid',
+ 'svc',
+ \&FS::UI::Web::cust_fields,
+ ],
+ 'links' => [ $link,
+ $link,
+ $link,
+ '',
+ ( map { $link_cust }
+ FS::UI::Web::cust_header()
+ ),
+ ],
+ )
%>
- Previous message: [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
- Next message: [freeside-commits] freeside/httemplate/search/elements search.html,
1.15, 1.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list