diff options
29 files changed, 430 insertions, 279 deletions
diff --git a/README.1.5.7 b/README.1.5.7 index ff70961b3..8c10f8852 100644 --- a/README.1.5.7 +++ b/README.1.5.7 @@ -104,7 +104,8 @@ dbdef-create username create-history-tables username rate rate_detail rate_region rate_prefix reg_code reg_code_pkg dbdef-create username -install Javascript::RPC (JavaScript::RPC::Server::CGI) +install Javascript::RPC (JavaScript::RPC::Server::CGI), Text::CSV_XS and +Spreadsheet::WriteExcel afterwords (for installs w/integrated RT): make configure-rt diff --git a/htetc/global.asa b/htetc/global.asa index 482572a80..ed26057ea 100644 --- a/htetc/global.asa +++ b/htetc/global.asa @@ -14,11 +14,14 @@ use Tie::IxHash; use HTML::Entities; use IO::Handle; use IO::File; +use IO::Scalar; use Net::Whois::Raw qw(whois); if ( $] < 5.006 ) { eval "use Net::Whois::Raw 0.32 qw(whois)"; die $@ if $@; } +use Text::CSV_XS; +use Spreadsheet::WriteExcel; use Business::CreditCard; use String::Approx qw(amatch); use Chart::LinesPoints; diff --git a/htetc/handler.pl b/htetc/handler.pl index f115104b1..f41db36ec 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -97,11 +97,14 @@ sub handler use HTML::Entities; use IO::Handle; use IO::File; + use IO::Scalar; use Net::Whois::Raw qw(whois); if ( $] < 5.006 ) { eval "use Net::Whois::Raw 0.32 qw(whois)"; die $@ if $@; } + use Text::CSV_XS; + use Spreadsheet::WriteExcel; use Business::CreditCard; use String::Approx qw(amatch); use Chart::LinesPoints; diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index 1632fb38d..4a89ab3ba 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -62,6 +62,8 @@ Before installing, you need: <li><a href="http://search.cpan.org/search?dist=Crypt-PasswdMD5">Crypt::PasswdMD5</a> <li><a href="http://search.cpan.org/search?dist=JavaScript-RPC">JavaScript::RPC (JavaScript::RPC::Server::CGI)</a> <li><a href="http://search.cpan.org/search?dist=Frontier-RPC">Frontier::RPC</a> + <li><a href="http://search.cpan.org/search?dist=Text-CSV_XS">Text::CSV_XS</a> + <li><a href="http://search.cpan.org/search?dist=Spreadsheet-WriteExcel">Spreadsheet::WriteExcel</a> <!-- <li><a href="http://search.cpan.org/search?dist=Crypt-YAPassGen">Crypt::YAPassGen</a> --> <li><a href="http://search.cpan.org/search?dist=ApacheDBI">Apache::DBI</a> <i>(optional but recommended for better webinterface performance)</i> </ul> diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html index 977755b90..2f4549d7f 100644 --- a/httemplate/docs/upgrade10.html +++ b/httemplate/docs/upgrade10.html @@ -9,7 +9,8 @@ install Net::SSH 0.08 - In httpd.conf, change <b>AddHandler perl-script .cgi</b> or <b>SetHandler perl-script</b> to <b>AddHandler perl-script .cgi .html</b> install NetAddr::IP, Chart::Base, Locale::SubCountry, -JavaScript::RPC (JavaScript::RPC::Server::CGI) <!-- and Crypt::YAPassGen--> +JavaScript::RPC (JavaScript::RPC::Server::CGI), Text::CSV_XS and +Spreadsheet::WriteExcel<!-- and Crypt::YAPassGen--> INSERT INTO msgcat ( msgnum, msgcode, locale, msg ) VALUES ( 20, 'svc_external-id', 'en_US', 'External ID' ); INSERT INTO msgcat ( msgnum, msgcode, locale, msg ) VALUES ( 21, 'svc_external-title', 'en_US', 'Title' ); diff --git a/httemplate/index.html b/httemplate/index.html index 2d326b539..b3b1c231a 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -62,16 +62,16 @@ <TR><TD> <BR><FONT SIZE="+1"><A HREF="edit/cust_main.cgi">New Customer</A></FONT> <BR> - <BR><FORM ACTION="search/cust_main.cgi" METHOD="POST"><INPUT TYPE="hidden" NAME="custnum_on" VALUE="1">Customer # <INPUT TYPE="text" NAME="custnum_text"><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/cust_main.cgi?browse=custnum">all customers by customer number</A></FORM> - <FORM ACTION="search/cust_main.cgi" METHOD="POST"><INPUT TYPE="hidden" NAME="last_on" VALUE="1">Last name <INPUT TYPE="text" NAME="last_text"><SELECT NAME="last_type"><OPTION SELECTED VALUE="All">(all)</OPTION><OPTION>Fuzzy<OPTION>Substring</OPTION><OPTION>Exact</OPTION></SELECT><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/cust_main.cgi?browse=last">all customers by last name</A></FORM> - <FORM ACTION="search/cust_main.cgi" METHOD="POST"><INPUT TYPE="hidden" NAME="company_on" VALUE="1">Company <INPUT TYPE="text" NAME="company_text"><SELECT NAME="company_type"><OPTION SELECTED VALUE="All">(all)</OPTION><OPTION>Fuzzy<OPTION>Substring</OPTION><OPTION>Exact</OPTION></SELECT><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/cust_main.cgi?browse=company">all customers by company</A></FORM> + <BR><FORM ACTION="search/cust_main.cgi" METHOD="GET"><INPUT TYPE="hidden" NAME="custnum_on" VALUE="1">Customer # <INPUT TYPE="text" NAME="custnum_text"><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/cust_main.cgi?browse=custnum">all customers by customer number</A></FORM> + <FORM ACTION="search/cust_main.cgi" METHOD="GET"><INPUT TYPE="hidden" NAME="last_on" VALUE="1">Last name <INPUT TYPE="text" NAME="last_text"><SELECT NAME="last_type"><OPTION SELECTED VALUE="All">(all)</OPTION><OPTION>Fuzzy<OPTION>Substring</OPTION><OPTION>Exact</OPTION></SELECT><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/cust_main.cgi?browse=last">all customers by last name</A></FORM> + <FORM ACTION="search/cust_main.cgi" METHOD="GET"><INPUT TYPE="hidden" NAME="company_on" VALUE="1">Company <INPUT TYPE="text" NAME="company_text"><SELECT NAME="company_type"><OPTION SELECTED VALUE="All">(all)</OPTION><OPTION>Fuzzy<OPTION>Substring</OPTION><OPTION>Exact</OPTION></SELECT><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/cust_main.cgi?browse=company">all customers by company</A></FORM> <% if ( $conf->exists('address2-search') ) { %> - <FORM ACTION="search/cust_main.cgi" METHOD="POST"><INPUT TYPE="hidden" NAME="address2_on" VALUE="1">Unit <INPUT TYPE="text" NAME="address2_text"><INPUT TYPE="submit" VALUE="Search"></FORM> + <FORM ACTION="search/cust_main.cgi" METHOD="GET"><INPUT TYPE="hidden" NAME="address2_on" VALUE="1">Unit <INPUT TYPE="text" NAME="address2_text"><INPUT TYPE="submit" VALUE="Search"></FORM> <% } %> - <FORM ACTION="search/cust_main.cgi" METHOD="POST"><INPUT TYPE="hidden" NAME="phone_on" VALUE="1">Phone # <INPUT TYPE="text" NAME="phone_text"><INPUT TYPE="submit" VALUE="Search"></FORM> - <BR><FORM ACTION="search/svc_acct.cgi" METHOD="POST">Username <INPUT TYPE="text" NAME="username"><SELECT NAME="username_type"><OPTION VALUE="All">(all)</OPTION><OPTION>Fuzzy</OPTION><OPTION>Substring</OPTION><OPTION SELECTED>Exact</OPTION></SELECT><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_acct.cgi?username">all accounts by username</A> or <A HREF="search/svc_acct.cgi?uid">uid</A></FORM> - <BR><FORM ACTION="search/svc_domain.cgi" METHOD="POST">Domain <INPUT TYPE="text" NAME="domain"><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_domain.cgi?domain">all domains</A></FORM> - <BR><FORM ACTION="search/svc_broadband.cgi" METHOD="POST">IP Address <INPUT TYPE="text" NAME="ip_addr"><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_broadband.cgi?svcnum">all services by svcnum</A> or <A HREF="search/svc_broadband.cgi?blocknum">address block</A></FORM> + <FORM ACTION="search/cust_main.cgi" METHOD="GET"><INPUT TYPE="hidden" NAME="phone_on" VALUE="1">Phone # <INPUT TYPE="text" NAME="phone_text"><INPUT TYPE="submit" VALUE="Search"></FORM> + <BR><FORM ACTION="search/svc_acct.cgi" METHOD="GET">Username <INPUT TYPE="text" NAME="username"><SELECT NAME="username_type"><OPTION VALUE="All">(all)</OPTION><OPTION>Fuzzy</OPTION><OPTION>Substring</OPTION><OPTION SELECTED>Exact</OPTION></SELECT><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_acct.cgi?username">all accounts by username</A> or <A HREF="search/svc_acct.cgi?uid">uid</A></FORM> + <BR><FORM ACTION="search/svc_domain.cgi" METHOD="GET">Domain <INPUT TYPE="text" NAME="domain"><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_domain.cgi?domain">all domains</A></FORM> + <BR><FORM ACTION="search/svc_broadband.cgi" METHOD="GET">IP Address <INPUT TYPE="text" NAME="ip_addr"><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_broadband.cgi?svcnum">all services by svcnum</A> or <A HREF="search/svc_broadband.cgi?blocknum">address block</A></FORM> <BR><A HREF="search/svc_forward.cgi?svcnum">all mail forwards by svcnum</A><BR> <BR><A HREF="search/svc_www.cgi?svcnum">all virtual hosts by svcnum</A><BR> <BR><A HREF="search/svc_external.cgi?svcnum">all external services by svcnum</A><BR> @@ -117,9 +117,9 @@ <TR><TD> <BR><A HREF="search/cust_main-quickpay.html">Quick payment entry</A> <BR> - <BR><FORM ACTION="search/cust_main.cgi" METHOD="POST">Credit card # <INPUT TYPE="hidden" NAME="card_on" VALUE="1"><INPUT TYPE="text" NAME="card"><INPUT TYPE="submit" VALUE="Search"></FORM> - <FORM ACTION="search/cust_bill.html" METHOD="POST">Invoice # <INPUT TYPE="text" NAME="invnum" SIZE="8"><INPUT TYPE="submit" VALUE="Search"></FORM> - <FORM ACTION="search/cust_pay.cgi" METHOD="POST">Check # <INPUT TYPE="text" NAME="payinfo" SIZE="8"><INPUT TYPE="hidden" NAME="payby" VALUE="BILL"><INPUT TYPE="submit" VALUE="Search"></FORM> + <BR><FORM ACTION="search/cust_main.cgi" METHOD="GET">Credit card # <INPUT TYPE="hidden" NAME="card_on" VALUE="1"><INPUT TYPE="text" NAME="card"><INPUT TYPE="submit" VALUE="Search"></FORM> + <FORM ACTION="search/cust_bill.html" METHOD="GET">Invoice # <INPUT TYPE="text" NAME="invnum" SIZE="8"><INPUT TYPE="submit" VALUE="Search"></FORM> + <FORM ACTION="search/cust_pay.cgi" METHOD="GET">Check # <INPUT TYPE="text" NAME="payinfo" SIZE="8"><INPUT TYPE="hidden" NAME="payby" VALUE="BILL"><INPUT TYPE="submit" VALUE="Search"></FORM> <BR><A HREF="browse/cust_pay_batch.cgi">View pending credit card batch</A> <BR><BR><A HREF="search/cust_pkg_report.cgi">Packages (by next bill date range)</A> <BR><BR>Invoice reports <UL> @@ -200,7 +200,7 @@ <UL> <LI><A HREF="search/cust_main-otaker.cgi">Search customers by ordering employee</A> </UL> - <FORM ACTION="search/sql.html" METHOD="POST">SQL query: <TT>SELECT </TT><INPUT TYPE="text" NAME="sql" SIZE=32><INPUT TYPE="submit" VALUE="Query"></FORM> + <FORM ACTION="search/sql.html" METHOD="GET">SQL query: <TT>SELECT </TT><INPUT TYPE="text" NAME="sql" SIZE=32><INPUT TYPE="submit" VALUE="Query"></FORM> <BR> </TD></TR> diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 3ae624af2..440e468e3 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -58,44 +58,43 @@ : ''; }; -%> -<%= include( 'elements/search.html', - 'title' => 'Invoice Search Results', - 'name' => 'invoices', - 'query' => $sql_query, - 'count_query' => $count_query, - 'count_addl' => [ '$%.2f total invoiced', - '$%.2f total outstanding balance', - ], - 'redirect' => $link, - 'header' => - [ 'Invoice #', qw(Balance Amount Date), 'Contact name', - 'Company' ], - 'fields' => [ - 'invnum', - sub { sprintf('$%.2f', shift->get('owed') ) }, - sub { sprintf('$%.2f', shift->charged ) }, - sub { time2str('%b %d %Y', shift->_date ) }, - sub { my $cust_bill = shift; - my $cust_main = $cust_bill->cust_main; - $cust_main - ? $cust_main->get('last'). ', '. $cust_main->first - : "WARNING: can't find cust_main.custnum ". - $cust_bill->custnum. ' (cust_bill.invnum '. - $cust_bill->invnum. ')'; - }, - sub { my $cust_main = shift->cust_main; - $cust_main ? $cust_main->company : ''; - }, - ], - 'links' => [ - $link, - $link, - $link, - $link, - $clink, - $clink, - ], - - ) +%><%= include( 'elements/search.html', + 'title' => 'Invoice Search Results', + 'name' => 'invoices', + 'query' => $sql_query, + 'count_query' => $count_query, + 'count_addl' => [ '$%.2f total invoiced', + '$%.2f total outstanding balance', + ], + 'redirect' => $link, + 'header' => + [ 'Invoice #', qw(Balance Amount Date), 'Contact name', + 'Company' ], + 'fields' => [ + 'invnum', + sub { sprintf('$%.2f', shift->get('owed') ) }, + sub { sprintf('$%.2f', shift->charged ) }, + sub { time2str('%b %d %Y', shift->_date ) }, + sub { my $cust_bill = shift; + my $cust_main = $cust_bill->cust_main; + $cust_main + ? $cust_main->get('last'). ', '. $cust_main->first + : "WARNING: can't find cust_main.custnum ". + $cust_bill->custnum. ' (cust_bill.invnum '. + $cust_bill->invnum. ')'; + }, + sub { my $cust_main = shift->cust_main; + $cust_main ? $cust_main->company : ''; + }, + ], + 'links' => [ + $link, + $link, + $link, + $link, + $clink, + $clink, + ], + + ) %> diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html index cd96ddf51..6de27091f 100755 --- a/httemplate/search/cust_bill_event.html +++ b/httemplate/search/cust_bill_event.html @@ -8,7 +8,7 @@ </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Invoice event errors</H1> - <FORM ACTION="cust_bill_event.cgi" METHOD="post"> + <FORM ACTION="cust_bill_event.cgi" METHOD="GET"> <TABLE> <!--<TR> <TD ALIGN="right">Customer type</TD> diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index 8f6258e4e..b978e6238 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -54,36 +54,35 @@ my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; -%> -<%= include( 'elements/search.html', - 'title' => $title, - 'name' => 'credits', - 'query' => $sql_query, - 'count_query' => $count_query, - 'count_addl' => [ '$%.2f total credited', ], - #'redirect' => $link, - 'header' => - [ qw(Amount Date), 'Cust #', 'Contact name', - qw(Company By Reason) ], - 'fields' => [ - #'crednum', - sub { sprintf('$%.2f', shift->amount ) }, - sub { time2str('%b %d %Y', shift->_date ) }, - 'custnum', - sub { $_[0]->get('last'). ', '. $_[0]->first; }, - 'company', - 'otaker', - 'reason', - ], - 'align' => 'rrrllll', - 'links' => [ - '', - '', - $clink, - $clink, - $clink, - '', - '', - ], - ) +%><%= include( 'elements/search.html', + 'title' => $title, + 'name' => 'credits', + 'query' => $sql_query, + 'count_query' => $count_query, + 'count_addl' => [ '$%.2f total credited', ], + #'redirect' => $link, + 'header' => + [ qw(Amount Date), 'Cust #', 'Contact name', + qw(Company By Reason) ], + 'fields' => [ + #'crednum', + sub { sprintf('$%.2f', shift->amount ) }, + sub { time2str('%b %d %Y', shift->_date ) }, + 'custnum', + sub { $_[0]->get('last'). ', '. $_[0]->first; }, + 'company', + 'otaker', + 'reason', + ], + 'align' => 'rrrllll', + 'links' => [ + '', + '', + $clink, + $clink, + $clink, + '', + '', + ], + ) %> diff --git a/httemplate/search/cust_main-otaker.cgi b/httemplate/search/cust_main-otaker.cgi index 44214368a..03c2619af 100755 --- a/httemplate/search/cust_main-otaker.cgi +++ b/httemplate/search/cust_main-otaker.cgi @@ -7,7 +7,7 @@ Customer Search </FONT> <BR> - <FORM ACTION="cust_main.cgi" METHOD="post"> + <FORM ACTION="cust_main.cgi" METHOD="GET"> Search for <B>Order taker</B>: <INPUT TYPE="hidden" NAME="otaker_on" VALUE="TRUE"> <% my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_main") diff --git a/httemplate/search/cust_main-payinfo.html b/httemplate/search/cust_main-payinfo.html index 671b5ef08..b82b610d8 100755 --- a/httemplate/search/cust_main-payinfo.html +++ b/httemplate/search/cust_main-payinfo.html @@ -7,7 +7,7 @@ Customer Search </FONT> <BR> - <FORM ACTION="cust_main.cgi" METHOD="post"> + <FORM ACTION="cust_main.cgi" METHOD="GET"> Search for <B>Credit card #</B>: <INPUT TYPE="hidden" NAME="card_on" VALUE="TRUE"> <INPUT TYPE="text" NAME="card"> diff --git a/httemplate/search/cust_main-quickpay.html b/httemplate/search/cust_main-quickpay.html index 077d290d9..154a64199 100755 --- a/httemplate/search/cust_main-quickpay.html +++ b/httemplate/search/cust_main-quickpay.html @@ -8,7 +8,7 @@ </FONT> <BR><BR> <A HREF="../">Main Menu</A><BR><BR> - <FORM ACTION="cust_main.cgi" METHOD="post"> + <FORM ACTION="cust_main.cgi" METHOD="GET"> <INPUT TYPE="hidden" NAME="quickpay" VALUE="yes"> <INPUT TYPE="checkbox" NAME="last_on" CHECKED> Search for <B>last name</B>: <INPUT TYPE="text" NAME="last_text"> diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index ecff4bf3b..a3256674b 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -285,7 +285,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { or eidiot "Illegal referral_custnum\n"; my $referral_custnum = $1; my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } ); - print '<FORM METHOD=POST>'. + print '<FORM METHOD="GET">'. qq!<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="$referral_custnum">!. 'referrals of <A HREF="'. popurl(2). "view/cust_main.cgi?$referral_custnum\">$referral_custnum: ". diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html index 5a066e453..4f7508447 100755 --- a/httemplate/search/cust_main.html +++ b/httemplate/search/cust_main.html @@ -7,7 +7,7 @@ Customer Search </FONT> <BR><BR> - <FORM ACTION="cust_main.cgi" METHOD="post"> + <FORM ACTION="cust_main.cgi" METHOD="GET"> <INPUT TYPE="checkbox" NAME="last_on" CHECKED> Search for <B>last name</B>: <INPUT TYPE="text" NAME="last_text"> using search method: <SELECT NAME="last_type"> diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index d4aaaa89c..01a2ed95a 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -98,43 +98,42 @@ my $link = [ "${p}view/cust_main.cgi?", 'custnum' ]; -%> -<%= include( 'elements/search.html', - 'title' => $title, - 'name' => 'payments', - 'query' => $sql_query, - 'count_query' => $count_query, - 'count_addl' => [ '$%.2f total paid', ], - 'header' => - [ qw(Payment Amount Date), 'Cust #', 'Contact name', - 'Company', ], - 'fields' => [ - sub { - my $cust_pay = shift; - if ( $cust_pay->payby eq 'CARD' ) { - 'Card #'. $cust_pay->payinfo_masked; - } elsif ( $cust_pay->payby eq 'CHEK' ) { - 'E-check acct#'. $cust_pay->payinfo; - } elsif ( $cust_pay->payby eq 'BILL' ) { - 'Check #'. $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', - ], - 'align' => 'lrrrll', - 'links' => [ - '', - '', - '', - $link, - $link, - $link, - ], - ) +%><%= include( 'elements/search.html', + 'title' => $title, + 'name' => 'payments', + 'query' => $sql_query, + 'count_query' => $count_query, + 'count_addl' => [ '$%.2f total paid', ], + 'header' => + [ qw(Payment Amount Date), 'Cust #', 'Contact name', + 'Company', ], + 'fields' => [ + sub { + my $cust_pay = shift; + if ( $cust_pay->payby eq 'CARD' ) { + 'Card #'. $cust_pay->payinfo_masked; + } elsif ( $cust_pay->payby eq 'CHEK' ) { + 'E-check acct#'. $cust_pay->payinfo; + } elsif ( $cust_pay->payby eq 'BILL' ) { + 'Check #'. $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', + ], + 'align' => 'lrrrll', + 'links' => [ + '', + '', + '', + $link, + $link, + $link, + ], + ) %> diff --git a/httemplate/search/cust_pay.html b/httemplate/search/cust_pay.html index 3848d66f7..6414cf771 100755 --- a/httemplate/search/cust_pay.html +++ b/httemplate/search/cust_pay.html @@ -7,7 +7,7 @@ Check # Search </FONT> <BR><BR> - <FORM ACTION="cust_pay.cgi" METHOD="post"> + <FORM ACTION="cust_pay.cgi" METHOD="GET"> Search for <B>check #</B>: <INPUT TYPE="text" NAME="payinfo"> <INPUT TYPE="hidden" NAME="payby" VALUE="BILL"> diff --git a/httemplate/search/cust_pkg_report.cgi b/httemplate/search/cust_pkg_report.cgi index b31674540..6bd918995 100755 --- a/httemplate/search/cust_pkg_report.cgi +++ b/httemplate/search/cust_pkg_report.cgi @@ -8,7 +8,7 @@ </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Packages</H1> - <FORM ACTION="cust_pkg.cgi" METHOD="post"> + <FORM ACTION="cust_pkg.cgi" METHOD="GET"> <INPUT TYPE="hidden" NAME="magic" VALUE="bill"> Return packages with next bill date:<BR><BR> <TABLE> diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 712d63a91..85e5af25e 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -1,6 +1,7 @@ <% my(%opt) = @_; + #warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n"; my %align = ( 'l' => 'left', @@ -12,31 +13,39 @@ $opt{align} = [ map $align{$_}, split(//, $opt{align}) ], unless !$opt{align} || ref($opt{align}); - #if ( ref($opt{'query'}) ) { - # - #} + my $type = ''; + my $limit = ''; + my($maxrecords, $total, $offset, $count_arrayref); - unless (exists($opt{'count_query'}) && length($opt{'count_query'})) { - ( $opt{'count_query'} = $opt{'query'} ) =~ - s/^\s*SELECT\s*(.*?)\s+FROM\s/SELECT COUNT(*) FROM /i; - } + if ( $cgi->param('_type') =~ /^(csv|\w*\.xls)$/ ) { + + $type = $1; - my $conf = new FS::Conf; - my $maxrecords = $conf->config('maxsearchrecordsperpage'); + } else { #setup some pagination things if we're in html mode - my $limit = $maxrecords ? "LIMIT $maxrecords" : ''; + unless (exists($opt{'count_query'}) && length($opt{'count_query'})) { + ( $opt{'count_query'} = $opt{'query'} ) =~ + s/^\s*SELECT\s*(.*?)\s+FROM\s/SELECT COUNT(*) FROM /i; + } - my $offset = $cgi->param('offset') || 0; - $limit .= " OFFSET $offset" if $offset; + my $conf = new FS::Conf; + $maxrecords = $conf->config('maxsearchrecordsperpage'); - my $count_sth = dbh->prepare($opt{'count_query'}) - or die "Error preparing $opt{'count_query'}: ". dbh->errstr; - $count_sth->execute - or die "Error executing $opt{'count_query'}: ". $count_sth->errstr; - my $count_arrayref = $count_sth->fetchrow_arrayref; - my $total = $count_arrayref->[0]; + $limit = $maxrecords ? "LIMIT $maxrecords" : ''; - #warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n"; + $offset = $cgi->param('offset') || 0; + $limit .= " OFFSET $offset" if $offset; + + my $count_sth = dbh->prepare($opt{'count_query'}) + or die "Error preparing $opt{'count_query'}: ". dbh->errstr; + $count_sth->execute + or die "Error executing $opt{'count_query'}: ". $count_sth->errstr; + $count_arrayref = $count_sth->fetchrow_arrayref; + $total = $count_arrayref->[0]; + + } + + # run the query my $header = $opt{'header'}; my $rows; @@ -62,80 +71,217 @@ $header ||= $sth->{NAME}; } - if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 && $total == 1 ) { - my( $url, $method ) = @{$opt{'redirect'}}; - redirect( $url. $rows->[0]->$method() ); - } else { - $opt{'name'} =~ s/s$// if $total == 1; -%> -<%= include( '/elements/header.html', $opt{'title'}, - include( '/elements/menubar.html', 'Main menu' => $p ) - ) -%> -<% my $pager = include ( '/elements/pager.html', - 'offset' => $offset, - 'num_rows' => scalar(@$rows), - 'total' => $total, - 'maxrecords' => $maxrecords, - ); -%> -<% unless ( $total ) { %> - No matching <%= $opt{'name'} %> found.<BR> -<% } else { %> - <%= $total %> total <%= $opt{'name'} %><BR> - <% if ( $opt{'count_addl'} ) { %> - <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %> - <%= sprintf( $count, $count_arrayref->[++$n] ) %><BR> - <% } %> - <% } %> - <BR><%= $pager %> - <%= include( '/elements/table.html' ) %> - <TR> - <% foreach my $header ( @$header ) { %> - <TH><%= $header %></TH> - <% } %> - </TR> - <% foreach my $row ( @$rows ) { %> - <TR> - <% if ( $opt{'fields'} ) { - my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; - my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; - foreach my $field ( @{$opt{'fields'}} ) { - my $align = $aligns ? shift @$aligns : ''; - $align = " ALIGN=$align" if $align; - my $a = ''; - if ( $links ) { - my $link = shift @$links; - $link = &{$link}($row) if ref($link) eq 'CODE'; - if ( $link ) { - my( $url, $method ) = @{$link}; - if ( ref($method) eq 'CODE' ) { - $a = $url. &{$method}($row); - } else { - $a = $url. $row->$method(); - } - $a = qq(<A HREF="$a">); - } - } - %> - <% if ( ref($field) eq 'CODE' ) { %> - <TD<%= $align %>><%= $a %><%= &{$field}($row) %><%= $a ? '</A>' : '' %></TD> - <% } else { %> - <TD<%= $align %>><%= $a %><%= $row->$field() %><%= $a ? '</A>' : '' %></TD> - <% } %> - <% } %> - <% } else { %> - <% foreach ( @$row ) { %> - <TD><%= $_ %></TD> - <% } %> - <% } %> - </TR> - <% } %> + if ( $type eq 'csv' ) { + + #http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes + http_header('Content-Type' => 'text/plain' ); + + my $csv = new Text::CSV_XS { 'always_quote' => 1, + #'eol' => "\015\012", #"\012" + }; + + $csv->combine(@$header); #or die $csv->status; + %><%= $csv->string %><% + + foreach my $row ( @$rows ) { + + if ( $opt{'fields'} ) { + + my @line = (); + + foreach my $field ( @{$opt{'fields'}} ) { + if ( ref($field) eq 'CODE' ) { + push @line, &{$field}($row); + } else { + push @line, $row->$field(); + } + } + + $csv->combine(@line); #or die $csv->status; + + } else { + $csv->combine(@$row); #or die $csv->status; + } + + %><%= $csv->string %><% + + } + + #} elsif ( $type eq 'excel' ) { + } elsif ( $type =~ /\.xls$/ ) { + + #http_header('Content-Type' => 'application/excel' ); #eww + http_header('Content-Type' => 'application/vnd.ms-excel' ); #alas + #http_header('Content-Type' => 'application/msexcel' ); #alas + + my $data = ''; + my $XLS = new IO::Scalar \$data; + my $workbook = Spreadsheet::WriteExcel->new($XLS) + or die "Error opening .xls file: $!"; + + my $worksheet = $workbook->add_worksheet(substr($opt{'title'},0,31)); + + my($r,$c) = (0,0); + + $worksheet->write($r, $c++, $_) foreach @$header; + + foreach my $row ( @$rows ) { + $r++; + $c = 0; + + if ( $opt{'fields'} ) { + + #my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; + #my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; + + foreach my $field ( @{$opt{'fields'}} ) { + #my $align = $aligns ? shift @$aligns : ''; + #$align = " ALIGN=$align" if $align; + #my $a = ''; + #if ( $links ) { + # my $link = shift @$links; + # $link = &{$link}($row) if ref($link) eq 'CODE'; + # if ( $link ) { + # my( $url, $method ) = @{$link}; + # if ( ref($method) eq 'CODE' ) { + # $a = $url. &{$method}($row); + # } else { + # $a = $url. $row->$method(); + # } + # $a = qq(<A HREF="$a">); + # } + #} + if ( ref($field) eq 'CODE' ) { + $worksheet->write($r, $c++, &{$field}($row) ); + } else { + $worksheet->write($r, $c++, $row->$field() ); + } + } + + } else { + $worksheet->write($r, $c++, $_) foreach @$row; + } + + } + + $workbook->close();# or die "Error creating .xls file: $!"; + + http_header('Content-Length' => length($data) ); + %><%= $data %><% + + } else { # regular HTML + + if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 && $total == 1 ) { + my( $url, $method ) = @{$opt{'redirect'}}; + redirect( $url. $rows->[0]->$method() ); + } else { + ( my $xlsname = $opt{'name'} ) =~ s/\W//g; + $opt{'name'} =~ s/s$// if $total == 1; + %> + <%= include( '/elements/header.html', $opt{'title'}, + include( '/elements/menubar.html', 'Main menu' => $p ) + ) + %> + <% my $pager = include ( '/elements/pager.html', + 'offset' => $offset, + 'num_rows' => scalar(@$rows), + 'total' => $total, + 'maxrecords' => $maxrecords, + ); + %> + <% unless ( $total ) { %> + No matching <%= $opt{'name'} %> found.<BR> + <% } else { %> - </TABLE> - <%= $pager %> -<% } %> -</BODY> -</HTML> + <TABLE> + <TR> + <TD> + <%= $total %> total <%= $opt{'name'} %><BR> + <% if ( $opt{'count_addl'} ) { %> + <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %> + <%= sprintf( $count, $count_arrayref->[++$n] ) %><BR> + <% } %> + <% } %> + </TD> + <TD ALIGN="right"> + <% $cgi->param('_type', "$xlsname.xls" ); %> + Download full results<BR> + as <A HREF="<%= $cgi->self_url %>">Excel spreadsheet</A> + <BR> + <% $cgi->param('_type', 'csv'); %> + as <A HREF="<%= $cgi->self_url %>">CSV file</A> + </TD> + </TR> + <TR> + <TD COLSPAN=2> + + <%= $pager %> + <STYLE TYPE="text/css"> + .grid table { border: solid; empty-cells: show } + .grid TH { padding-left: 1px; padding-right: 1px; border: 1px solid #dddddd; border-bottom: dashed 1px black; border-right: none } + .grid TD { padding-left: 1px; padding-right: 1px; empty-cells: show; border: 1px solid #cccccc; border-bottom: none; border-right: none } + </STYLE> + <TABLE CLASS="grid" CELLSPACING=0 CELLPADDING=0 BORDER=1 BORDERCOLOR="#000000" STYLE="border: solid 1px black; empty-cells: show"> + <TR> + <% foreach my $header ( @$header ) { %> + <TH CLASS="grid" BGCOLOR="#cccccc"><%= $header %></TH> + <% } %> + </TR> + <% my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor; + foreach my $row ( @$rows ) { + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } + %> + <TR> + <% if ( $opt{'fields'} ) { + my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; + my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; + foreach my $field ( @{$opt{'fields'}} ) { + my $align = $aligns ? shift @$aligns : ''; + $align = " ALIGN=$align" if $align; + my $a = ''; + if ( $links ) { + my $link = shift @$links; + $link = &{$link}($row) if ref($link) eq 'CODE'; + if ( $link ) { + my( $url, $method ) = @{$link}; + if ( ref($method) eq 'CODE' ) { + $a = $url. &{$method}($row); + } else { + $a = $url. $row->$method(); + } + $a = qq(<A HREF="$a">); + } + } + %> + <% if ( ref($field) eq 'CODE' ) { %> + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $a %><%= &{$field}($row) %><%= $a ? '</A>' : '' %></TD> + <% } else { %> + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $a %><%= $row->$field() %><%= $a ? '</A>' : '' %></TD> + <% } %> + <% } %> + <% } else { %> + <% foreach ( @$row ) { %> + <TD CLASS="grid" BGCOLOR="$bgcolor"><%= $_ %></TD> + <% } %> + <% } %> + </TR> + <% } %> + + </TABLE> + <%= $pager %> + + </TD> + </TR> + </TABLE> + + <% } %> + </BODY> + </HTML> + <% } %> <% } %> - diff --git a/httemplate/search/reg_code.html b/httemplate/search/reg_code.html index ba1eee078..52a99ff66 100644 --- a/httemplate/search/reg_code.html +++ b/httemplate/search/reg_code.html @@ -7,29 +7,30 @@ my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); my $count_query = "SELECT COUNT(*) FROM reg_code WHERE agentnum = $agentnum"; -%> -<%= include( 'elements/search.html', - 'title' => 'Unused Registration Codes for '. $agent->agent, - 'name' => 'registration codes', - 'query' => { 'table' => 'reg_code', - 'hashref' => { 'agentnum' => $agentnum, }, - }, - 'count_query' => $count_query, - #'redirect' => $link, - 'header' => [ qw(Code Packages) ], - 'fields' => [ - 'code', - sub { map { - qq!<A HREF="${p}edit/part_pkg.cgi?!. $_->pkgpart. '">'. - $_->pkg. ' - '. $_->comment. - '</A><BR>' - } $_[0]->part_pkg - }, - ], - 'links' => [ - '', - #$plink, - '', - ], - ) +%><%= include( 'elements/search.html', + 'title' => 'Unused Registration Codes for '. + $agent->agent, + 'name' => 'registration codes', + 'query' => { 'table' => 'reg_code', + 'hashref' => { 'agentnum' => $agentnum, }, + }, + 'count_query' => $count_query, + #'redirect' => $link, + 'header' => [ qw(Code Packages) ], + 'fields' => [ + 'code', + sub { + map { + qq!<A HREF="${p}edit/part_pkg.cgi?!. $_->pkgpart. '">'. + $_->pkg. ' - '. $_->comment. + '</A><BR>' + } $_[0]->part_pkg + }, + ], + 'links' => [ + '', + #$plink, + '', + ], + ) %> diff --git a/httemplate/search/report_cust_credit.html b/httemplate/search/report_cust_credit.html index b614e87b2..3a14f44e2 100644 --- a/httemplate/search/report_cust_credit.html +++ b/httemplate/search/report_cust_credit.html @@ -8,7 +8,7 @@ </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Credit report criteria</H1> - <FORM ACTION="cust_credit.html" METHOD="post"> + <FORM ACTION="cust_credit.html" METHOD="GET"> <INPUT TYPE="hidden" NAME="magic" VALUE="_date"> <TABLE> <TR> diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index d1d4cb983..8b9e27302 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -8,7 +8,7 @@ </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Payment report criteria</H1> - <FORM ACTION="cust_pay.cgi" METHOD="post"> + <FORM ACTION="cust_pay.cgi" METHOD="GET"> <INPUT TYPE="hidden" NAME="magic" VALUE="_date"> <TABLE> <TR> diff --git a/httemplate/search/report_prepaid_income.html b/httemplate/search/report_prepaid_income.html index e8b6ac4b1..57c318eba 100644 --- a/httemplate/search/report_prepaid_income.html +++ b/httemplate/search/report_prepaid_income.html @@ -8,7 +8,7 @@ </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Prepaid Income (Unearned Revenue) Report</H1> - <FORM ACTION="report_prepaid_income.cgi" METHOD="post"> + <FORM ACTION="report_prepaid_income.cgi" METHOD="GET"> <TABLE> <TR> <TD>Prepaid income (unearned revenue) as of </TD> diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html index d217e5671..85af212d7 100755 --- a/httemplate/search/report_tax.html +++ b/httemplate/search/report_tax.html @@ -7,7 +7,7 @@ <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Tax Report Criteria</H1> - <FORM ACTION="report_tax.cgi" METHOD="post"> + <FORM ACTION="report_tax.cgi" METHOD="GET"> Return <B>tax report</B> for period: <TABLE> <TR> diff --git a/httemplate/search/sqlradius.html b/httemplate/search/sqlradius.html index 20e8fb817..8f4878dbc 100644 --- a/httemplate/search/sqlradius.html +++ b/httemplate/search/sqlradius.html @@ -4,7 +4,7 @@ <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> ') %> -<FORM NAME="OneTrueForm" ACTION="sqlradius.cgi" METHOD="POST"> +<FORM NAME="OneTrueForm" ACTION="sqlradius.cgi" METHOD="GET"> <% #include( '/elements/table.html' ) %> <%= ntable('#cccccc') %> <TR> diff --git a/httemplate/search/svc_acct.html b/httemplate/search/svc_acct.html index 742360596..c504c2f34 100755 --- a/httemplate/search/svc_acct.html +++ b/httemplate/search/svc_acct.html @@ -7,7 +7,7 @@ Account Search </FONT> <BR><BR> - <FORM ACTION="svc_acct.cgi" METHOD="post"> + <FORM ACTION="svc_acct.cgi" METHOD="GET"> Search for <B>username</B>: <INPUT TYPE="text" NAME="username"> diff --git a/httemplate/search/svc_domain.html b/httemplate/search/svc_domain.html index 94bb9a66d..b759102f4 100755 --- a/httemplate/search/svc_domain.html +++ b/httemplate/search/svc_domain.html @@ -7,7 +7,7 @@ Domain Search </FONT> <BR><BR> - <FORM ACTION="svc_domain.cgi" METHOD="post"> + <FORM ACTION="svc_domain.cgi" METHOD="GET"> Search for <B>domain</B>: <INPUT TYPE="text" NAME="domain"> diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi index 1f05c2377..141661992 100755 --- a/httemplate/search/svc_www.cgi +++ b/httemplate/search/svc_www.cgi @@ -23,20 +23,19 @@ my $link = [ "${p}view/svc_www.cgi?", 'svcnum', ]; my $ulink = [ "${p}view/svc_acct.cgi?", 'usersvc', ]; -%> -<%= include( 'elements/search.html', - 'title' => 'Virtual Host Search Results', - 'name' => 'virtual hosts', - 'query' => $sql_query, - 'count_query' => $count_query, - 'header' => [ '#', 'Zone', 'User', ], - 'fields' => [ 'svcnum', - sub { $_[0]->domain_record->zone }, - sub { $_[0]->svc_acct->email }, - ], - 'links' => [ $link, - '', - $ulink, - ], - ) +%><%= include( 'elements/search.html', + 'title' => 'Virtual Host Search Results', + 'name' => 'virtual hosts', + 'query' => $sql_query, + 'count_query' => $count_query, + 'header' => [ '#', 'Zone', 'User', ], + 'fields' => [ 'svcnum', + sub { $_[0]->domain_record->zone }, + sub { $_[0]->svc_acct->email }, + ], + 'links' => [ $link, + '', + $ulink, + ], + ) %> diff --git a/httemplate/view/cust_bill-pdf.cgi b/httemplate/view/cust_bill-pdf.cgi index a72a60551..ce7ab0c5c 100755 --- a/httemplate/view/cust_bill-pdf.cgi +++ b/httemplate/view/cust_bill-pdf.cgi @@ -14,5 +14,4 @@ my $pdf = $cust_bill->print_pdf( '', $templatename); http_header('Content-Type' => 'application/pdf' ); http_header('Content-Length' => length($pdf) ); http_header('Cache-control' => 'max-age=60' ); -%> -<%= $pdf %> +%><%= $pdf %> diff --git a/httemplate/view/cust_bill-ps.cgi b/httemplate/view/cust_bill-ps.cgi index 8485a150f..e730a822a 100755 --- a/httemplate/view/cust_bill-ps.cgi +++ b/httemplate/view/cust_bill-ps.cgi @@ -10,5 +10,4 @@ my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); die "Invoice #$invnum not found!" unless $cust_bill; http_header('Content-Type' => 'application/postscript' ); -%> -<%= $cust_bill->print_ps( '', $templatename) %> +%><%= $cust_bill->print_ps( '', $templatename) %> |