diff options
Diffstat (limited to 'httemplate')
95 files changed, 2356 insertions, 5037 deletions
diff --git a/httemplate/autohandler b/httemplate/autohandler index a3f7eb008..2bd3adffd 100644 --- a/httemplate/autohandler +++ b/httemplate/autohandler @@ -9,7 +9,7 @@ if ( UNIVERSAL::can(dbh, 'sprintProfile') ) { if ( lc($r->content_type) eq 'text/html' ) { - $profile = '<PRE>'. encode_entities(dbh->sprintProfile()). + $profile = '<PRE>'. ("\n"x4096). encode_entities(dbh->sprintProfile()). #"\n\n". &sprintAutoProfile(). '</PRE>'; "\n\n". '</PRE>'; } diff --git a/httemplate/browse/agent.cgi b/httemplate/browse/agent.cgi index 05300d0bd..c5c992704 100755 --- a/httemplate/browse/agent.cgi +++ b/httemplate/browse/agent.cgi @@ -8,8 +8,6 @@ %search = ( 'disabled' => '' ); } - my $conf = new FS::Conf; - %> <%= header('Agent Listing', menubar( 'Main Menu' => $p, @@ -34,14 +32,9 @@ full offerings (via their type).<BR><BR> <TH COLSPAN=<%= ( $cgi->param('showdisabled') || !dbdef->table('agent')->column('disabled') ) ? 2 : 3 %>>Agent</TH> <TH>Type</TH> <TH>Customers</TH> - <TH><FONT SIZE=-1>Customer<BR>packages</FONT></TH> <TH>Reports</TH> <TH>Registration codes</TH> <TH>Prepaid cards</TH> - <% if ( $conf->config('ticket_system') ) { %> - <TH>Ticketing</TH> - <% } %> - <TH><FONT SIZE=-1>Payment Gateway Overrides</FONT></TH> <TH><FONT SIZE=-1>Freq.</FONT></TH> <TH><FONT SIZE=-1>Prog.</FONT></TH> </TR> @@ -57,8 +50,6 @@ foreach my $agent ( sort { my $cust_main_link = $p. 'search/cust_main.cgi?agentnum_on=1&'. 'agentnum='. $agent->agentnum; - my $cust_pkg_link = $p. 'search/cust_pkg.cgi?agentnum='. $agent->agentnum; - %> <TR> @@ -74,6 +65,7 @@ foreach my $agent ( sort { <TD><A HREF="<%=$p%>edit/agent_type.cgi?<%= $agent->typenum %>"><%= $agent->agent_type->atype %></A></TD> <TD> + <TABLE CELLSPACING=0 CELLPADDING=0> <TR> <TH ALIGN="right" WIDTH="40%"> @@ -121,44 +113,6 @@ foreach my $agent ( sort { </TD> <TD> - <TABLE CELLSPACING=0 CELLPADDING=0> - <TR> - <TH ALIGN="right" WIDTH="40%"> - <FONT COLOR="#00CC00"> - <%= my $num_active_pkg = $agent->num_active_cust_pkg %> - </FONT> - </TH> - <TD> - <% if ( $num_active_pkg ) { %> - <A HREF="<%= $cust_pkg_link %>&magic=active"><% } %>active<% if ( $num_active_pkg ) { %></A><% } %> - </TD> - </TR> - <TR> - <TH ALIGN="right" WIDTH="40%"> - <FONT COLOR="#FF9900"> - <%= my $num_susp_pkg = $agent->num_susp_cust_pkg %> - </FONT> - </TH> - <TD> - <% if ( $num_susp_pkg ) { %> - <A HREF="<%= $cust_pkg_link %>&magic=suspended"><% } %>suspended<% if ( $num_susp_pkg ) { %></A><% } %> - </TD> - </TR> - <TR> - <TH ALIGN="right" WIDTH="40%"> - <FONT COLOR="#FF0000"> - <%= my $num_cancel_pkg = $agent->num_cancel_cust_pkg %> - </FONT> - </TH> - <TD> - <% if ( $num_cancel_pkg ) { %> - <A HREF="<%= $cust_pkg_link %>&magic=cancelled"><% } %>cancelled<% if ( $num_cancel_pkg ) { %></A><% } %> - </TD> - </TR> - </TABLE> - </TD> - - <TD> <A HREF="<%= $p %>search/report_cust_pay.html?agentnum=<%= $agent->agentnum %>">Payments</A> <BR><A HREF="<%= $p %>search/report_cust_credit.html?agentnum=<%= $agent->agentnum %>">Credits</A> <BR><A HREF="<%= $p %>search/report_receivables.cgi?agentnum=<%= $agent->agentnum %>">A/R Aging</A> @@ -180,40 +134,6 @@ foreach my $agent ( sort { <BR><A HREF="<%=$p%>edit/prepay_credit.cgi?agentnum=<%= $agent->agentnum %>">Generate cards</A> </TD> - <% if ( $conf->config('ticket_system') ) { %> - - <TD> - <% if ( $agent->ticketing_queueid ) { %> - Queue: <%= $agent->ticketing_queueid %>: <%= $agent->ticketing_queue %><BR> - <% } %> - </TD> - - <% } %> - - <TD> - <TABLE CELLSPACING=0 CELLPADDING=0> - <% foreach my $override ( - # sort { } want taxclass-full stuff first? and default cards (empty cardtype) - qsearch('agent_payment_gateway', { 'agentnum' => $agent->agentnum } ) - ) { - %> - <TR> - <TD> - <%= $override->cardtype || 'Default' %> to <%= $override->payment_gateway->gateway_module %> (<%= $override->payment_gateway->gateway_username %>) - <%= $override->taxclass - ? ' for '. $override->taxclass. ' only' - : '' - %> - <FONT SIZE=-1><A HREF="<%=$p%>misc/delete-agent_payment_gateway.cgi?<%= 'XXXoverridenum' %>">(delete)</A></FONT> - </TD> - </TR> - <% } %> - <TR> - <TD><FONT SIZE=-1><A HREF="<%=$p%>edit/agent_payment_gateway.html?agentnum=<%= $agent->agentnum %>">(add override)</A></FONT></TD> - </TR> - </TABLE> - </TD> - <TD><%= $agent->freq %></TD> <TD><%= $agent->prog %></TD> diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 8d5b55451..ffa0d87c2 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -144,8 +144,9 @@ foreach my $part_pkg ( sort $sortby @part_pkg ) { <TD ROWSPAN=<%= $rowspan %>><%= $plandata %></TD> <% + my($pkg_svc); my($n)=""; - foreach my $pkg_svc ( @pkg_svc ) { + foreach $pkg_svc ( @pkg_svc ) { my($svcpart)=$pkg_svc->getfield('svcpart'); my($part_svc) = qsearchs('part_svc',{'svcpart'=> $svcpart }); print $n,qq!<TD><A HREF="${p}edit/part_svc.cgi?$svcpart">!, diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index a725dc051..ef0de13cc 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -1,11 +1,6 @@ +<!-- mason kludge --> <% -my %flag = ( - 'D' => 'Default', - 'F' => 'Fixed', - '' => '', -); - my %search; if ( $cgi->param('showdisabled') ) { %search = (); @@ -18,13 +13,18 @@ my @part_svc = qsearch('part_svc', \%search ); my $total = scalar(@part_svc); -my %num_active_cust_svc = map { $_->svcpart => $_->num_cust_svc } @part_svc; - -if ( $cgi->param('orderby') eq 'active' ) { +my %num_active_cust_svc = (); +if ( $cgi->param('active') ) { + my $active_sth = dbh->prepare( + 'SELECT COUNT(*) FROM cust_svc WHERE svcpart = ?' + ) or die dbh->errstr; + foreach my $part_svc ( @part_svc ) { + $active_sth->execute($part_svc->svcpart) or die $active_sth->errstr; + $num_active_cust_svc{$part_svc->svcpart} = + $active_sth->fetchrow_arrayref->[0]; + } @part_svc = sort { $num_active_cust_svc{$b->svcpart} <=> $num_active_cust_svc{$a->svcpart} } @part_svc; -} elsif ( $cgi->param('orderby') eq 'svc' ) { - @part_svc = sort { lc($a->svc) cmp lc($b->svc) } @part_svc; } %> @@ -55,23 +55,21 @@ function part_export_areyousure(href) { : do { $cgi->param('showdisabled', 1); '( <a href="'. $cgi->self_url. '">show disabled services</a> )'; } %> -<% $cgi->param('showdisabled', ( 1 ^ $cgi->param('showdisabled') ) ); %> <%= table() %> <TR> - <TH><A HREF="<%= do { $cgi->param('orderby', 'svcpart'); $cgi->self_url } %>">#</A></TH> - <% if ( $cgi->param('showdisabled') ) { %> - <TH>Status</TH> - <% } %> - <TH><A HREF="<%= do { $cgi->param('orderby', 'svc'); $cgi->self_url; } %>">Service</A></TH> + <TH COLSPAN=<%= $cgi->param('showdisabled') ? 2 : 3 %>>Service</TH> <TH>Table</TH> - <TH><A HREF="<%= do { $cgi->param('orderby', 'active'); $cgi->self_url; } %>"><FONT SIZE=-1>Customer<BR>Services</FONT></A></TH> +<% if ( $cgi->param('active') ) { %> + <TH><FONT SIZE=-1>Customer<BR>Services</FONT></TH> +<% } %> <TH>Export</TH> <TH>Field</TH> <TH COLSPAN=2>Modifier</TH> </TR> <% foreach my $part_svc ( @part_svc ) { - my $svcdb = $part_svc->svcdb; + my $hashref = $part_svc->hashref; + my $svcdb = $hashref->{svcdb}; my $svc_x = "FS::$svcdb"->new( { svcpart => $part_svc->svcpart } ); my @dfields = $svc_x->fields; push @dfields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge @@ -80,30 +78,25 @@ function part_export_areyousure(href) { or $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag } @dfields ; my $rowspan = scalar(@fields) || 1; - my $url = "${p}edit/part_svc.cgi?". $part_svc->svcpart; + my $url = "${p}edit/part_svc.cgi?$hashref->{svcpart}"; %> <TR> <TD ROWSPAN=<%= $rowspan %>><A HREF="<%= $url %>"> - <%= $part_svc->svcpart %></A></TD> -<% if ( $cgi->param('showdisabled') ) { %> + <%= $hashref->{svcpart} %></A></TD> +<% unless ( $cgi->param('showdisabled') ) { %> <TD ROWSPAN=<%= $rowspan %>> - <%= $part_svc->disabled - ? '<FONT COLOR="#FF0000"><B>Disabled</B></FONT>' - : '<FONT COLOR="#00CC00"><B>Enabled</B></FONT>' - %> - </TD> + <%= $hashref->{disabled} ? 'DISABLED' : '' %></TD> <% } %> <TD ROWSPAN=<%= $rowspan %>><A HREF="<%= $url %>"> - <%= $part_svc->svc %></A></TD> + <%= $hashref->{svc} %></A></TD> <TD ROWSPAN=<%= $rowspan %>> - <%= $svcdb %></TD> + <%= $hashref->{svcdb} %></TD> +<% if ( $cgi->param('active') ) { %> <TD ROWSPAN=<%= $rowspan %>> - <FONT COLOR="#00CC00"><B><%= $num_active_cust_svc{$part_svc->svcpart} %></B></FONT> <A HREF="<%=$p%>search/<%= $svcdb %>.cgi?svcpart=<%= $part_svc->svcpart %>">active</A> - <% if ( $num_active_cust_svc{$part_svc->svcpart} ) { %> - <BR><FONT SIZE="-1">[ <A HREF="<%=$p%>edit/bulk-cust_svc.html?svcpart=<%= $part_svc->svcpart %>">change</A> ]</FONT> - <% } %> + <FONT COLOR="#00CC00"><B><%= $num_active_cust_svc{$hashref->{svcpart}} %></B></FONT> <A HREF="<%=$p%>search/<%= $hashref->{svcdb} %>.cgi?svcpart=<%= $hashref->{svcpart} %>">active</A> </TD> +<% } %> <TD ROWSPAN=<%= $rowspan %>><%= itable() %> <% # my @part_export = @@ -122,11 +115,14 @@ map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export foreach my $field ( @fields ) { my $flag = $part_svc->part_svc_column($field)->columnflag; %> - <%= $n1 %> - <TD><%= $field %></TD> - <TD><%= $flag{$flag} %></TD> - <TD><%= $part_svc->part_svc_column($field)->columnvalue%></TD> + <%= $n1 %><TD><%= $field %></TD><TD> +<% if ( $flag eq "D" ) { print "Default"; } + elsif ( $flag eq "F" ) { print "Fixed"; } + elsif ( not $flag ) { } + else { print "(Unknown!)"; } +%> + </TD><TD><%= $part_svc->part_svc_column($field)->columnvalue%></TD> <% $n1="</TR><TR>"; } %> diff --git a/httemplate/browse/payment_gateway.html b/httemplate/browse/payment_gateway.html deleted file mode 100644 index bb7f31514..000000000 --- a/httemplate/browse/payment_gateway.html +++ /dev/null @@ -1,70 +0,0 @@ -<% - - my %search; - if ( $cgi->param('showdisabled') ) { - %search = (); - } else { - %search = ( 'disabled' => '' ); - } - -%> -<%= header('Payment gateways', menubar( - 'Main Menu' => $p, - 'Agents' => $p. 'browse/agent.cgi', -)) %> - -<A HREF="<%= $p %>edit/payment_gateway.html"><I>Add a new payment gateway</I></A><BR><BR> - -<%= $cgi->param('showdisabled') - ? do { $cgi->param('showdisabled', 0); - '( <a href="'. $cgi->self_url. '">hide disabled gateways</a> )'; } - : do { $cgi->param('showdisabled', 1); - '( <a href="'. $cgi->self_url. '">show disabled gateways</a> )'; } -%> - -<%= table() %> -<TR> - <TH COLSPAN=<%= $cgi->param('showdisabled') ? 1 : 2 %>>#</TH> - <TH>Gateway</TH> - <TH>Username</TH> - <TH>Password</TH> - <TH>Action</TH> - <TH>Options</TH> -</TR> - -<% foreach my $payment_gateway ( qsearch( 'payment_gateway', \%search ) ) { %> - - <TR> - <TD><%= $payment_gateway->gatewaynum %></TD> - <% if ( !$cgi->param('showdisabled') ) { %> - <TD><%= $payment_gateway->disabled ? 'DISABLED' : '' %></TD> - <% } %> - <TD><%= $payment_gateway->gateway_module %> - <%= !$payment_gateway->disabled - ? '<FONT SIZE="-1"> <A HREF="misc/disable-payment_gateway.cgi?'. $payment_gateway->gatewaynum.'">(disable)</A></FONT>' - : '' - %> - </TD> - <TD><%= $payment_gateway->gateway_username %></TD> - <TD> - </TD> - <TD><%= $payment_gateway->gateway_action %></TD> - <TD> - <TABLE CELLSPACING=0 CELLPADDING=0> - <% my %options = $payment_gateway->options; - foreach my $option ( keys %options ) { - %> - <TR> - <TH><%= $option %>:</TH> - <TD><%= $options{$option} %></TD> - </TR> - <% } %> - </TABLE> - </TD> - </TR> - -<% } %> - -</TABLE> -</BODY> -</HTML> - diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index 8011e7697..9a0006792 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -36,35 +36,19 @@ <% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { my $n = 0; %> <% if ( $type eq '' ) { %> - <tr> - <td><font color="#ff0000">no type</font></td> - </tr> + <tr><td><font color="#ff0000">no type</font></td></tr> <% } elsif ( $type eq 'textarea' || $type eq 'editlist' || $type eq 'selectmultiple' ) { %> - <tr> - <td bgcolor="#ffffff"> + <tr><td bgcolor="#ffffff"> <pre> <%= encode_entities(join("\n", $conf->config($i->key) ) ) %> </pre> - </td> - </tr> + </td></tr> <% } elsif ( $type eq 'checkbox' ) { %> - <tr> - <td bgcolor="#<%= $conf->exists($i->key) ? '00ff00">YES' : 'ff0000">NO' %></td> - </tr> + <tr><td bgcolor="#<%= $conf->exists($i->key) ? '00ff00">YES' : 'ff0000">NO' %></td></tr> <% } elsif ( $type eq 'text' || $type eq 'select' ) { %> - <tr> - <td bgcolor="#ffffff"> - <%= $conf->exists($i->key) ? $conf->config($i->key) : '' %> - </td></tr> - <% } elsif ( $type eq 'select-sub' ) { %> - <tr> - <td bgcolor="#ffffff"> - <%= $conf->config($i->key) %>: - <%= &{ $i->option_sub }( $conf->config($i->key) ) %> - </td> - </tr> + <tr><td bgcolor="#ffffff"><%= $conf->exists($i->key) ? $conf->config($i->key) : '' %></td></tr> <% } else { %> <tr><td> <font color="#ff0000">unknown type <%= $type %></font> diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi index ff29d8578..409869e11 100644 --- a/httemplate/config/config.cgi +++ b/httemplate/config/config.cgi @@ -73,21 +73,6 @@ function SafeOnsubmit() { <option value=<%= $conf->config($i->key) %> SELECTED><%= $conf->config($i->key) %> <% } %> </select> - <% } elsif ( $type eq 'select-sub' ) { %> - <select name="<%= $i->key. $n %>"> - <option value=""> - <% my %options = &{$i->options_sub}; - my @options = sort { $a <=> $b } keys %options; - my %saw; - foreach my $value ( @options ) { - local($^W)=0; next if $saw{$value}++; - %> - <option value="<%= $value %>"<%= $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><%= $value %>: <%= $options{$value} %> - <% } %> - <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! exists $options{$conf->config($i->key)} ) { %> - <option value=<%= $conf->config($i->key) %> SELECTED><%= $conf->config($i->key) %>: <%= &{ $i->option_sub }( $conf->config($i->key) ) %> - <% } %> - </select> <% } elsif ( $type eq 'editlist' ) { %> <script> function doremove<%= $i->key. $n %>() { diff --git a/httemplate/docs/ach.html b/httemplate/docs/ach.html index b8a17c87d..b79df78fe 100644 --- a/httemplate/docs/ach.html +++ b/httemplate/docs/ach.html @@ -4,7 +4,9 @@ Electronic check (ACH) information </TITLE> </HEAD> - <BODY BGCOLOR="#ffffff"> + <BODY BGCOLOR="#e8e8e8"> <IMG BORDER=0 SRC="../images/ach.png"> + <BR> + <CENTER><A HREF="javascript:close()">(close window)</A></CENTER> </BODY> </HTML> diff --git a/httemplate/docs/admin.html b/httemplate/docs/admin.html index 9ce259c2b..50beafe78 100755 --- a/httemplate/docs/admin.html +++ b/httemplate/docs/admin.html @@ -42,8 +42,7 @@ sources</u> and <u>Add a new advertising source</u>. <li>Click on <u>New Customer</u> and create a new customer for your system - accounts with billing type <b>Complimentary</b>. Leave the <i>First - package</i> dropdown set to <b>(none)</b>. + accounts with billing type <b>Complimentary</b>. <li>From the Customer View screen of the newly created customer, order the package you defined above. diff --git a/httemplate/docs/cvv2.html b/httemplate/docs/cvv2.html index 767098537..fe8a17f6f 100644 --- a/httemplate/docs/cvv2.html +++ b/httemplate/docs/cvv2.html @@ -20,5 +20,6 @@ <IMG BORDER=0 ALT="American Express" SRC="../images/cvv2_amex.png"> </TD> </TABLE> + <CENTER><A HREF="javascript:close()">(close window)</A></CENTER> </BODY> </HTML> diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index 1f80db1a7..d742ddb11 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -14,14 +14,13 @@ Before installing, you need: <li>Optional, enables typeset invoices: teTeX and Ghostscript (included with most distributions). <li>A <b>transactional</b> database engine <a href="http://search.cpan.org/search?mode=module&query=DBD%3A%3A">supported</a> by Perl's <a href="http://dbi.perl.org">DBI</a>. <ul> - <li><a href="http://www.postgresql.org/">PostgreSQL</a> is recommended (v7.2 or later, 7.4 or later recommended). + <li><a href="http://www.postgresql.org/">PostgreSQL</a> is recommended (v7.2 or later). <li> <a href="http://www.mysql.com/">MySQL</a> is <b>not currently supported</b>. <FONT SIZE="-1"><i>Developers intersted in maintaining MySQL support are welcome to ask on the -devel mailing list; many things work, but MySQL support needs a maintainer to update it for recent (and future) changes.</i></FONT> <!-- <li><a href="http://www.mysql.com/">MySQL</a> <b>MINIMUM VERSION 4.1</b> is untested but may work. Versions before 4.1 do not support standard SQL subqueries and are <b>NOT SUPPORTED</b>. <!-- <li>MySQL has been reported to work. MySQL's default <a href="http://www.mysql.com/doc/M/y/MyISAM.html">MyISAM</a> and <a href="http://www.mysql.com/doc/I/S/ISAM.html">ISAM</a> table types are not supported. You <b>must</b> use one of the new <a href="http://www.mysql.com/doc/T/a/Table_types.html">transaction-safe table types</a> such as <a href="http://www.mysql.com/doc/I/n/InnoDB.html">InnoDB</a>. Set it as the default table type using the <code>--default-table-type=InnoDB</code> <a href="http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#Command-line_options">mysqld command-line option</a> or by setting <code>default-table-type=InnoDB</code> in the <a href="http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#Option_files">my.cnf option file</a>. --> </ul> - <i>Note: the above only applies to the database used by the Freeside software itself. Freeside can integrate with RADIUS and other servers running MySQL <!--(any version)--> or any other DBI-supported database.</i> <li>Perl modules (<a href="http://search.cpan.org/~andk/CPAN/lib/CPAN.pm">CPAN</a> will query, download and build perl modules automatically) <ul> <!-- <li><a href="http://search.cpan.org/dist/Array-PrintCols">Array-PrintCols</a> @@ -62,16 +61,15 @@ Before installing, you need: <li><a href="http://search.cpan.org/dist/Chart">Chart</a> <li><a href="http://search.cpan.org/dist/Crypt-PasswdMD5">Crypt::PasswdMD5</a> <li><a href="http://search.cpan.org/dist/Locale-SubCountry">Locale::SubCountry</a> + <li><a href="http://search.cpan.org/dist/JavaScript-RPC">JavaScript::RPC (JavaScript::RPC::Server::CGI)</a> <li><a href="http://search.cpan.org/dist/Frontier-RPC">Frontier::RPC</a> <li><a href="http://search.cpan.org/dist/Text-CSV_XS">Text::CSV_XS</a> <li><a href="http://search.cpan.org/dist/Spreadsheet-WriteExcel">Spreadsheet::WriteExcel</a> <li><a href="http://search.cpan.org/dist/IO-stringy">IO-stringy (IO::Scalar)</a> <li><a href="http://search.cpan.org/dist/Frontier-RPC">Frontier::RPC (Frontier::RPC2)</a> <li><a href="http://search.cpan.org/dist/MIME-tools">MIME::Entity (MIME-tools)</a> - <li><a href="http://search.cpan.org/dist/IPC-Run3">IPC::Run3</a> - <li><a href="http://search.cpan.org/dist/Term-ReadKey">Term::ReadKey</a> <!-- <li><a href="http://search.cpan.org/dist/Crypt-YAPassGen">Crypt::YAPassGen</a> --> - <li><a href="http://search.cpan.org/search?mode=module&query=MIME::Entity">Fax::Hylafax::Client</a> <i>(Required if using FAX invoice destinations)</i> + <li><a href="http://search.cpan.org/search?mode=module&query=MIME::Entity">Fax::Hylafax::Client</a> <i>(Required if using FAX invoice destinations</i> <li><a href="http://search.cpan.org/dist/ApacheDBI">Apache::DBI</a> <i>(optional but recommended for better webinterface performance)</i> </ul> </ul> @@ -186,16 +184,12 @@ require valid-user <ul> <li>First user:<font size="-1"> <pre>$ su -# <a href="man/bin/freeside-adduser.html">freeside-adduser</a> -c -h /usr/local/etc/freeside/htpasswd <i>username</i></pre></font> +$ <a href="man/bin/freeside-adduser.html">freeside-adduser</a> -c -h /usr/local/etc/freeside/htpasswd <i>username</i></pre></font> <li>Additional users:<font size="-1"> <pre>$ su -# <a href="man/bin/freeside-adduser.html">freeside-adduser</a> -h /usr/local/etc/freeside/htpasswd <i>username</i></pre></font> +$ <a href="man/bin/freeside-adduser.html">freeside-adduser</a> -h /usr/local/etc/freeside/htpasswd <i>username</i></pre></font> </ul> <i>(using other auth types, add each user to your <a href="http://httpd.apache.org/docs/misc/FAQ.html#user-authentication">Apache authentication</a> and then run: <tt>freeside-adduser <b>username</b></tt>)</i> - <li>Create the Freeside system users: -<pre>$ su -# <a href="man/bin/freeside-adduser.html">freeside-adduser</a> fs_queue -# <a href="man/bin/freeside-adduser.html">freeside-adduser</a> fs_selfservice</pre> <li>As the freeside UNIX user, run <tt>freeside-setup <b>username</b></tt> to create the database tables, passing the username of a Freeside user you created above: <pre> $ su freeside diff --git a/httemplate/docs/schema.dia b/httemplate/docs/schema.dia Binary files differindex e00f59ce1..746561550 100644 --- a/httemplate/docs/schema.dia +++ b/httemplate/docs/schema.dia diff --git a/httemplate/docs/selfservice.html b/httemplate/docs/selfservice.html index 9dc8f2a5e..674b1fb6e 100644 --- a/httemplate/docs/selfservice.html +++ b/httemplate/docs/selfservice.html @@ -21,9 +21,7 @@ machine, not the backend Freeside server. On the public machine, install: Then: <ul> <li>Set the <a href="../config/config.cgi#unclassified"><i>signup_server-default_agentnum</i></a> configuration value to a default <a href="../browse/agent.cgi">agent number</a>. - <li>Set the <a href="../config/config.cgi#unclassified"><i>signup_server-default_refnum</i></a> configuration value to a default <a href="../browse/part_referral.cgi">advertising source</a>. - <li>Set the <a href="../config/config.cgi#unclassified"><i>signup_server-payby</i></a> configuration value to the acceptable payment types for signups. - <li>Set the <a href="../config/config.cgi#unclassified"><i>signup_server-realtime</i></a> configuration value to run billing for signups immediately. + <li>Set the <a href="../config/config.cgi#unclassified"><i>signup_server-default_refnum</i></a> to a default <a href="../browse/part_referral.cgi">advertising source</a>. <li>Add the user `freeside' to the the external machine. <li>Copy or symlink the <code>fs_selfservice/FS-SelfService/cgi/</code> directory into the web server's document space. Optionally, customize the .html templates. "Entry points" (useful places to link to) are: <ul> diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html index ac2c6238d..1faaedee0 100644 --- a/httemplate/docs/upgrade10.html +++ b/httemplate/docs/upgrade10.html @@ -5,40 +5,344 @@ NOTE: Version numbering has been simplified. 1.5.7 is the version after 1.5.0pre6. It is still a development version - releases with odd numbered middle parts (NN in x.NN.x) are development versions, like Perl or Linux. -If migrating from 1.5.7, see README.1.5.8 instead - If migrating from 1.5.0pre6, see README.1.5.7 instead install DBD::Pg 1.32, 1.41 or later (not 1.40) (or, if you're using a Perl version before 5.6, you could try installing DBD::Pg 1.22 with <a href="http://420.am/~ivan/DBD-Pg-1.22-fixvercmp.patch">this patch</a> and commenting out the "use DBD::Pg 1.32" at the top of DBIx/DBSchema/DBD/Pg.pm) -install DBIx::DBSchema 0.27 (or later) - (if you are running Pg version 7.2.x or earlier, install at least - DBIx::DBSchema 0.29) +install DBIx::DBSchema 0.26 install Net::SSH 0.08 -install HTML::Widgets::SelectLayers 0.05 -install Business::CreditCard 0.28 - - If using Apache::ASP, add PerlSetVar RequestBinaryRead Off and PerlSetVar IncludesDir /your/freeside/document/root/ to your Apache configuration and make sure you are using Apache::ASP minimum version 2.55. - In httpd.conf, change <Files ~ \.cgi> to <Files ~ (\.cgi|\.html)> - 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, Text::CSV_XS, +install NetAddr::IP, Chart::Base, Locale::SubCountry, +JavaScript::RPC (JavaScript::RPC::Server::CGI), Text::CSV_XS, Spreadsheet::WriteExcel, IO-stringy (IO::Scalar), Frontier::RPC -(Frontier::RPC2), MIME::Entity (MIME-tools), IPC::Run3, Net::Whois::Raw, -JSON and Term::ReadKey +(Frontier::RPC2), MIME::Entity (MIME-tools) and IPC::Run3 <!-- 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' ); +CREATE TABLE cust_bill_pkg_detail ( + detailnum serial, + pkgnum int NOT NULL, + invnum int NOT NULL, + detail varchar(80), + PRIMARY KEY (detailnum) +); +CREATE INDEX cust_bill_pkg_detail1 ON cust_bill_pkg_detail ( pkgnum, invnum ); + +CREATE TABLE part_virtual_field ( + vfieldpart int NOT NULL, + dbtable varchar(32) NOT NULL, + name varchar(32) NOT NULL, + check_block text, + list_source text, + length integer, + label varchar(80), + PRIMARY KEY (vfieldpart) +); + +CREATE TABLE virtual_field ( + recnum integer NOT NULL, + vfieldpart integer NOT NULL, + value varchar(128) NOT NULL, + PRIMARY KEY (vfieldpart, recnum) +); + +CREATE TABLE router ( + routernum serial, + routername varchar(80), + svcnum int, + PRIMARY KEY (routernum) +); + +CREATE TABLE part_svc_router ( + svcrouternum serial, + svcpart int NOT NULL, + routernum int NOT NULL, + PRIMARY KEY (svcrouternum) +); + +CREATE TABLE addr_block ( + blocknum serial, + routernum int NOT NULL, + ip_gateway varchar(15) NOT NULL, + ip_netmask int NOT NULL, + PRIMARY KEY (blocknum) +); +CREATE UNIQUE INDEX addr_block1 ON addr_block ( blocknum, routernum ); + +CREATE TABLE svc_broadband ( + svcnum int NOT NULL, + blocknum int NOT NULL, + speed_up int NOT NULL, + speed_down int NOT NULL, + ip_addr varchar(15), + PRIMARY KEY (svcnum) +); + +CREATE TABLE acct_snarf ( + snarfnum serial, + svcnum int NOT NULL, + machine varchar(255) NULL, + protocol varchar(80) NULL, + username varchar(80) NULL, + _password varchar(80) NULL, + PRIMARY KEY (snarfnum) +); +CREATE INDEX acct_snarf1 ON acct_snarf ( svcnum ); + +CREATE TABLE svc_external ( + svcnum int NOT NULL, + id int, + title varchar(80), + PRIMARY KEY (svcnum) +); + +<!-- +CREATE TABLE part_pkg_temp ( + pkgpart serial NOT NULL, + pkg varchar(80) NOT NULL, + "comment" varchar(80) NOT NULL, + setup text NULL, + freq varchar(80) NOT NULL, + recur text NULL, + setuptax char(1) NULL, + recurtax char(1) NULL, + plan varchar(80) NULL, + plandata text NULL, + disabled char(1) NULL, + taxclass varchar(80) NULL, + PRIMARY KEY (pkgpart) +); +INSERT INTO part_pkg_temp SELECT * from part_pkg; +DROP TABLE part_pkg; +ALTER TABLE part_pkg_temp RENAME TO part_pkg; +CREATE INDEX part_pkg1 ON part_pkg(disabled); + +On modern Pg: +ALTER TABLE part_pkg DROP CONSTRAINT part_pkg_temp_pkey; +ALTER TABLE part_pkg ADD PRIMARY KEY (pkgpart); +select setval('public.part_pkg_temp_pkgpart_seq', ( select max(pkgpart) from part_pkg) ); + +Or on Pg versions that don't support DROP CONSTRAINT and ADD PRIMARY KEY (tested on 7.1 and 7.2 so far): +DROP INDEX part_pkg_temp_pkey; +CREATE UNIQUE INDEX part_pkg_pkey ON part_pkg (pkgpart); +probably this one?: select setval('part_pkg_temp_pkgpart_seq', ( select max(pkgpart) from part_pkg) ); +probably not this one?: select setval('part_pkg_pkgpart_seq', ( select max(pkgpart) from part_pkg) ); + +CREATE TABLE h_part_pkg_temp ( + historynum serial NOT NULL, + history_date int, + history_user varchar(80) NOT NULL, + history_action varchar(80) NOT NULL, + pkgpart int NOT NULL, + pkg varchar(80) NOT NULL, + "comment" varchar(80) NOT NULL, + setup text NULL, + freq varchar(80) NOT NULL, + recur text NULL, + setuptax char(1) NULL, + recurtax char(1) NULL, + plan varchar(80) NULL, + plandata text NULL, + disabled char(1) NULL, + taxclass varchar(80) NULL, + PRIMARY KEY (historynum) +); +INSERT INTO h_part_pkg_temp SELECT * from h_part_pkg; +DROP TABLE h_part_pkg; +ALTER TABLE h_part_pkg_temp RENAME TO h_part_pkg; +CREATE INDEX h_part_pkg1 ON h_part_pkg(disabled); + +On modern Pg: +ALTER TABLE h_part_pkg DROP CONSTRAINT h_part_pkg_temp_pkey; +ALTER TABLE h_part_pkg ADD PRIMARY KEY (historynum); +select setval('public.h_part_pkg_temp_historynum_seq', ( select max(historynum) from h_part_pkg) ); + +Or on Pg versions that don't support DROP CONSTRAINT and ADD PRIMARY KEY (tested on 7.1 and 7.2 so far): +DROP INDEX h_part_pkg_temp_pkey; +CREATE UNIQUE INDEX h_part_pkg_pkey ON h_part_pkg (historynum); +probably this one?: select setval('h_part_pkg_temp_historynum_seq', ( select max(historynum) from h_part_pkg) ); +probably not this one?: select setval('h_part_pkg_historynum_seq', ( select max(historynum) from h_part_pkg) ); +-->ALTER TABLE part_pkg ADD COLUMN taxclass varchar(80) NULL; +ALTER TABLE h_part_pkg ADD COLUMN taxclass varchar(80) NULL; + +CREATE TABLE cust_pay_refund ( + payrefundnum serial NOT NULL, + paynum int NOT NULL, + refundnum int NOT NULL, + _date int NOT NULL, + amount decimal(10,2) NOT NULL, + PRIMARY KEY (payrefundnum) +); +CREATE INDEX cust_pay_refund1 ON cust_pay_refund(paynum); +CREATE INDEX cust_pay_refund2 ON cust_pay_refund(refundnum); + +CREATE TABLE cust_pay_void ( + paynum int NOT NULL, + custnum int NOT NULL, + paid decimal(10,2) NOT NULL, + _date int, + payby char(4) NOT NULL, + payinfo varchar(80), + paybatch varchar(80), + closed char(1), + void_date int, + reason varchar(80), + otaker varchar(32) NOT NULL, + PRIMARY KEY (paynum) +); +CREATE INDEX cust_pay_void1 ON cust_pay_void(custnum); + +CREATE TABLE part_pkg_option ( + optionnum serial, + pkgpart int not null, + optionname varchar(80) not null, + optionvalue text NULL, + PRIMARY KEY (optionnum) +); +CREATE INDEX part_pkg_option1 ON part_pkg_option ( pkgpart ); +CREATE INDEX part_pkg_option2 ON part_pkg_option ( optionname ); + +CREATE TABLE rate ( + ratenum serial NOT NULL, + ratename varchar(80) NOT NULL, + PRIMARY KEY (ratenum) +); + +CREATE TABLE rate_detail ( + ratedetailnum serial NOT NULL, + ratenum int NOT NULL, + orig_regionnum int NULL, + dest_regionnum int NOT NULL, + min_included int NOT NULL, + min_charge decimal(10,2) NOT NULL, + sec_granularity int NOT NULL, + PRIMARY KEY (ratedetailnum) +); +CREATE UNIQUE INDEX rate_detail1 ON rate_detail ( ratenum, orig_regionnum, dest_regionnum ); + +CREATE TABLE rate_region ( + regionnum serial NOT NULL, + regionname varchar(80) NOT NULL, + PRIMARY KEY (regionnum) +); + +CREATE TABLE rate_prefix ( + prefixnum serial NOT NULL, + regionnum int NOT NULL, + countrycode varchar(3) NOT NULL, + npa varchar(6) NULL, + nxx varchar(3) NULL, + PRIMARY KEY (prefixnum) +); +CREATE INDEX rate_prefix1 ON rate_prefix ( countrycode ); +CREATE INDEX rate_prefix2 ON rate_prefix ( regionnum ); + +CREATE TABLE reg_code ( + codenum serial NOT NULL, + code varchar(80) NOT NULL, + agentnum int NOT NULL, + PRIMARY KEY (codenum) +); +CREATE UNIQUE INDEX reg_code1 ON reg_code ( agentnum, code ); +CREATE INDEX reg_code2 ON reg_code ( agentnum ); + +CREATE TABLE reg_code_pkg ( + codepkgnum serial, + codenum int NOT NULL, + pkgpart int NOT NULL, + PRIMARY KEY (codepkgnum) +); +CREATE UNIQUE INDEX reg_code_pkg1 ON reg_code_pkg ( codenum, pkgpart ); +CREATE INDEX reg_code_pkg2 ON reg_code_pkg ( codenum ); + +CREATE TABLE clientapi_session ( + sessionnum serial NOT NULL, + sessionid varchar(80) NOT NULL, + namespace varchar(80) NOT NULL, + PRIMARY KEY (sessionnum) +); +CREATE UNIQUE INDEX clientapi_session1 ON clientapi_session ( sessionid, namespace ); + +CREATE TABLE clientapi_session_field ( + fieldnum serial NOT NULL, + sessionnum int NOT NULL, + fieldname varchar(80) NOT NULL, + fieldvalue text NULL, + PRIMARY KEY (fieldnum) +); +CREATE UNIQUE INDEX clientapi_session_field1 ON clientapi_session_field ( sessionnum, fieldname ); + DROP INDEX cust_bill_pkg1; +ALTER TABLE cust_bill_pkg ADD itemdesc varchar(80) NULL; +ALTER TABLE h_cust_bill_pkg ADD itemdesc varchar(80) NULL; +ALTER TABLE cust_main_county ADD taxname varchar(80) NULL; +ALTER TABLE h_cust_main_county ADD taxname varchar(80) NULL; +ALTER TABLE cust_main_county ADD setuptax char(1) NULL; +ALTER TABLE h_cust_main_county ADD setuptax char(1) NULL; +ALTER TABLE cust_main_county ADD recurtax char(1) NULL; +ALTER TABLE h_cust_main_county ADD recurtax char(1) NULL; +ALTER TABLE cust_pkg ADD last_bill int NULL; +ALTER TABLE h_cust_pkg ADD last_bill int NULL; +ALTER TABLE agent ADD disabled char(1) NULL; +ALTER TABLE h_agent ADD disabled char(1) NULL; +ALTER TABLE agent ADD username varchar(80) NULL; +ALTER TABLE h_agent ADD username varchar(80) NULL; +ALTER TABLE agent ADD _password varchar(80) NULL; +ALTER TABLE h_agent ADD _password varchar(80) NULL; +ALTER TABLE cust_main ADD paycvv varchar(512) NULL; +ALTER TABLE h_cust_main ADD paycvv varchar(512) NULL; +ALTER TABLE cust_main ADD paymask varchar(80) NULL; +ALTER TABLE h_cust_main ADD paymask varchar(80) NULL; +ALTER TABLE part_referral ADD disabled char(1) NULL; +ALTER TABLE h_part_referral ADD disabled char(1) NULL; +CREATE INDEX part_referral1 ON part_referral ( disabled ); +ALTER TABLE pkg_svc ADD primary_svc char(1) NULL; +ALTER TABLE h_pkg_svc ADD primary_svc char(1) NULL; +ALTER TABLE svc_forward ADD src varchar(255) NULL; +ALTER TABLE h_svc_forward ADD src varchar(255) NULL; +ALTER TABLE part_pkg ADD promo_code varchar(80) NULL; +ALTER TABLE h_part_pkg ADD promo_code varchar(80) NULL; +CREATE INDEX part_pkg2 ON part_pkg ( promo_code ); +CREATE INDEX h_part_pkg2 ON h_part_pkg ( promo_code ); +ALTER TABLE prepay_credit ADD agentnum integer NULL; +ALTER TABLE h_prepay_credit ADD agentnum integer NULL; + +ALTER TABLE type_pkgs ADD typepkgnum int; +ALTER TABLE type_pkgs ALTER COLUMN typepkgnum SET DEFAULT nextval('public.type_pkgs_typepkgnum_seq'::text); +CREATE SEQUENCE type_pkgs_typepkgnum_seq; +UPDATE type_pkgs SET typepkgnum = nextval('public.type_pkgs_typepkgnum_seq'::text) WHERE typepkgnum IS NULL; +ALTER TABLE type_pkgs ALTER typepkgnum SET NOT NULL; +ALTER TABLE type_pkgs ADD PRIMARY KEY (typepkgnum); +ALTER TABLE h_type_pkgs ADD typepkgnum int; + +ALTER TABLE cust_bill_pkg ADD billpkgnum int; +ALTER TABLE cust_bill_pkg ALTER COLUMN billpkgnum SET DEFAULT nextval('public.cust_bill_pkg_billpkgnum_seq'::text); +CREATE SEQUENCE cust_bill_pkg_billpkgnum_seq; +UPDATE cust_bill_pkg SET billpkgnum = nextval('public.cust_bill_pkg_billpkgnum_seq'::text) WHERE billpkgnum IS NULL; +ALTER TABLE cust_bill_pkg ALTER billpkgnum SET NOT NULL; +ALTER TABLE cust_bill_pkg ADD PRIMARY KEY (billpkgnum); +ALTER TABLE h_cust_bill_pkg ADD billpkgnum int; + +ALTER TABLE pkg_svc ADD pkgsvcnum int; +ALTER TABLE pkg_svc ALTER COLUMN pkgsvcnum SET DEFAULT nextval('public.pkg_svc_pkgsvcnum_seq'::text); +CREATE SEQUENCE pkg_svc_pkgsvcnum_seq; +UPDATE pkg_svc SET pkgsvcnum = nextval('public.pkg_svc_pkgsvcnum_seq'::text) WHERE pkgsvcnum IS NULL; +ALTER TABLE pkg_svc ALTER pkgsvcnum SET NOT NULL; +ALTER TABLE pkg_svc ADD PRIMARY KEY (pkgsvcnum); +ALTER TABLE h_pkg_svc ADD pkgsvcnum int; + On recent Pg versions: ALTER TABLE cust_main ALTER COLUMN payinfo varchar(512) NULL; ALTER TABLE h_cust_main ALTER COLUMN payinfo varchar(512) NULL; Or on older Pg versions that don't support altering columns directly: -(dump database, edit & reload) + On recent Pg versions: @@ -64,30 +368,26 @@ If you created your database with a version before 1.4.2, dump database, edit: - domain_record and h_domain_record: increase recdata from 80 to 255 then reload -mandatory again: +optionally: -make install-perl-modules to install the new libraries and CLI utilities -run "freeside-upgrade username" to create the remaining new tables and columns + CREATE INDEX cust_main6 ON cust_main ( daytime ); + CREATE INDEX cust_main7 ON cust_main ( night ); + CREATE INDEX cust_main8 ON cust_main ( fax ); + CREATE INDEX cust_main9 ON cust_main ( ship_daytime ); + CREATE INDEX cust_main10 ON cust_main ( ship_night ); + CREATE INDEX cust_main11 ON cust_main ( ship_fax ); + CREATE INDEX agent2 ON agent ( disabled ); + CREATE INDEX part_bill_event2 ON part_bill_event ( disabled ); + CREATE INDEX cust_pay4 ON cust_pay (_date); -optionally: + serial columns -CREATE INDEX cust_main4 ON cust_main ( daytime ); -CREATE INDEX cust_main5 ON cust_main ( night ); -CREATE INDEX cust_main6 ON cust_main ( fax ); -CREATE INDEX cust_main7 ON cust_main ( refnum ); -CREATE INDEX cust_main8 ON cust_main ( county ); -CREATE INDEX cust_main9 ON cust_main ( state ); -CREATE INDEX cust_main10 ON cust_main ( country ); -CREATE INDEX cust_main11 ON cust_main ( ship_last ); -CREATE INDEX cust_main12 ON cust_main ( ship_company ); -CREATE INDEX cust_main13 ON cust_main ( ship_daytime ); -CREATE INDEX cust_main14 ON cust_main ( ship_night ); -CREATE INDEX cust_main15 ON cust_main ( ship_fax ); -CREATE INDEX agent2 ON agent ( disabled ); -CREATE INDEX part_bill_event2 ON part_bill_event ( disabled ); -CREATE INDEX cust_pay4 ON cust_pay (_date); -CREATE INDEX part_referral1 ON part_referral ( disabled ); -CREATE INDEX part_pkg2 ON part_pkg ( promo_code ); -CREATE INDEX h_part_pkg2 ON h_part_pkg ( promo_code ); +mandatory again: + +dbdef-create username +create-history-tables username cust_bill_pkg_detail router part_svc_router addr_block svc_broadband acct_snarf svc_external cust_pay_refund cust_pay_void part_pkg_option rate rate_detail rate_region rate_prefix reg_code reg_code_pkg +dbdef-create username + +apache - fix <Files> sections to include .html also </pre> diff --git a/httemplate/edit/REAL_cust_pkg.cgi b/httemplate/edit/REAL_cust_pkg.cgi index 78dd0fafa..2f6be7cad 100755 --- a/httemplate/edit/REAL_cust_pkg.cgi +++ b/httemplate/edit/REAL_cust_pkg.cgi @@ -1,4 +1,6 @@ +<!-- mason kludge --> <% +# <!-- $Id: REAL_cust_pkg.cgi,v 1.9 2005-02-27 11:05:35 ivan Exp $ --> my $error =''; my $pkgnum = ''; @@ -31,20 +33,17 @@ if ( $error ) { } #my $custnum = $cust_pkg->getfield('custnum'); -%> - -<%= header('Customer package - Edit dates') %> -<% -#, menubar( +print header('Package Edit'); #, menubar( # "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum", # 'Main Menu' => popurl(2) #)); + %> -<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> <% @@ -58,106 +57,67 @@ my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment')); my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill')); my $otaker = $cust_pkg->getfield('otaker'); -%> - -<FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> - -<% if ( $error ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $error %></FONT> -<% } %> +print '<FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST">', qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!; -<% +print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: $error</FONT>! + if $error; #my $format = "%c %z (%Z)"; my $format = "%m/%d/%Y %T %z (%Z)"; -#false laziness w/view/cust_main/packages.html -#my( $billed_or_prepaid, -my( $last_bill_or_renewed, $next_bill_or_prepaid_until ); -unless ( $part_pkg->is_prepaid ) { - #$billed_or_prepaid = 'billed'; - $last_bill_or_renewed = 'Last bill'; - $next_bill_or_prepaid_until = 'Next bill'; -} else { - #$billed_or_prepaid = 'prepaid'; - $last_bill_or_renewed = 'Renewed'; - $next_bill_or_prepaid_until = 'Prepaid until'; -} +print ntable("#cccccc",2), + '<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">', + $pkgnum, '</TD></TR>', + '<TR><TD ALIGN="right">Package</TD><TD BGCOLOR="#ffffff">', + $pkg, '</TD></TR>', + '<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">', + $comment, '</TD></TR>', + '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">', + $otaker, '</TD></TR>', + '<TR><TD ALIGN="right">Setup date</TD><TD>'. + '<INPUT TYPE="text" NAME="setup" SIZE=32 ID="setup_text" VALUE="', + ( $setup ? time2str($format, $setup) : "" ), '">'. + ' <IMG SRC="../images/calendar.png" ID="setup_button" STYLE="cursor: pointer" TITLE="Select date">'. + '</TD></TR>'; + +print '<TR><TD ALIGN="right">Last bill date</TD><TD>', + '<INPUT TYPE="text" NAME="last_bill" SIZE=32 ID="last_bill_text" VALUE="', + ( $cust_pkg->last_bill + ? time2str($format, $cust_pkg->last_bill) + : "" ), + '">'. + ' <IMG SRC="../images/calendar.png" ID="last_bill_button" STYLE="cursor: pointer" TITLE="Select date">'. + '</TD></TR>' + if $cust_pkg->dbdef_table->column('last_bill'); + +print '<TR><TD ALIGN="right">Next bill date</TD><TD>', + '<INPUT TYPE="text" NAME="bill" SIZE=32 ID="bill_text" VALUE="', + ( $bill ? time2str($format, $bill) : "" ), '">'. + ' <IMG SRC="../images/calendar.png" ID="bill_button" STYLE="cursor: pointer" TITLE="Select date">'. + '</TD></TR>'; + +print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">', + time2str($format, $susp), '</TD></TR>' + if $susp; + +#print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">', +# time2str("%D",$expire), '</TD></TR>' +# if $expire; +print '<TR><TD ALIGN="right">Expiration date'. + '</TD><TD>', + '<INPUT TYPE="text" NAME="expire" SIZE=32 ID="expire_text" VALUE="', + ( $expire ? time2str($format, $expire) : "" ), '">'. + ' <IMG SRC="../images/calendar.png" ID="expire_button" STYLE="cursor: pointer" TITLE="Select date">'. + '<BR><FONT SIZE=-1>(will <b>cancel</b> this package'. + ' when the date is reached)</FONT>'. + '</TD></TR>'; + +print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">', + time2str($format, $cancel), '</TD></TR>' + if $cancel; %> - -<%= ntable("#cccccc",2) %> - - <TR> - <TD ALIGN="right">Package number</TD> - <TD BGCOLOR="#ffffff"><%= $pkgnum %></TD> - </TR> - - <TR> - <TD ALIGN="right">Package</TD> - <TD BGCOLOR="#ffffff"><%= $pkg %></TD> - </TR> - - <TR> - <TD ALIGN="right">Comment</TD> - <TD BGCOLOR="#ffffff"><%= $comment %></TD> - </TR> - - <TR> - <TD ALIGN="right">Order taker</TD> - <TD BGCOLOR="#ffffff"><%= $otaker %></TD> - </TR> - - <TR> - <TD ALIGN="right">Setup date</TD> - <TD> - <INPUT TYPE="text" NAME="setup" SIZE=32 ID="setup_text" VALUE="<%= ( $setup ? time2str($format, $setup) : "" ) %>"> - <IMG SRC="../images/calendar.png" ID="setup_button" STYLE="cursor: pointer" TITLE="Select date"> - </TD> - </TR> - - <TR> - <TD ALIGN="right"><%= $last_bill_or_renewed %> date</TD> - <TD> - <INPUT TYPE="text" NAME="last_bill" SIZE=32 ID="last_bill_text" VALUE="<%= ( $cust_pkg->last_bill ? time2str($format, $cust_pkg->last_bill) : "" ) %>"> - <IMG SRC="../images/calendar.png" ID="last_bill_button" STYLE="cursor: pointer" TITLE="Select date"> - </TD> - </TR> - - <TR> - <TD ALIGN="right"><%= $next_bill_or_prepaid_until %> date</TD> - <TD> - <INPUT TYPE="text" NAME="bill" SIZE=32 ID="bill_text" VALUE="<%= ( $bill ? time2str($format, $bill) : "" ) %>"> - <IMG SRC="../images/calendar.png" ID="bill_button" STYLE="cursor: pointer" TITLE="Select date"> - </TD> - </TR> - - <% if ( $susp ) { %> - <TR> - <TD ALIGN="right">Suspension date</TD> - <TD BGCOLOR="#ffffff"><%= time2str($format, $susp) %></TD> - </TR> - <% } %> - - <TR> - <TD ALIGN="right">Expiration date</TD> - <TD> - <INPUT TYPE="text" NAME="expire" SIZE=32 ID="expire_text" VALUE="<%= ( $expire ? time2str($format, $expire) : "" ) %>"> - <IMG SRC="../images/calendar.png" ID="expire_button" STYLE="cursor: pointer" TITLE="Select date"> - <BR><FONT SIZE=-1>(will <b>cancel</b> this package when the date is reached)</FONT> - </TD> - </TR> - - <% if ( $cancel ) { %> - <TR> - <TD ALIGN="right">Cancellation date</TD> - <TD BGCOLOR="#ffffff"><%= time2str($format, $cancel) %></TD> - </TR> - <% } %> - </TABLE> - <SCRIPT TYPE="text/javascript"> <% my @cal = qw( setup bill expire ); diff --git a/httemplate/edit/agent.cgi b/httemplate/edit/agent.cgi index cb64ad8cd..8a1cb2ae1 100755 --- a/httemplate/edit/agent.cgi +++ b/httemplate/edit/agent.cgi @@ -1,3 +1,4 @@ +<!-- mason kludge --> <% my $agent; @@ -15,8 +16,6 @@ if ( $cgi->param('error') ) { my $action = $agent->agentnum ? 'Edit' : 'Add'; my $hashref = $agent->hashref; -my $conf = new FS::Conf; - %> <%= header("$action Agent", menubar( @@ -33,74 +32,45 @@ my $conf = new FS::Conf; Agent #<%= $hashref->{agentnum} ? $hashref->{agentnum} : "(NEW)" %> <%= &ntable("#cccccc", 2, '') %> - <TR> <TH ALIGN="right">Agent</TH> <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<%= $hashref->{agent} %>"></TD> </TR> +<TR> + <TH ALIGN="right">Agent type</TH> + <TD><SELECT NAME="typenum" SIZE=1> - <TR> - <TH ALIGN="right">Agent type</TH> - <TD><SELECT NAME="typenum" SIZE=1> - - <% foreach my $agent_type (qsearch('agent_type',{})) { %> - <OPTION VALUE="<%= $agent_type->typenum %>"<%= ( $hashref->{typenum} && ( $hashref->{typenum} == $agent_type->typenum ) ) ? ' SELECTED' : '' %>> - <%= $agent_type->getfield('typenum') %>: <%= $agent_type->getfield('atype') %> - <% } %> - - </SELECT></TD> - </TR> - +<% foreach my $agent_type (qsearch('agent_type',{})) { %> + <OPTION VALUE="<%= $agent_type->typenum %>"<%= ( $hashref->{typenum} && ( $hashref->{typenum} == $agent_type->typenum ) ) ? ' SELECTED' : '' %>> + <%= $agent_type->getfield('typenum') %>: <%= $agent_type->getfield('atype') %> +<% } %> + +</SELECT></TD> +</TR> +<% if ( dbdef->table('agent')->column('disabled') ) { %> <TR> <TD ALIGN="right">Disable</TD> <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>></TD> </TR> - - <TR> - <TD ALIGN="right"><!--Frequency--></TD> - <TD><INPUT TYPE="hidden" NAME="freq" VALUE="<%= $hashref->{freq} %>"></TD> - </TR> - - <TR> - <TD ALIGN="right"><!--Program--></TD> - <TD><INPUT TYPE="hidden" NAME="prog" VALUE="<%= $hashref->{prog} %>"></TD> - </TR> - - <% if ( $conf->config('ticket_system') ) { - my $default_queueid = $conf->config('ticket_system-default_queueid'); - my $default_queue = FS::TicketSystem->queue($default_queueid); - $default_queue = "(default) $default_queueid: $default_queue" - if $default_queueid; - my %queues = FS::TicketSystem->queues(); - my @queueids = sort { $a <=> $b } keys %queues; - %> - <TR> - <TD ALIGN="right">Ticketing queue</TD> - <TD> - <SELECT NAME="ticketing_queueid"> - <OPTION VALUE=""><%= $default_queue %> - <% foreach my $queueid ( @queueids ) { %> - <OPTION VALUE="<%= $queueid %>" <%= $agent->ticketing_queueid == $queueid ? ' SELECTED' : '' %>><%= $queueid %>: <%= $queues{$queueid} %> - <% } %> - </SELECT> - </TD> - </TR> - <% } %> - +<% } %> +<TR> + <TD ALIGN="right"><!--Frequency--></TD> + <TD><INPUT TYPE="hidden" NAME="freq" VALUE="<%= $hashref->{freq} %>"></TD> +</TR> +<TR> + <TD ALIGN="right"><!--Program--></TD> + <TD><INPUT TYPE="hidden" NAME="prog" VALUE="<%= $hashref->{prog} %>"></TD> +</TR> +<% if ( dbdef->table('agent')->column('username') ) { %> <TR> <TD ALIGN="right">Agent interface username</TD> - <TD> - <INPUT TYPE="text" NAME="username" VALUE="<%= $hashref->{username} %>"> - </TD> + <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $hashref->{username} %>"></TD> </TR> - <TR> <TD ALIGN="right">Agent interface password</TD> - <TD> - <INPUT TYPE="text" NAME="_password" VALUE="<%= $hashref->{_password} %>"> - </TD> + <TD><INPUT TYPE="text" NAME="_password" VALUE="<%= $hashref->{_password} %>"></TD> </TR> - +<% } %> </TABLE> <BR><INPUT TYPE="submit" VALUE="<%= $hashref->{agentnum} ? "Apply changes" : "Add agent" %>"> diff --git a/httemplate/edit/agent_payment_gateway.html b/httemplate/edit/agent_payment_gateway.html deleted file mode 100644 index 61d29e0e9..000000000 --- a/httemplate/edit/agent_payment_gateway.html +++ /dev/null @@ -1,64 +0,0 @@ -<% - -$cgi->param('agentnum') =~ /(\d+)$/ or die "illegal agentnum"; -my $agent = qsearchs('agent', { 'agentnum' => $1 } ); -die "agentnum $1 not found" unless $agent; - -#my @agent_payment_gateway; -if ( $cgi->param('error') ) { -} - -my $action = 'Add'; - -%> - -<%= header("$action payment gateway override for ". $agent->agent, menubar( - 'Main Menu' => $p, - #'View all payment gateways' => $p. 'browse/payment_gateway.html', - 'View all agents' => $p. 'browse/agent.html', -)) %> - -<% if ( $cgi->param('error') ) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> - -<FORM ACTION="<%=popurl(1)%>process/agent_payment_gateway.html" METHOD=POST> -<INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agent->agentnum %>"> - -Use gateway <SELECT NAME="gatewaynum"> -<% foreach my $payment_gateway ( - qsearch('payment_gateway', { 'disabled' => '' } ) - ) { -%> - <OPTION VALUE="<%= $payment_gateway->gatewaynum %>"><%= $payment_gateway->gateway_module %> (<%= $payment_gateway->gateway_username %>) -<% } %> -</SELECT> -<BR><BR> - -for <SELECT NAME="cardtype" MULTIPLE> -<% foreach my $cardtype ( - "", - "VISA card", - "MasterCard", - "Discover card", - "American Express card", - "Diner's Club/Carte Blanche", - "enRoute", - "JCB", - "BankCard", - "Switch", - "Solo", - 'ACH', -) { %> - <OPTION VALUE="<%= $cardtype %>"><%= $cardtype || '(Default fallback)' %> -<% } %> -</SELECT> -<BR><BR> - -(optional) when invoice contains only items of taxclass <INPUT TYPE="text" NAME="taxclass"> -<BR><BR> - -<INPUT TYPE="submit" VALUE="Add gateway override"> -</FORM> -</BODY> -</HTML> diff --git a/httemplate/edit/agent_type.cgi b/httemplate/edit/agent_type.cgi index 5addbbd4c..637c710ab 100755 --- a/httemplate/edit/agent_type.cgi +++ b/httemplate/edit/agent_type.cgi @@ -1,3 +1,4 @@ +<!-- mason kludge --> <% my($agent_type); @@ -13,63 +14,50 @@ if ( $cgi->param('error') ) { $agent_type = new FS::agent_type {}; } my $action = $agent_type->typenum ? 'Edit' : 'Add'; +my $hashref = $agent_type->hashref; -%> - -<%= header("$action Agent Type", menubar( +print header("$action Agent Type", menubar( 'Main Menu' => "$p", 'View all agent types' => "${p}browse/agent_type.cgi", -)) -%> +)); -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> +print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), + "</FONT>" + if $cgi->param('error'); -<FORM ACTION="<%= popurl(1) %>process/agent_type.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="typenum" VALUE="<%= $agent_type->typenum %>"> -Agent Type #<%= $agent_type->typenum || "(NEW)" %> -<BR><BR> +print '<FORM ACTION="', popurl(1), 'process/agent_type.cgi" METHOD=POST>', + qq!<INPUT TYPE="hidden" NAME="typenum" VALUE="$hashref->{typenum}">!, + "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)"; -Agent Type -<INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<%= $agent_type->atype %>"> -<BR><BR> - -Select which packages agents of this type may sell to customers<BR> - -<% foreach my $part_pkg ( - qsearch({ 'table' => 'part_pkg', - 'hashref' => { 'disabled' => '' }, - 'select' => 'part_pkg.*', - 'addl_from' => 'LEFT JOIN type_pkgs USING ( pkgpart )', - 'extra_sql' => ( $agent_type->typenum - ? 'OR typenum = '. $agent_type->typenum - : '' - ), - }) - ) { -%> +print <<END; +<BR><BR>Agent Type <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="$hashref->{atype}"> +<BR><BR>Select which packages agents of this type may sell to customers<BR> +END - <BR> - <INPUT TYPE="checkbox" NAME="pkgpart<%= $part_pkg->pkgpart %>" <%= +foreach my $part_pkg ( qsearch('part_pkg',{ 'disabled' => '' }) ) { + print qq!<BR><INPUT TYPE="checkbox" NAME="pkgpart!, + $part_pkg->getfield('pkgpart'), qq!" !, + # ( 'CHECKED 'x scalar( qsearchs('type_pkgs',{ - 'typenum' => $agent_type->typenum, - 'pkgpart' => $part_pkg->pkgpart, + 'typenum' => $agent_type->getfield('typenum'), + 'pkgpart' => $part_pkg->getfield('pkgpart'), }) ? 'CHECKED ' - : '' - %> VALUE="ON"> - - <A HREF="<%= $p %>edit/part_pkg.cgi?<%= $part_pkg->pkgpart %>"><%= $part_pkg->pkgpart %>: - <%= $part_pkg->pkg %> - <%= $part_pkg->comment %></A> - <%= $part_pkg->disabled =~ /^Y/i ? ' (DISABLED)' : '' %> - -<% } %> - -<BR><BR> + : '', + qq!VALUE="ON"> !, + qq!<A HREF="${p}edit/part_pkg.cgi?!, $part_pkg->pkgpart, + '">', $part_pkg->pkgpart. ": ". $part_pkg->getfield('pkg'), '</A>', + ; +} -<INPUT TYPE="submit" VALUE="<%= $agent_type->typenum ? "Apply changes" : "Add agent type" %>"> +print qq!<BR><BR><INPUT TYPE="submit" VALUE="!, + $hashref->{typenum} ? "Apply changes" : "Add agent type", + qq!">!; +print <<END; </FORM> </BODY> </HTML> +END + +%> diff --git a/httemplate/edit/bulk-cust_svc.html b/httemplate/edit/bulk-cust_svc.html deleted file mode 100644 index 332b5b67c..000000000 --- a/httemplate/edit/bulk-cust_svc.html +++ /dev/null @@ -1,97 +0,0 @@ -<%= header( 'Bulk customer service change', - menubar( - 'Main Menu' => $p, - ), - ) -%> - -<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT> - -<%= include('/elements/progress-init.html', - 'OneTrueForm', - [qw( old_svcpart new_svcpart pkgpart )], - 'process/bulk-cust_svc.cgi', - $p.'browse/part_svc.cgi', - ) -%> - -<FORM NAME="OneTrueForm"> - -<% - $cgi->param('svcpart') =~ /^(\d+)$/ - or die "illegal svcpart: ". $cgi->param('svcpart'); - - my $old_svcpart = $1; - my $src_part_svc = qsearchs('part_svc', { 'svcpart' => $old_svcpart } ) - or die "unknown svcpart: $old_svcpart"; -%> - -<INPUT NAME="old_svcpart" TYPE="hidden" VALUE="<%= $old_svcpart %>"> -Change <!-- customer -<B><%= $src_part_svc->svcpart %>: <%= $src_part_svc->svc %></B> services -<BR> ---> - -<SELECT NAME="pkgpart"> - -<% my $num_cust_svc = $src_part_svc->num_cust_svc; %> -<% if ( $num_cust_svc > 1 ) { %> - <OPTION VALUE="">all <%= $num_cust_svc %> <%= $src_part_svc->svc %> services -<% } else { %> - <OPTION VALUE="">the <%= $num_cust_svc %> <%= $src_part_svc->svc %> service -<% } %> - -<% - my $num_unlinked = $src_part_svc->num_cust_svc(0); - if ( $num_unlinked ) { -%> - <OPTION VALUE="0">the <%= $num_unlinked %> unlinked <%= $src_part_svc->svc %> services - -<% } %> - -<% foreach my $schwartz ( - grep { $_->[1] } - map { [ $_, $src_part_svc->num_cust_svc($_->pkgpart) ] } - qsearch('part_pkg', {} ) - ) { - my( $part_pkg, $num_cust_svc ) = @$schwartz; -%> - <OPTION VALUE="<%= $part_pkg->pkgpart %>">the <%= $num_cust_svc %> - <%= $src_part_svc->svc %> service<%= $num_cust_svc > 1 ? 's in' : ' in a' %> - <%= $part_pkg->pkg %> package<%= $num_cust_svc > 1 ? 's' : '' %> -<% } %> -</SELECT> -<BR> - -to new service definition -<SELECT NAME="new_svcpart"> -<% foreach my $dest_part_svc ( - grep { $_->svcpart != $old_svcpart - && $_->svcdb eq $src_part_svc->svcdb - } - qsearch('part_svc', { 'disabled' => '' } ) - ) { -%> - <OPTION VALUE="<%= $dest_part_svc->svcpart %>"><%= $dest_part_svc->svcpart %>: <%= $dest_part_svc->svc %> - -<% } %> -</SELECT> -<BR> - -<BR> - -<SCRIPT TYPE="text/javascript"> -var confirm_change = '<P ALIGN="center"><B>Bulk customer service change - Are you sure?</B><BR><P ALIGN="CENTER" <INPUT TYPE="button" VALUE="Yes, make changes" onClick="process();"> <INPUT TYPE="BUTTON" VALUE="Cancel" onClick="cClick()">'; -</SCRIPT> - -<INPUT TYPE="button" VALUE="Bulk change customer services" onClick="overlib(confirm_change, CAPTION, 'Confirm bulk customer service change', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH, 576, HEIGHT, 128, TEXTSIZE, 3, BGCOLOR, '#ff0000', CGCOLOR, '#ff0000' );"> - -</FORM> - -</BODY> -</HTML> - - - diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 144d5405c..61468f382 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -1,3 +1,4 @@ +<!-- mason kludge --> <% #for misplaced logic below @@ -17,7 +18,6 @@ my $conf = new FS::Conf; my $error = ''; my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart); my(@invoicing_list); -my $same = ''; if ( $cgi->param('error') ) { $error = $cgi->param('error'); $cust_main = new FS::cust_main ( { @@ -34,8 +34,6 @@ if ( $cgi->param('error') ) { $password = $cgi->param('_password'); $popnum = $cgi->param('popnum'); @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); - $same = $cgi->param('same'); - $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid'); } elsif ( $cgi->keywords ) { #editing my( $query ) = $cgi->keywords; $query =~ /^(\d+)$/; @@ -76,7 +74,7 @@ my $action = $custnum ? 'Edit' : 'Add'; <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $error %></FONT> <% } %> -<FORM NAME="topform" STYLE="margin-bottom: 0"> +<FORM ACTION="<%= popurl(1) %>process/cust_main.cgi" METHOD=POST NAME="form1" onSubmit="document.form1.submit.disabled=true"> <INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>"> Customer # <%= $custnum ? "<B>$custnum</B>" : " (NEW)" %> @@ -105,64 +103,58 @@ my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first </SELECT> <% } %> -<!-- referral (advertising source) --> - -<% -my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; -if ( $custnum && ! $conf->exists('editreferrals') ) { -%> - - <INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $refnum %>"> - <% - } else { - my(@referrals) = qsearch('part_referral',{}); - if ( scalar(@referrals) == 0 ) { - eidiot "You have not created any advertising sources. You must create at least one advertising source before adding a customer. Go to ". popurl(2). "browse/part_referral.cgi and create one or more advertising sources."; - } elsif ( scalar(@referrals) == 1 ) { - $refnum ||= $referrals[0]->refnum; -%> +# (referral and referring customer still need to be "template"ized) - <INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $refnum %>"> - -<% } else { %> +#referral - <BR><BR><%=$r%>Advertising source - <SELECT NAME="refnum" SIZE="1"> - <%= $refnum ? '' : '<OPTION VALUE="">' %> - <% foreach my $referral (sort { $a->refnum <=> $b->refnum } @referrals) { %> - <OPTION VALUE="<%= $referral->refnum %>" <%= $referral->refnum == $refnum ? 'SELECTED' : '' %>><%= $referral->refnum %>: <%= $referral->referral %> - <% } %> - </SELECT> -<% } %> - -<% } %> +my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; +if ( $custnum && ! $conf->exists('editreferrals') ) { + print qq!<INPUT TYPE="hidden" NAME="refnum" VALUE="$refnum">!; +} else { + my(@referrals) = qsearch('part_referral',{}); + if ( scalar(@referrals) == 0 ) { + eidiot "You have not created any advertising sources. You must create at least one advertising source before adding a customer. Go to ". popurl(2). "browse/part_referral.cgi and create one or more advertising sources."; + } elsif ( scalar(@referrals) == 1 ) { + $refnum ||= $referrals[0]->refnum; + print qq!<INPUT TYPE="hidden" NAME="refnum" VALUE="$refnum">!; + } else { + print qq!<BR><BR>${r}Advertising source <SELECT NAME="refnum" SIZE="1">!; + print "<OPTION> " unless $refnum; + my($referral); + foreach $referral (sort { + $a->refnum <=> $b->refnum; + } @referrals) { + print "<OPTION" . " SELECTED"x($referral->refnum==$refnum), + ">", $referral->refnum, ": ", $referral->referral; + } + print "</SELECT>"; + } +} -<!-- referring customer --> +#referring customer -<% +#print qq!<BR><BR>Referring Customer: !; my $referring_cust_main = ''; if ( $cust_main->referral_custnum and $referring_cust_main = qsearchs('cust_main', { custnum => $cust_main->referral_custnum } ) ) { -%> - - <BR><BR>Referring Customer: - <A HREF="<%= popurl(1) %>/cust_main.cgi?<%= $cust_main->referral_custnum %>"><%= $cust_main->referral_custnum %>: <%= $referring_cust_main->name %></A> - <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<%= $cust_main->referral_custnum %>"> - -<% } elsif ( ! $conf->exists('disable_customer_referrals') ) { %> - - <BR><BR>Referring customer number: - <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> - -<% } else { %> - - <INPUT TYPE="hidden" NAME="referral_custnum" VALUE=""> + print '<BR><BR>Referring Customer: <A HREF="'. popurl(1). '/cust_main.cgi?'. + $cust_main->referral_custnum. '">'. + $cust_main->referral_custnum. ': '. + ( $referring_cust_main->company + || $referring_cust_main->last. ', '. $referring_cust_main->first ). + '</A><INPUT TYPE="hidden" NAME="referral_custnum" VALUE="'. + $cust_main->referral_custnum. '">'; +} elsif ( ! $conf->exists('disable_customer_referrals') ) { + print '<BR><BR>Referring customer number: <INPUT TYPE="text" NAME="referral_custnum" VALUE="">'; +} else { + print '<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">'; +} -<% } %> +%> <!-- contact info --> @@ -180,17 +172,11 @@ function bill_changed(what) { <% for (qw( last first company address1 address2 city zip daytime night fax )) { %> what.form.ship_<%=$_%>.value = what.form.<%=$_%>.value; <% } %> - what.form.ship_country.selectedIndex = what.form.country.selectedIndex; - function fix_ship_state() { - what.form.ship_state.selectedIndex = what.form.state.selectedIndex; - } - ship_country_changed(what.form.ship_country, fix_ship_state ); - - function fix_ship_county() { - what.form.ship_county.selectedIndex = what.form.county.selectedIndex; - } - ship_state_changed(what.form.ship_state, fix_ship_county ); + ship_country_changed(what.form.ship_country); + what.form.ship_state.selectedIndex = what.form.state.selectedIndex; + ship_state_changed(what.form.ship_state); + what.form.ship_county.selectedIndex = what.form.county.selectedIndex; } } function samechanged(what) { @@ -213,7 +199,7 @@ function samechanged(what) { my $checked = ''; my $disabled = ''; my $disabledselect = ''; - unless ( $cust_main->ship_last && $same ne 'Y' ) { + unless ( $cust_main->ship_last && $cgi->param('same') ne 'Y' ) { $checked = 'CHECKED'; $disabled = 'DISABLED style="background-color: #dddddd"'; foreach ( @@ -232,138 +218,184 @@ Service address <% } %> -<!-- billing info --> +<% +# billing info + +sub expselect { + my $prefix = shift; + my( $m, $y ) = (0, 0); + if ( scalar(@_) ) { + my $date = shift || '01-2000'; + if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format + ( $m, $y ) = ( $2, $1 ); + } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { + ( $m, $y ) = ( $1, $3 ); + } else { + die "unrecognized expiration date format: $date"; + } + } -<%= include( 'cust_main/billing.html', $cust_main, - 'invoicing_list' => \@invoicing_list, - ) -%> + my $return = qq!<SELECT NAME="$prefix!. qq!_month" SIZE="1">!; + for ( 1 .. 12 ) { + $return .= "<OPTION"; + $return .= " SELECTED" if $_ == $m; + $return .= ">$_"; + } + $return .= qq!</SELECT>/<SELECT NAME="$prefix!. qq!_year" SIZE="1">!; + my @t = localtime; + my $thisYear = $t[5] + 1900; + for ( ($thisYear > $y && $y > 0 ? $y : $thisYear) .. 2037 ) { + $return .= "<OPTION"; + $return .= " SELECTED" if $_ == $y; + $return .= ">$_"; + } + $return .= "</SELECT>"; -<SCRIPT> -function bottomfixup(what) { + $return; +} - var topvars = new Array( - 'custnum', 'agentnum', 'refnum', 'referral_custnum', +my $payby_default = $conf->config('payby-default'); - 'last', 'first', 'ss', 'company', - 'address1', 'address2', 'city', - 'county', 'state', 'zip', 'country', - 'daytime', 'night', 'fax', +if ( $payby_default eq 'HIDE' ) { - 'same', + $cust_main->payby('BILL') unless $cust_main->payby; - 'ship_last', 'ship_first', 'ship_company', - 'ship_address1', 'ship_address2', 'ship_city', - 'ship_county', 'ship_state', 'ship_zip', 'ship_country', - 'ship_daytime','ship_night', 'ship_fax', + foreach my $field (qw( tax payby )) { + print qq!<INPUT TYPE="hidden" NAME="$field" VALUE="!. + $cust_main->getfield($field). '">'; + } - 'select' // XXX key - ); + print qq!<INPUT TYPE="hidden" NAME="invoicing_list" VALUE="!. + join(', ', $cust_main->invoicing_list). '">'; - var layervars = new Array( - 'payauto', - 'payinfo', 'payinfo1', 'payinfo2', - 'payname', 'exp_month', 'exp_year', 'paycvv', - 'paystart_month', 'paystart_year', 'payissue', - 'payip', - 'paid' - ); + foreach my $payby (qw( CARD DCRD CHEK DCHK LECB BILL COMP )) { + foreach my $field (qw( payinfo payname )) { + print qq!<INPUT TYPE="hidden" NAME="${payby}_$field" VALUE="!. + $cust_main->getfield($field). '">'; + } - var billing_bottomvars = new Array( - 'tax', - 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX' - ); + #false laziness w/expselect + my( $m, $y ); + my $date = $cust_main->paydate || '12-2037'; + if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format + ( $m, $y ) = ( $2, $1 ); + } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { + ( $m, $y ) = ( $1, $3 ); + } else { + die "unrecognized expiration date format: $date"; + } - for ( f=0; f < topvars.length; f++ ) { - var field = topvars[f]; - copyelement( document.topform.elements[field], - document.bottomform.elements[field] - ); - } + print qq!<INPUT TYPE="hidden" NAME="${payby}_month" VALUE="$m">!. + qq!<INPUT TYPE="hidden" NAME="${payby}_year" VALUE="$y">!; - var layerform = document.topform.select.options[document.topform.select.selectedIndex].value; - for ( f=0; f < layervars.length; f++ ) { - var field = layervars[f]; - copyelement( document.forms[layerform].elements[field], - document.bottomform.elements[field] - ); } - for ( f=0; f < billing_bottomvars.length; f++ ) { - var field = billing_bottomvars[f]; - copyelement( document.billing_bottomform.elements[field], - document.bottomform.elements[field] - ); +} else { + + print "<BR>Billing information", &itable("#cccccc"), + qq!<TR><TD><INPUT TYPE="checkbox" NAME="tax" VALUE="Y"!; + print qq! CHECKED! if $cust_main->tax eq "Y"; + print qq!>Tax Exempt</TD></TR><TR><TD>!. + qq!<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"!; + + #my @invoicing_list = $cust_main->invoicing_list; + print qq! CHECKED! + if ( ! @invoicing_list && ! $conf->exists('disablepostalinvoicedefault') ) + || grep { $_ eq 'POST' } @invoicing_list; + print qq!>Postal mail invoice</TD></TR><TR><TD>!; + print qq!<INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX"!; + print qq! CHECKED! if (grep { $_ eq 'FAX' } @invoicing_list); + print qq!>FAX invoice</TD></TR>!; + my $invoicing_list = join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ); + print qq!<TR><TD>Email invoice <INPUT TYPE="text" NAME="invoicing_list" VALUE="$invoicing_list"></TD></TR>!; + + print "<TR><TD>Billing type</TD></TR>", + "</TABLE>", '<SCRIPT> + var mywindow = -1; + function myopen(filename,windowname,properties) { + myclose(); + mywindow = window.open(filename,windowname,properties); + } + function myclose() { + if ( mywindow != -1 ) + mywindow.close(); + mywindow = -1; + } + var achwindow = -1; + function achopen(filename,windowname,properties) { + achclose(); + achwindow = window.open(filename,windowname,properties); + } + function achclose() { + if ( achwindow != -1 ) + achwindow.close(); + achwindow = -1; + } + </SCRIPT>', + &table("#cccccc"), "<TR>"; + + my($payinfo, $payname)=( + $cust_main->payinfo, + $cust_main->payname, + ); + + my %payby = ( + 'CARD' => qq!Credit card (automatic)<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD"). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="">!, + 'DCRD' => qq!Credit card (on-demand)<BR>${r}<INPUT TYPE="text" NAME="DCRD_payinfo" VALUE="" MAXLENGTH=19><BR>${r}Exp !. expselect("DCRD"). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="DCRD_payname" VALUE="">!, + 'CHEK' => qq!Electronic check (automatic)<BR>${r}Account number <INPUT TYPE="text" NAME="CHEK_payinfo1" VALUE=""><BR>${r}ABA/Routing number <INPUT TYPE="text" NAME="CHEK_payinfo2" VALUE="" SIZE=10 MAXLENGTH=9> (<A HREF="javascript:achopen('../docs/ach.html','ach','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=384,height=256')">help</A>)<INPUT TYPE="hidden" NAME="CHEK_month" VALUE="12"><INPUT TYPE="hidden" NAME="CHEK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="CHEK_payname" VALUE="">!, + 'DCHK' => qq!Electronic check (on-demand)<BR>${r}Account number <INPUT TYPE="text" NAME="DCHK_payinfo1" VALUE=""><BR>${r}ABA/Routing number <INPUT TYPE="text" NAME="DCHK_payinfo2" VALUE="" SIZE=10 MAXLENGTH=9> (<A HREF="javascript:achopen('../docs/ach.html','ach','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=384,height=256')">help</A>)<INPUT TYPE="hidden" NAME="DCHK_month" VALUE="12"><INPUT TYPE="hidden" NAME="DCHK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="DCHK_payname" VALUE="">!, + 'LECB' => qq!Phone bill billing<BR>${r}Phone number <INPUT TYPE="text" BANE="LECB_payinfo" VALUE="" MAXLENGTH=15 SIZE=16><INPUT TYPE="hidden" NAME="LECB_month" VALUE="12"><INPUT TYPE="hidden" NAME="LECB_year" VALUE="2037"><INPUT TYPE="hidden" NAME="LECB_payname" VALUE="">!, + 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR><INPUT TYPE="hidden" NAME="BILL_month" VALUE="12"><INPUT TYPE="hidden" NAME="BILL_year" VALUE="2037">Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="">!, + 'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""><BR>${r}Exp !. expselect("COMP"), +); + + if ( $cust_main->dbdef_table->column('paycvv') ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 bs + $payby{$payby} .= qq!<BR>CVV2 (<A HREF="javascript:myopen('../docs/cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>) <INPUT TYPE="text" NAME=${payby}_paycvv VALUE="" SIZE=4 MAXLENGTH=4>!; + } } -} + my( $account, $aba ) = split('@', $payinfo); -function copyelement(from, to) { - if ( from == undefined ) { - to.value = ''; - } else if ( from.type == 'select-one' ) { - to.value = from.options[from.selectedIndex].value; - //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value); - } else if ( from.type == 'checkbox' ) { - if ( from.checked ) { - to.value = from.value; - } else { - to.value = ''; + my %paybychecked = ( + 'CARD' => qq!Credit card (automatic)<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD", $cust_main->paydate). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname">!, + 'DCRD' => qq!Credit card (on-demand)<BR>${r}<INPUT TYPE="text" NAME="DCRD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR>${r}Exp !. expselect("DCRD", $cust_main->paydate). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="DCRD_payname" VALUE="$payname">!, + 'CHEK' => qq!Electronic check (automatic)<BR>${r}Account number <INPUT TYPE="text" NAME="CHEK_payinfo1" VALUE="$account"><BR>${r}ABA/Routing number <INPUT TYPE="text" NAME="CHEK_payinfo2" VALUE="$aba" SIZE=10 MAXLENGTH=9> (<A HREF="javascript:achopen('../docs/ach.html','ach','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=384,height=256')">help</A>)<INPUT TYPE="hidden" NAME="CHEK_month" VALUE="12"><INPUT TYPE="hidden" NAME="CHEK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="CHEK_payname" VALUE="$payname">!, + 'DCHK' => qq!Electronic check (on-demand)<BR>${r}Account number <INPUT TYPE="text" NAME="DCHK_payinfo1" VALUE="$account"><BR>${r}ABA/Routing number <INPUT TYPE="text" NAME="DCHK_payinfo2" VALUE="$aba" SIZE=10 MAXLENGTH=9> (<A HREF="javascript:achopen('../docs/ach.html','ach','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=384,height=256')">help</A>)<INPUT TYPE="hidden" NAME="DCHK_month" VALUE="12"><INPUT TYPE="hidden" NAME="DCHK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="DCHK_payname" VALUE="$payname">!, + 'LECB' => qq!Phone bill billing<BR>${r}Phone number <INPUT TYPE="text" BANE="LECB_payinfo" VALUE="$payinfo" MAXLENGTH=15 SIZE=16><INPUT TYPE="hidden" NAME="LECB_month" VALUE="12"><INPUT TYPE="hidden" NAME="LECB_year" VALUE="2037"><INPUT TYPE="hidden" NAME="LECB_payname" VALUE="">!, + 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR><INPUT TYPE="hidden" NAME="BILL_month" VALUE="12"><INPUT TYPE="hidden" NAME="BILL_year" VALUE="2037">Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!, + 'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("COMP", $cust_main->paydate), +); + + if ( $cust_main->dbdef_table->column('paycvv') ) { + my $paycvv = $cust_main->paycvv; + + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 bs + $paybychecked{$payby} .= qq!<BR>CVV2 (<A HREF="javascript:myopen('../docs/cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>) <INPUT TYPE="text" NAME=${payby}_paycvv VALUE="$paycvv" SIZE=4 MAXLENGTH=4>!; } - } else { - if ( from.value == undefined ) { - to.value = ''; + } + + + $cust_main->payby($payby_default) unless $cust_main->payby; + for (qw(CARD DCRD CHEK DCHK LECB BILL COMP)) { + print qq!<TD VALIGN=TOP><INPUT TYPE="radio" NAME="payby" VALUE="$_"!; + if ($cust_main->payby eq "$_") { + print qq! CHECKED> $paybychecked{$_}</TD>!; } else { - to.value = from.value; + print qq!> $payby{$_}</TD>!; } } - //alert(from + " (" + from.type + "): " + to.name + " => " + to.value); -} -</SCRIPT> + print "</TR></TABLE>$r required fields for each billing type"; -<FORM ACTION="<%= popurl(1) %>process/cust_main.cgi" METHOD=POST NAME="bottomform" onSubmit="document.bottomform.submit.disabled=true; bottomfixup(this.form);" STYLE="margin-top: 0; margin-bottom: 0"> - -<% foreach my $hidden ( - 'custnum', 'agentnum', 'refnum', 'referral_custnum', - 'last', 'first', 'ss', 'company', - 'address1', 'address2', 'city', - 'county', 'state', 'zip', 'country', - 'daytime', 'night', 'fax', - - 'same', - - 'ship_last', 'ship_first', 'ship_company', - 'ship_address1', 'ship_address2', 'ship_city', - 'ship_county', 'ship_state', 'ship_zip', 'ship_country', - 'ship_daytime','ship_night', 'ship_fax', - - 'select', #XXX key - - 'payauto', - 'payinfo', 'payinfo1', 'payinfo2', - 'payname', 'exp_month', 'exp_year', 'paycvv', - 'paystart_month', 'paystart_year', 'payissue', - 'payip', - 'paid', - - 'tax', - 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX' - ) { -%> - <INPUT TYPE="hidden" NAME="<%= $hidden %>" VALUE=""> -<% } %> - -<BR>Comments -<%= &ntable("#cccccc") %> - <TR> - <TD> - <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments"><%= $cust_main->comments %></TEXTAREA> - </TD> - </TR> -</TABLE> +} -<% +if ( defined $cust_main->dbdef_table->column('comments') ) { + print "<BR><BR>Comments", &itable("#cccccc"), + qq!<TR><TD><TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments">!, + $cust_main->comments, "</TEXTAREA>", + "</TD></TR></TABLE>"; +} unless ( $custnum ) { # pry the wrong place for this logic. also pretty expensive @@ -393,7 +425,7 @@ unless ( $custnum ) { # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"), #apiabuse & undesirable wrapping - print "<BR>First package", &ntable("#cccccc"), + print "<BR><BR>First package", &itable("#cccccc"), qq!<TR><TD COLSPAN=2><SELECT NAME="pkgpart_svcpart">!; print qq!<OPTION VALUE="">(none)!; @@ -421,7 +453,7 @@ unless ( $custnum ) { (blank to generate)</TD></TR> END - print '<TR><TD ALIGN="right">Access number</TD><TD>' + print '<TR><TD ALIGN="right">Access number</TD><TD WIDTH="100%">' . &FS::svc_acct_pop::popselector($popnum). '</TD></TR></TABLE>' @@ -431,9 +463,9 @@ END my $otaker = $cust_main->otaker; print qq!<INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">!, - qq!<BR><INPUT TYPE="submit" NAME="submit" VALUE="!, - $custnum ? "Apply Changes" : "Add Customer", qq!"><BR>!, - "</FORM></DIV></BODY></HTML>", + qq!<BR><INPUT NAME="submit" TYPE="submit" VALUE="!, + $custnum ? "Apply Changes" : "Add Customer", qq!">!, + "</FORM></BODY></HTML>", ; %> diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html deleted file mode 100644 index 96f777baa..000000000 --- a/httemplate/edit/cust_main/billing.html +++ /dev/null @@ -1,443 +0,0 @@ -<% - -my( $cust_main, %options ) = @_; -my @invoicing_list = @{ $options{'invoicing_list'} }; -my $conf = new FS::Conf; -my $payby_default = $conf->config('payby-default'); - -my @payby = grep /\w/, $conf->config('payby'); -#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) -@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) - unless @payby; - -if ( $payby_default eq 'HIDE' ) { - - $cust_main->payby('BILL') unless $cust_main->payby; - -%> - - <INPUT TYPE="hidden" NAME="select" VALUE="<%= $cust_main->payby %>"> - - </FORM> - - <FORM NAME="<%= $cust_main->payby %>" STYLE="margin-top: 0; margin-bottom: 0"> <% # XXX key %> - - <% foreach my $field (qw( payinfo payname paycvv paystart_month paystart_year payissue payip )) { %> - - <INPUT TYPE="hidden" NAME="<%= $field %>" VALUE="<%= $cust_main->getfield($field) %>"> - - <% } %> - - <% - #false laziness w/elements/select-month_year.html & view/cust_main/billing.html - my( $mon, $year ); - my $date = $cust_main->paydate || '12-2037'; - if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); - } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); - } else { - die "unrecognized expiration date format: $date"; - } - %> - - <INPUT TYPE="hidden" NAME="exp_month" VALUE="<%= $mon %>"> - <INPUT TYPE="hidden" NAME="exp_year" VALUE="<%= $year %>"> - - </FORM> - - <FORM NAME="billing_bottomform" STYLE="margin-top: 0; margin-bottom: 0"> - - <INPUT TYPE="hidden" NAME="tax" VALUE="<%= $cust_main->tax %>"> - - <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<%= join(', ', @invoicing_list) %>"> - - </FORM> - -<% } else { - - my $r = qq!<font color="#ff0000">*</font> !; - -%> - - <BR>Billing information - <%= &ntable("#cccccc") %> - - <TR> - <TD ALIGN="right" WIDTH="200"><%=$r%>Billing type</TD> - - <SCRIPT> - - var mywindow = -1; - function myopen(filename,windowname,properties) { - myclose(); - mywindow = window.open(filename,windowname,properties); - } - function myclose() { - if ( mywindow != -1 ) - mywindow.close(); - mywindow = -1; - } - - var achwindow = -1; - function achopen(filename,windowname,properties) { - achclose(); - achwindow = window.open(filename,windowname,properties); - } - function achclose() { - if ( achwindow != -1 ) - achwindow.close(); - achwindow = -1; - } - - function card_changed(what) { - if ( - what.form.payinfo.value.substring(0, 4) == '4093' - || what.form.payinfo.value.substring(0, 4) == '4911' - || what.form.payinfo.value.substring(0, 4) == '4936' - || what.form.payinfo.value.substring(0, 6) == '564132' - || what.form.payinfo.value.substring(0, 2) == '63' - || what.form.payinfo.value.substring(0, 2) == '67' - ) - { - what.form.paystart_month.disabled = false; - what.form.paystart_year.disabled = false; - what.form.payissue.disabled = false; - what.form.paystart_month.style.backgroundColor = '#ffffff'; - what.form.paystart_year.style.backgroundColor = '#ffffff'; - what.form.payissue.style.backgroundColor = '#ffffff'; - document.getElementById('paystart_label').style.color = '#000000'; - document.getElementById('payissue_label').style.color = '#000000'; - } else { - what.form.paystart_month.disabled = true; - what.form.paystart_year.disabled = true; - what.form.payissue.disabled = true; - what.form.paystart_month.style.backgroundColor = '#dddddd'; - what.form.paystart_year.style.backgroundColor = '#dddddd'; - what.form.payissue.style.backgroundColor = '#dddddd'; - document.getElementById('paystart_label').style.color = '#999999'; - document.getElementById('payissue_label').style.color = '#999999'; - } - return true; - } - - </SCRIPT> - - <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT> - <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT> - <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT> - <SCRIPT TYPE="text/javascript"> - function OLiframeContent(src, width, height, name) { - return ('<iframe src="'+src+'" width="'+width+'" height="'+height+'"' - +(name?' name="'+name+'" id="'+name+'"':'')+' scrolling="auto">' - +'<div>[iframe not supported]</div></iframe>'); - } - </SCRIPT> - - <% - - my($payby, $payinfo, $payname)=( - $cust_main->payby, - $cust_main->payinfo, - $cust_main->payname, - ); - my( $account, $aba ) = split('@', $payinfo); - - my $disabled = 'DISABLED style="background-color: #dddddd"'; - my $text_disabled = 'style="color: #999999"'; - if ( $payby =~ /^(CARD|DCRD)$/ && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) { - $disabled = 'style="background-color: #ffffff"'; - $text_disabled = 'style="color: #000000";' - } - - my %payby = ( - - 'CARD' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Card number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $payinfo : '' ). qq!" MAXLENGTH=19 onChange="card_changed(this)" onKeyUp="card_changed(this)"></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'exp', - 'selected_date' => - ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paydate : '' ), - ). - - '</TD></TR>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">CVV2 !. - - qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!. - qq!</TD>!. - '<TD WIDTH="408"><INPUT TYPE="text" NAME="paycvv" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paycvv : '' ). '" SIZE=4 MAXLENGTH=4>'. - - - qq!<TR><TD ALIGN="right" WIDTH="200"><SPAN ID="paystart_label" $text_disabled>Start date </SPAN></TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'paystart', - 'disabled' => $disabled, - 'empty_option' => 1, - 'start_year' => 2000, - 'end_year' => (localtime())[5] + 1900, - 'selected_date' => ( - ( $payby =~ /^(CARD|DCRD)$/ - && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) - ? $cust_main->paystart_month. '-'. - $cust_main->paystart_year - : '' - ) - ). - - qq!<SPAN ID="payissue_label" $text_disabled> or Issue number </SPAN>!. - '<INPUT TYPE="text" NAME="payissue" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payissue : '' ). qq!" SIZE=3 MAXLENGTH=2 $disabled></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Exact name on card </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCRD' ? '' : 'CHECKED' ). '> Charge future payments to this card automatically</TD></TR>'. - - '</TABLE>', - - 'CHEK' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Account number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD></TR>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}ABA/Routing number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $aba : '' ). qq!" SIZE=10 MAXLENGTH=9> !. - qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!. - qq!</TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Bank name </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCHK' ? '' : 'CHECKED' ). '> Charge future payments to this electronic check automatically</TD></TR>'. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'LECB' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Phone number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'LECB' ? $cust_main->payinfo : '' ). qq!" MAXLENGTH=15 SIZE=16></TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - qq!<INPUT TYPE="hidden" NAME="payname" VALUE="">!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'BILL' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">P.O. </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payinfo : '' ). qq!"></TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - - qq!<TR><TD ALIGN="right" WIDTH="200">Attention </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'COMP' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Approved by </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE=""></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'exp', - 'selected_date' => - ( $payby eq 'COMP' ? $cust_main->paydate : '' ), - ). - - '</TD></TR>'. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'CASH' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'CASH' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'WEST' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'WEST' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'MCRD' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'MCRD' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - ); - - - my %allopt = ( - 'CARD' => 'Credit card', - 'CHEK' => 'Electronic check', - 'LECB' => 'Phone bill billing', - 'BILL' => 'Billing', - 'CASH' => 'Cash', # initial payment, then billing', - 'WEST' => 'Western Union', # initial payment, then billing', - 'MCRD' => 'Manual credit card', # initial payment, then billing', - 'COMP' => 'Complimentary', - ); - if ( $cust_main->custnum ) { #don't offer CASH/WEST/MCRD initial payment types - # when editing customer - delete $allopt{$_} for qw(CASH WEST MCRD); - } - - tie my %options, 'Tie::IxHash', - map { $_ => $allopt{$_} } - grep { exists $allopt{$_} } - @payby; - - my %payby2option = ( - ( map { $_ => $_ } keys %options ), - 'DCRD' => 'CARD', - 'DCHK' => 'CHEK', - ); - - my $widget = new HTML::Widgets::SelectLayers( - 'options' => \%options, - #'form_name' => 'dummy', - #'form_action' => 'nothingyet', - #chops bottom of page in IE# 'under_position' => 'absolute', - 'html_between' => '</TD></TR></TABLE>', - 'selected_layer' => $payby2option{$payby || $payby_default || $payby[0] }, - 'layer_callback' => sub { my $layer = shift; $payby{$layer}; }, - ); - - %> - - <TD WIDTH="408"><%= $widget->html %> - - <FORM NAME="billing_bottomform" STYLE="margin-top: 0; margin-bottom: 0"> - - <%= &ntable("#cccccc") %> - - <TR><TD> </TD></TR> - - <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <%= $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt</TD> - </TR> - - <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST" <%= - - ( ( ! @invoicing_list - && ! $conf->exists('disablepostalinvoicedefault') - && ! $cust_main->custnum - ) - || grep { $_ eq 'POST' } @invoicing_list ) - - ? 'CHECKED' - : '' - - %>> Postal mail invoice - - </TD> - </TR> - - <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <%= - - ( grep { $_ eq 'FAX' } @invoicing_list ) - ? 'CHECKED' - : '' - - %>> Fax invoice - - </TD> - </TR> - - <TR> - <TD ALIGN="right" WIDTH="200">Email invoice </TD> - <TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<%= join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></TD> - </TR> - - </TABLE> - - </FORM> - - <%= $r %> required fields - -<% } %> - diff --git a/httemplate/edit/cust_main/contact.html b/httemplate/edit/cust_main/contact.html index e0cd06f56..7b88ccbcb 100644 --- a/httemplate/edit/cust_main/contact.html +++ b/httemplate/edit/cust_main/contact.html @@ -14,23 +14,14 @@ $cust_main->set($pre.'state', $statedefault ) unless $cust_main->get($pre.'state') || $cust_main->get($pre.'country') ne $countrydefault; -#my($county_html, $state_html, $country_html) = -# FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), -# $cust_main->get($pre.'state'), -# $cust_main->get($pre.'country'), -# $pre, -# $onchange, -# $disabled, -# ); - -my %select_hash = ( - 'county' => $cust_main->get($pre.'county'), - 'state' => $cust_main->get($pre.'state'), - 'country' => $cust_main->get($pre.'country'), - 'prefix' => $pre, - 'onchange' => $onchange, - 'disabled' => $disabled, -); +my($county_html, $state_html, $country_html) = + FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), + $cust_main->get($pre.'state'), + $cust_main->get($pre.'country'), + $pre, + $onchange, + $disabled, + ); my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; @@ -39,7 +30,7 @@ my $r = qq!<font color="#ff0000">*</font> !; %> -<%= &ntable("#cccccc") %> +<%= &itable("#cccccc") %> <TR> <TH ALIGN="right"><%=$r%>Contact name<BR>(last, first)</TH> @@ -51,7 +42,7 @@ my $r = qq!<font color="#ff0000">*</font> !; <% if ( $conf->exists('show_ss') && !$pre ) { %> <TD ALIGN="right">SS#</TD> <TD><INPUT TYPE="text" NAME="ss" VALUE="<%= $cust_main->ss %>" SIZE=11></TD> -<% } elsif ( !$pre ) { %> +<% } else { %> <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<%= $cust_main->ss %>"></TD> <% } %> @@ -84,10 +75,7 @@ my $r = qq!<font color="#ff0000">*</font> !; <INPUT TYPE="text" NAME="<%=$pre%>city" VALUE="<%= $cust_main->get($pre.'city') %>" onChange="<%= $onchange %>" <%=$disabled%>> </TD> <TH ALIGN="right"><%=$r%>State</TH> - <TD> - <%= include('select-county.html', %select_hash ) %> - <%= include('select-state.html', %select_hash ) %> - </TD> + <TD><%= $county_html. $state_html %></TD> <TH><%=$r%>Zip</TH> <TD> <INPUT TYPE="text" NAME="<%=$pre%>zip" VALUE="<%= $cust_main->get($pre.'zip') %>" SIZE=10 onChange="<%= $onchange %>" <%=$disabled%>> @@ -96,7 +84,7 @@ my $r = qq!<font color="#ff0000">*</font> !; <TR> <TH ALIGN="right"><%=$r%>Country</TH> - <TD><%= include('select-country.html', %select_hash ) %></TD> + <TD><%= $country_html %></TD> </TR> <TR> diff --git a/httemplate/edit/cust_main/select-country.html b/httemplate/edit/cust_main/select-country.html deleted file mode 100644 index 014effd66..000000000 --- a/httemplate/edit/cust_main/select-country.html +++ /dev/null @@ -1,72 +0,0 @@ -<% - - my %opt = @_; - foreach my $opt (qw( county state country prefix onchange disabled )) { - $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); - } - - my $conf = new FS::Conf; - my $countrydefault = $conf->config('countrydefault') || 'US'; - -%> - -<%= include('/elements/xmlhttp.html', - 'url' => $p.'misc/states.cgi', - 'subs' => [ $opt{'prefix'}. 'get_states' ], - ) -%> - -<SCRIPT TYPE="text/javascript"> - - function opt(what,value,text) { - var optionName = new Option(text, value, false, false); - var length = what.length; - what.options[length] = optionName; - } - - function <%= $opt{'prefix'} %>country_changed(what, callback) { - - country = what.options[what.selectedIndex].text; - - function <%= $opt{'prefix'} %>update_states(states) { - - // blank the current state list - for ( var i = what.form.<%= $opt{'prefix'} %>state.length; i >= 0; i-- ) - what.form.<%= $opt{'prefix'} %>state.options[i] = null; - - // add the new states - var statesArray = eval('(' + states + ')' ); - for ( var s = 0; s < statesArray.length; s++ ) { - var stateLabel = statesArray[s]; - if ( stateLabel == "" ) - stateLabel = '(n/a)'; - opt(what.form.<%= $opt{'prefix'} %>state, statesArray[s], stateLabel); - } - - //run the callback - if ( callback != null ) - callback(); - } - - // go get the new states - <%= $opt{'prefix'} %>get_states( country, <%= $opt{'prefix'} %>update_states ); - - } - -</SCRIPT> - -<SELECT NAME="<%= $opt{'prefix'} %>country" onChange="<%= $opt{'prefix'} %>country_changed(this); <%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>> - -<% foreach my $country ( - sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) or $a cmp $b } - map { $_->country } - qsearch( 'cust_main_county',{}, 'DISTINCT ON ( country ) *', ) - ) { -%> - - <OPTION VALUE="<%= $country %>"<%= $country eq $opt{'country'} ? ' SELECTED' : '' %>><%= $country %> - -<% } %> - -</SELECT> - diff --git a/httemplate/edit/cust_main/select-county.html b/httemplate/edit/cust_main/select-county.html deleted file mode 100644 index 3de380b31..000000000 --- a/httemplate/edit/cust_main/select-county.html +++ /dev/null @@ -1,91 +0,0 @@ -<% - - my %opt = @_; - foreach my $opt (qw( county state country prefix onchange disabled )) { - $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); - } - - my $sql = "SELECT COUNT(*) FROM cust_main_county". - " WHERE county IS NOT NULL AND county != ''"; - my $sth = dbh->prepare($sql) or die dbh->errstr; - $sth->execute or die $sth->errstr; - my $countyflag = $sth->fetchrow_arrayref->[0]; - -%> - -<% if ( $countyflag ) { %> - - <%= include('/elements/xmlhttp.html', - 'url' => $p.'misc/counties.cgi', - 'subs' => [ $opt{'prefix'}. 'get_counties' ], - ) -%> - - <SCRIPT TYPE="text/javascript"> - - function opt(what,value,text) { - var optionName = new Option(text, value, false, false); - var length = what.length; - what.options[length] = optionName; - } - - function <%= $opt{'prefix'} %>state_changed(what, callback) { - - state = what.options[what.selectedIndex].text; - country = what.form.<%= $opt{'prefix'} %>country.options[what.form.<%= $opt{'prefix'} %>country.selectedIndex].text; - - function <%= $opt{'prefix'} %>update_counties(counties) { - - // blank the current county list - for ( var i = what.form.<%= $opt{'prefix'} %>county.length; i >= 0; i-- ) - what.form.<%= $opt{'prefix'} %>county.options[i] = null; - - // add the new counties - var countiesArray = eval('(' + counties + ')' ); - for ( var s = 0; s < countiesArray.length; s++ ) { - var countyLabel = countiesArray[s]; - if ( countyLabel == "" ) - countyLabel = '(n/a)'; - opt(what.form.<%= $opt{'prefix'} %>county, countiesArray[s], countyLabel); - } - - //run the callback - if ( callback != null ) - callback(); - } - - // go get the new counties - <%= $opt{'prefix'} %>get_counties( state, country, <%= $opt{'prefix'} %>update_counties ); - - } - - </SCRIPT> - - <SELECT NAME="<%= $opt{'prefix'} %>county" onChange="<%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>> - - <% foreach my $county ( - sort - map { $_->county } - qsearch('cust_main_county', { 'state' => $opt{'state'}, - 'country' => $opt{'country'}, - } - ) - ) { - %> - - <OPTION VALUE="<%= $county %>"<%= $county eq $opt{'county'} ? ' SELECTED' : '' %>><%= $county %> - - <% } %> - - </SELECT> - -<% } else { %> - - <SCRIPT TYPE="text/javascript"> - function <%= $opt{'prefix'} %>state_changed(what) { - } - </SCRIPT> - - <INPUT TYPE="hidden" NAME="<%= $opt{'prefix'} %>county" VALUE="<%= $opt{'county'} %>"> - -<% } %> diff --git a/httemplate/edit/cust_main/select-state.html b/httemplate/edit/cust_main/select-state.html deleted file mode 100644 index 98e685ab8..000000000 --- a/httemplate/edit/cust_main/select-state.html +++ /dev/null @@ -1,27 +0,0 @@ -<% - - my %opt = @_; - foreach my $opt (qw( county state country prefix onchange disabled )) { - $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); - } - -%> - -<SELECT NAME="<%= $opt{'prefix'} %>state" onChange="<%= $opt{'prefix'} %>state_changed(this); <%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>> - -<% foreach my $state ( - sort - map { $_->state } - qsearch( 'cust_main_county', - { 'country' => $opt{'country'} }, - 'DISTINCT ON ( state ) *', - ) - ) { -%> - - <OPTION VALUE="<%= $state %>"<%= $state eq $opt{'state'} ? ' SELECTED' : '' %>><%= $state || '(n/a)' %> - -<% } %> - -</SELECT> - diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index 0370ab726..c0a679b03 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -1,14 +1,8 @@ +<!-- mason kludge --> <% my $conf = new FS::Conf; -my %payby = ( - 'BILL' => 'Check', - 'CASH' => 'Cash', - 'WEST' => 'Western Union', - 'MCRD' => 'Manual credit card', -); - my($link, $linknum, $paid, $payby, $payinfo, $quickpay, $_date); if ( $cgi->param('error') ) { $link = $cgi->param('link'); @@ -18,29 +12,31 @@ if ( $cgi->param('error') ) { $payinfo = $cgi->param('payinfo'); $quickpay = $cgi->param('quickpay'); $_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time; -} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { - $link = 'custnum'; - $linknum = $1; - $paid = ''; - $payby = $cgi->param('payby') || 'BILL'; - $payinfo = ''; - $quickpay = $cgi->param('quickpay'); - $_date = time; -} elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) { +} elsif ($cgi->keywords) { + my($query) = $cgi->keywords; + $query =~ /^(\d+)$/; $link = 'invnum'; $linknum = $1; $paid = ''; - $payby = $cgi->param('payby') || 'BILL'; + $payby = 'BILL'; $payinfo = ""; $quickpay = ''; $_date = time; +} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { + $link = 'custnum'; + $linknum = $1; + $paid = ''; + $payby = 'BILL'; + $payinfo = ''; + $quickpay = $cgi->param('quickpay'); + $_date = time; } else { die "illegal query ". $cgi->keywords; } my $paybatch = "webui-$_date-$$-". rand() * 2**32; -my $title = 'Post '. $payby{$payby}. ' payment'; +my $title = 'Post payment'; $title .= " against Invoice #$linknum" if $link eq 'invnum'; %> @@ -101,17 +97,12 @@ Payment <TR> <TD ALIGN="right">Amount</TD> <TD BGCOLOR="#ffffff" ALIGN="right"><%= $money_char %></TD> - <TD><INPUT TYPE="text" NAME="paid" VALUE="<%= $paid %>" SIZE=8 MAXLENGTH=8> by <B><%= $payby{$payby} %></B></TD> + <TD><INPUT TYPE="text" NAME="paid" VALUE="<%= $paid %>" SIZE=8 MAXLENGTH=8></TD> +</TR> +<TR> + <TD ALIGN="right">Check #</TD> + <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<%= $payinfo %>" SIZE=10></TD> </TR> - -<% if ( $payby eq 'BILL' ) { %> - - <TR> - <TD ALIGN="right">Check #</TD> - <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<%= $payinfo %>" SIZE=10></TD> - </TR> - -<% } %> <TR> <% if ( $link eq 'custnum' ) { %> diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi index 32ca47af4..06bdaf647 100755 --- a/httemplate/edit/part_bill_event.cgi +++ b/httemplate/edit/part_bill_event.cgi @@ -94,9 +94,6 @@ sub select_agentnum { '</SELECT>'; } -my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; - #this is pretty kludgy right here. tie my %events, 'Tie::IxHash', @@ -113,12 +110,6 @@ tie my %events, 'Tie::IxHash', 'code' => '$cust_main->suspend();', 'weight' => 10, }, - 'suspend' => { - 'name' => 'Suspend if balance (this invoice and previous) over', - 'code' => '$cust_bill->cust_suspend_if_balance_over( %%%balanceover%%% );', - 'html' => " $money_char ". '<INPUT TYPE="text" SIZE="7" NAME="balanceover" VALUE="%%%balanceover%%%">', - 'weight' => 10, - }, 'suspend-if-pkgpart' => { 'name' => 'Suspend packages', 'code' => '$cust_main->suspend_if_pkgpart(%%%if_pkgpart%%%);', @@ -223,26 +214,13 @@ tie my %events, 'Tie::IxHash', 'send_csv_ftp' => { 'name' => 'Upload CSV invoice data to an FTP server', - 'code' => '$cust_bill->send_csv( protocol => \'ftp\', - server => \'%%%ftpserver%%%\', - username => \'%%%ftpusername%%%\', - password => \'%%%ftppassword%%%\', - dir => \'%%%ftpdir%%%\', - \'format\' => \'%%%ftpformat%%%\', - );', + 'code' => '$cust_bill->send_csv( protocol => \'ftp\', + server => \'%%%ftpserver%%%\', + username => \'%%%ftpusername%%%\', + password => \'%%%ftppassword%%%\', + dir => \'%%%ftpdir%%%\' );', 'html' => - '<TABLE BORDER=0>'. - '<TR><TD ALIGN="right">Format ("default" or "billco"): </TD>'. - '<TD>'. - '<!--'. - '<SELECT NAME="ftpformat">'. - '<OPTION VALUE="default">Default'. - '<OPTION VALUE="billco">Billco'. - '</SELECT>'. - '-->'. - '<INPUT TYPE="text" NAME="ftpformat" VALUE="%%%ftpformat%%%">'. - '</TD></TR>'. - '<TR><TD ALIGN="right">FTP server: </TD>'. + '<TABLE BORDER=0><TR><TD ALIGN="right">FTP server: </TD>'. '<TD><INPUT TYPE="text" NAME="ftpserver" VALUE="%%%ftpserver%%%">'. '</TD></TR>'. '<TR><TD ALIGN="right">FTP username: </TD><TD>'. @@ -258,63 +236,6 @@ tie my %events, 'Tie::IxHash', 'weight' => 50, }, - 'spool_csv' => { - 'name' => 'Spool CSV invoice data', - 'code' => '$cust_bill->spool_csv( - \'format\' => \'%%%spoolformat%%%\', - \'dest\' => \'%%%spooldest%%%\', - \'agent_spools\' => \'%%%spoolagent_spools%%%\', - );', - 'html' => sub { - my $plandata = shift; - - my $html = - '<TABLE BORDER=0>'. - '<TR><TD ALIGN="right">Format: </TD>'. - '<TD>'. - '<SELECT NAME="spoolformat">'; - - foreach my $option (qw( default billco )) { - $html .= qq(<OPTION VALUE="$option"); - $html .= ' SELECTED' if $option eq $plandata->{'spoolformat'}; - $html .= ">\u$option"; - } - - $html .= - '</SELECT>'. - '</TD></TR>'. - '<TR><TD ALIGN="right">For destination: </TD>'. - '<TD>'. - '<SELECT NAME="spooldest">'; - - tie my %dest, 'Tie::IxHash', - '' => '(all)', - 'POST' => 'Postal Mail', - 'EMAIL' => 'Email', - 'FAX' => 'Fax', - ; - - foreach my $dest (keys %dest) { - $html .= qq(<OPTION VALUE="$dest"); - $html .= ' SELECTED' if $dest eq $plandata->{'spooldest'}; - $html .= '>'. $dest{$dest}; - } - - $html .= - '</SELECT>'. - '</TD></TR>'. - '<TR><TD ALIGN="right">Individual per-agent spools? </TD>'. - '<TD><INPUT TYPE="checkbox" NAME="spoolagent_spools" VALUE="1" '. - ( $plandata->{'spoolagent_spools'} ? 'CHECKED' : '' ). - '>'. - '</TD></TR>'. - '</TABLE>'; - - $html; - }, - 'weight' => 50, - }, - 'bill' => { 'name' => 'Generate invoices (normally only used with a <i>Late Fee</i> event)', 'code' => '$cust_main->bill();', diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 60365f628..128775619 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,3 +1,4 @@ +<!-- mason kludge --> <% if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { @@ -28,7 +29,7 @@ if ( $cgi->param('clone') ) { $action = 'Custom Pricing'; $clone_part_pkg= qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } ); $part_pkg ||= $clone_part_pkg->clone; - $part_pkg->disabled('Y'); #isn't sticky on errors + $part_pkg->disabled('Y'); } elsif ( $query && $query =~ /^(\d+)$/ ) { $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); $pkgpart = $part_pkg->pkgpart; @@ -59,8 +60,21 @@ my $hashref = $part_pkg->hashref; <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> <% } %> +<% #print '<FORM ACTION="', popurl(1), 'process/part_pkg.cgi" METHOD=POST>'; %> + <FORM NAME="dummy"> +<% +#if ( $cgi->param('clone') ) { +# print qq!<INPUT TYPE="hidden" NAME="clone" VALUE="!, $cgi->param('clone'), qq!">!; +#} +#if ( $cgi->param('pkgnum') ) { +# print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="!, $cgi->param('pkgnum'), qq!">!; +#} +# +#print qq!<INPUT TYPE="hidden" NAME="pkgpart" VALUE="$hashref->{pkgpart}">!, +%> + <%= itable('',8,1) %><TR><TD VALIGN="top"> Package information @@ -106,31 +120,42 @@ Tax information <TR> <TD ALIGN="right">Setup fee tax exempt</TD> <TD> - <INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <%= $hashref->{setuptax} eq 'Y' ? ' CHECKED' : '' %>> - </TD> - </TR> - <TR> - <TD ALIGN="right">Recurring fee tax exempt</TD> - <TD> - <INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y" <%= $hashref->{recurtax} eq 'Y' ? ' CHECKED' : '' %>> - </TD> - </TR> +<% -<% my $conf = new FS::Conf; %> -<% if ( $conf->exists('enable_taxclasses') ) { %> +print '<INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y"'; +print ' CHECKED' if $hashref->{setuptax} eq "Y"; +print '>'; - <TR> - <TD align="right">Tax class</TD> - <TD> - <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> - </TD> - </TR> +print <<END; +</TD></TR> +<TR><TD ALIGN="right">Recurring fee tax exempt</TD><TD> +END -<% } else { %> +print '<INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y"'; +print ' CHECKED' if $hashref->{recurtax} eq "Y"; +print '>'; - <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> +print '</TD></TR>'; -<% } %> +my $conf = new FS::Conf; +#false laziness w/ view/cust_main.cgi quick order +if ( $conf->exists('enable_taxclasses') ) { + print '<TR><TD ALIGN="right">Tax class</TD><TD><SELECT NAME="taxclass">'; + my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county') + or die dbh->errstr; + $sth->execute or die $sth->errstr; + foreach my $taxclass ( map $_->[0], @{$sth->fetchall_arrayref} ) { + print qq!<OPTION VALUE="$taxclass"!; + print ' SELECTED' if $taxclass eq $hashref->{taxclass}; + print qq!>$taxclass</OPTION>!; + } + print '</SELECT></TD></TR>'; +} else { + print + '<INPUT TYPE="hidden" NAME="taxclass" VALUE="'. $hashref->{taxclass}. '">'; +} + +%> </TABLE> @@ -144,13 +169,15 @@ $thead .= '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Primary</FONT></TH>' if dbdef->table('pkg_svc')->column('primary_svc'); $thead .= '<TH BGCOLOR="#dcdcdc">Service</TH></TR>'; -%> - -<%= itable('', 4, 1) %><TR><TD VALIGN="top"> +#unless ( $cgi->param('clone') ) { +#dunno why... +unless ( 0 ) { + #print <<END, $thead; + print <<END, itable('', 4, 1), '<TR><TD VALIGN="top">', $thead; <BR><BR>Services included -<%= $thead %> +END +} -<% my $where = "WHERE disabled IS NULL OR disabled = ''"; if ( $pkgpart ) { @@ -160,60 +187,64 @@ if ( $pkgpart ) { )"; } my @part_svc = qsearch('part_svc', {}, '', $where); -my $q_part_pkg = $clone_part_pkg || $part_pkg; -my %pkg_svc = map { $_->svcpart => $_ } $q_part_pkg->pkg_svc; my @fixups = (); my $count = 0; my $columns = 3; foreach my $part_svc ( @part_svc ) { my $svcpart = $part_svc->svcpart; - my $pkg_svc = $pkg_svc{$svcpart} - || new FS::pkg_svc ( { - 'pkgpart' => $pkgpart, - 'svcpart' => $svcpart, - 'quantity' => 0, - 'primary_svc' => '', - } ); + my $pkg_svc = $pkgpart && qsearchs( 'pkg_svc', { + 'pkgpart' => $pkgpart, + 'svcpart' => $svcpart, + } ) || new FS::pkg_svc ( { + 'pkgpart' => $pkgpart, + 'svcpart' => $svcpart, + 'quantity' => 0, + 'primary_svc' => '', + }); + #? #next unless $pkg_svc; push @fixups, "pkg_svc$svcpart"; -%> - - <TR> - <TD> - <INPUT TYPE="text" NAME="pkg_svc<%= $svcpart %>" SIZE=4 MAXLENGTH=3 VALUE="<%= $cgi->param("pkg_svc$svcpart") || $pkg_svc->quantity || 0 %>"> - </TD> - - <TD> - <INPUT TYPE="radio" NAME="pkg_svc_primary" VALUE="<%= $svcpart %>" <%= $pkg_svc->primary_svc =~ /^Y/i ? ' CHECKED' : '' %>> - </TD> - - <TD> - <A HREF="part_svc.cgi?<%= $part_svc->svcpart %>"><%= $part_svc->svc %></A> <%= $part_svc->disabled =~ /^Y/i ? ' (DISABLED' : '' %> - </TD> - </TR> - - <% $count++; - foreach ( 1 .. $columns-1 ) { - if ( $count == int( $_ * scalar(@part_svc) / $columns ) ) { - %> - </TABLE></TD><TD VALIGN="top"><%= $thead %> - - <% } - } - %> - -<% } %> - -</TR></TABLE></TD></TR></TABLE> + #unless ( defined ($cgi->param('clone')) && $cgi->param('clone') ) { + #dunno why... + unless ( 0 ) { + print '<TR>'; # if $count == 0 ; + print qq!<TD><INPUT TYPE="text" NAME="pkg_svc$svcpart" SIZE=4 MAXLENGTH=3 VALUE="!, + $cgi->param("pkg_svc$svcpart") || $pkg_svc->quantity || 0, + qq!"></TD>!; + if ( dbdef->table('pkg_svc')->column('primary_svc') ) { + print qq!<TD><INPUT TYPE="radio" NAME="pkg_svc_primary" VALUE="$svcpart"!; + print ' CHECKED' if $pkg_svc->primary_svc =~ /^Y/i; + print '></TD>'; + } + print qq!<TD><A HREF="part_svc.cgi?!,$part_svc->svcpart, + qq!">!, $part_svc->getfield('svc'), '</A>'; + print ' (DISABLED)' if $part_svc->disabled =~ /^Y/i; + print '</TD></TR>'; +# print "</TABLE></TD><TD>$thead" if ++$count == int(scalar(@part_svc) / 2); + $count+=1; + foreach ( 1 .. $columns-1 ) { + print "</TABLE></TD><TD VALIGN=\"top\">$thead" + if $count == int( $_ * scalar(@part_svc) / $columns ); + } + } else { + print qq!<INPUT TYPE="hidden" NAME="pkg_svc$svcpart" VALUE="!, + $cgi->param("pkg_svc$svcpart") || $pkg_svc->quantity || 0, qq!">\n!; + } +} -<% foreach my $f ( qw( clone pkgnum ) ) { %> - <INPUT TYPE="hidden" NAME="<%= $f %>" VALUE="<%= $cgi->param($f) %>"> -<% } %> -<INPUT TYPE="hidden" NAME="pkgpart" VALUE="<%= $part_pkg->pkgpart %>"> +#unless ( $cgi->param('clone') ) { +#dunno why... +unless ( 0 ) { + print "</TR></TABLE></TD></TR></TABLE>"; + #print "</TR></TABLE>"; +} -<% +foreach my $f ( qw( clone pkgnum ) ) { + print qq!<INPUT TYPE="hidden" NAME="$f" VALUE="!. $cgi->param($f). '">'; +} +print '<INPUT TYPE="hidden" NAME="pkgpart" VALUE="'. $part_pkg->pkgpart. '">'; # prolly should be in database tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() }; diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 9749fc12d..3540a421e 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -23,6 +23,7 @@ my $hashref = $part_svc->hashref; #" onLoad=\"visualize()\"" %> +<!-- mason kludge --> <%= header("$action Service Definition", menubar( 'Main Menu' => $p, 'View all service definitions' => "${p}browse/part_svc.cgi" @@ -97,7 +98,7 @@ my %defs = ( select_label => 'domain', }, 'usergroup' => { - desc =>'RADIUS groups', + desc =>'ICRADIUS/FreeRADIUS groups', type =>'radius_usergroup_selector', }, }, @@ -193,7 +194,7 @@ my %defs = ( $html .= table(). "<TH>Field</TH><TH COLSPAN=2>Modifier</TH>"; #yucky kludge - my @fields = defined( dbdef->table($layer) ) + my @fields = defined( $FS::Record::dbdef->table($layer) ) ? grep { $_ ne 'svcnum' } fields($layer) : (); push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge diff --git a/httemplate/edit/payment_gateway.html b/httemplate/edit/payment_gateway.html deleted file mode 100644 index 33cc236d0..000000000 --- a/httemplate/edit/payment_gateway.html +++ /dev/null @@ -1,109 +0,0 @@ -<% - -my $payment_gateway; -if ( $cgi->param('error') ) { - $payment_gateway = new FS::payment_gateway ( { - map { $_, scalar($cgi->param($_)) } fields('payment_gateway') - } ); -} elsif ( $cgi->keywords ) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $payment_gateway = qsearchs( 'payment_gateway', { 'gatewaynum' => $1 } ); -} else { #adding - $payment_gateway = new FS::payment_gateway {}; -} -my $action = $payment_gateway->gatewaynum ? 'Edit' : 'Add'; -#my $hashref = $payment_gateway->hashref; - -%> - -<%= header("$action Payment gateway", menubar( - 'Main Menu' => $p, - 'View all payment gateways' => $p. 'browse/payment_gateway.html', -)) %> - -<% if ( $cgi->param('error') ) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> - -<FORM ACTION="<%=popurl(1)%>process/payment_gateway.html" METHOD=POST> -<INPUT TYPE="hidden" NAME="gatewaynum" VALUE="<%= $payment_gateway->gatewaynum %>"> -Gateway #<%= $payment_gateway->gatewaynum || "(NEW)" %> - -<%= ntable('#cccccc', 2, '') %> - -<TR> - <TH ALIGN="right">Gateway: </TH> - <TD><SELECT NAME="gateway_module" SIZE=1> - <% foreach my $module ( qw( - 2CheckOut - AuthorizeNet - BankOfAmerica - Beanstream - Capstone - Cardstream - CashCow - CyberSource - eSec - eSelectPlus - Exact - iAuthorizer - IPaymentTPG - Jettis - LinkPoint - MerchantCommerce - Network1Financial - OCV - OpenECHO - PayConnect - PayflowPro - PaymentsGateway - PXPost - SecureHostingUPG - Skipjack - StGeorge - SurePay - TCLink - TransactionCentral - VirtualNet - ) ) { - %> - <OPTION VALUE="<%= $module %>"><%= $module %> - <% } %> - </SELECT> - </TD> -</TR> - -<TR> - <TH ALIGN="right">Username: </TH> - <TD><INPUT TYPE="text" NAME="gateway_username"></TD> -</TR> - -<TR> - <TH ALIGN="right">Password: </TH> - <TD><INPUT TYPE="text" NAME="gateway_password"></TD> -</TR> - -<TR> - <TH ALIGN="right">Action: </TH> - <TD> - <SELECT NAME="gateway_action" SIZE=1> - <OPTION VALUE="Normal Authorization">Normal Authorization - <OPTION VALUE="Authorization Only">Authorization Only - <OPTION VALUE="Authorization Only, Post Authorization">Authorization Only, Post Authorization - </SELECT> - </TD> -</TR> - -<TR> - <TH ALIGN="right">Options: </TH> - <TD><TEXTAREA ROWS="5" NAME="gateway_options"></TEXTAREA></TD> -</TR> - -</TABLE> - -<BR><INPUT TYPE="submit" VALUE="<%= $payment_gateway->gatewaynum ? "Apply changes" : "Add gateway" %>"> - </FORM> - </BODY> -</HTML> - diff --git a/httemplate/edit/process/agent_payment_gateway.html b/httemplate/edit/process/agent_payment_gateway.html deleted file mode 100644 index c306bfa3f..000000000 --- a/httemplate/edit/process/agent_payment_gateway.html +++ /dev/null @@ -1,25 +0,0 @@ -<% - -$cgi->param('agentnum') =~ /(\d+)$/ or die "illegal agentnum"; -my $agent = qsearchs('agent', { 'agentnum' => $1 } ); -die "agentnum $1 not found" unless $agent; - -#my $old - -my @new = map { - my $cardtype = $_; - new FS::agent_payment_gateway { - ( map { $_ => scalar($cgi->param($_)) } - fields('agent_payment_gateway') - ), - 'cardtype' => $cardtype, - }; - } - $cgi->param('cardtype'); - -foreach my $new (@new) { - my $error = $new->insert; - die $error if $error; -} - -%><%= $cgi->redirect(popurl(3). "browse/agent.cgi") %> diff --git a/httemplate/edit/process/bulk-cust_svc.cgi b/httemplate/edit/process/bulk-cust_svc.cgi deleted file mode 100644 index dd9d1dbd2..000000000 --- a/httemplate/edit/process/bulk-cust_svc.cgi +++ /dev/null @@ -1,3 +0,0 @@ -<% - my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process_bulk_cust_svc', $cgi; -%><%= $server->process %> diff --git a/httemplate/edit/process/cust_credit_bill.cgi b/httemplate/edit/process/cust_credit_bill.cgi index 28f892f62..23e2e6ce5 100755 --- a/httemplate/edit/process/cust_credit_bill.cgi +++ b/httemplate/edit/process/cust_credit_bill.cgi @@ -14,12 +14,11 @@ my $custnum = $cust_main->custnum; my $new; if ($cgi->param('invnum') =~ /^Refund$/) { $new = new FS::cust_refund ( { - 'reason' => ( $cust_credit->reason || 'refund from credit' ), + 'reason' => $cust_credit->reason, 'refund' => $cgi->param('amount'), 'payby' => 'BILL', #'_date' => $cgi->param('_date'), - #'payinfo' => 'Cash', - 'payinfo' => 'Refund', + 'payinfo' => 'Cash', 'crednum' => $crednum, } ); } else { diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 09a42544c..d2773a60e 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -8,25 +8,19 @@ $cgi->param('tax','') unless defined $cgi->param('tax'); $cgi->param('refnum', (split(/:/, ($cgi->param('refnum'))[0] ))[0] ); -#my $payby = $cgi->param('payby'); -my $payby = $cgi->param('select'); # XXX key - -my %noauto = ( - 'CARD' => 'DCRD', - 'CHEK' => 'DCHK', -); -$payby = $noauto{$payby} - if ! $cgi->param('payauto') && exists $noauto{$payby}; - -$cgi->param('payby', $payby); - +my $payby = $cgi->param('payby'); if ( $payby ) { if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) { $cgi->param('payinfo', - $cgi->param('payinfo1'). '@'. $cgi->param('payinfo2') ); + $cgi->param($payby. '_payinfo1'). '@'. $cgi->param($payby. '_payinfo2') ); + } else { + $cgi->param('payinfo', $cgi->param( $payby. '_payinfo' ) ); } $cgi->param('paydate', - $cgi->param( 'exp_month' ). '-'. $cgi->param( 'exp_year' ) ); + $cgi->param( $payby. '_month' ). '-'. $cgi->param( $payby. '_year' ) ); + $cgi->param('payname', $cgi->param( $payby. '_payname' ) ); + $cgi->param('paycvv', $cgi->param( $payby. '_paycvv' ) ) + if defined $cgi->param( $payby. '_paycvv' ); } my @invoicing_list = split( /\s*\,\s*/, $cgi->param('invoicing_list') ); @@ -53,9 +47,6 @@ if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { ); } -$new->setfield('paid', $cgi->param('paid') ) - if $cgi->param('paid'); - #perhaps this stuff should go to cust_main.pm my $cust_pkg = ''; my $svc_acct = ''; @@ -121,20 +112,7 @@ if ( $new->custnum eq '' ) { tie my %hash, 'Tie::RefHash'; %hash = ( $cust_pkg => [ $svc_acct ] ) if $cust_pkg; $error ||= $new->insert( \%hash, \@invoicing_list ); - - my $conf = new FS::Conf; - if ( $conf->exists('backend-realtime') && ! $error ) { - - my $berror = $new->bill; - $new->apply_payments; - $new->apply_credits; - $berror ||= $new->collect; - warn "Warning, error billing during backend-realtime: $berror" if $berror; - - } - } else { #create old record object - my $old = qsearchs( 'cust_main', { 'custnum' => $new->custnum } ); $error ||= "Old record not found!" unless $old; if ( defined dbdef->table('cust_main')->column('paycvv') @@ -143,7 +121,6 @@ if ( $new->custnum eq '' ) { $new->paycvv($old->paycvv); } $error ||= $new->replace($old, \@invoicing_list); - } if ( $error ) { diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 0d0a13491..1a7f52838 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -29,18 +29,12 @@ my %pkg_svc = map { $_ => scalar($cgi->param("pkg_svc$_")) } my $error; my $custnum = ''; -if ( $cgi->param('taxclass') eq '(select)' ) { - - $error = 'Must select a tax class'; - -} elsif ( $pkgpart ) { - +if ( $pkgpart ) { $error = $new->replace( $old, pkg_svc => \%pkg_svc, primary_svc => scalar($cgi->param('pkg_svc_primary')), ); } else { - $error = $new->insert( pkg_svc => \%pkg_svc, primary_svc => scalar($cgi->param('pkg_svc_primary')), cust_pkg => $cgi->param('pkgnum'), @@ -48,7 +42,6 @@ if ( $cgi->param('taxclass') eq '(select)' ) { ); $pkgpart = $new->pkgpart; } - if ( $error ) { $cgi->param('error', $error ); print $cgi->redirect(popurl(2). "part_pkg.cgi?". $cgi->query_string ); diff --git a/httemplate/edit/process/part_svc.cgi b/httemplate/edit/process/part_svc.cgi index b92b62739..664e5212a 100755 --- a/httemplate/edit/process/part_svc.cgi +++ b/httemplate/edit/process/part_svc.cgi @@ -1,3 +1,4 @@ <% - my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process', $cgi; -%><%= $server->process %> +my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process'; +$server->process; +%> diff --git a/httemplate/edit/process/payment_gateway.html b/httemplate/edit/process/payment_gateway.html deleted file mode 100644 index b9e4d47da..000000000 --- a/httemplate/edit/process/payment_gateway.html +++ /dev/null @@ -1,33 +0,0 @@ -<% - -my $gatewaynum = $cgi->param('gatewaynum'); - -my $old = qsearchs('payment_gateway',{'gatewaynum'=>$gatewaynum}) if $gatewaynum; - -my $new = new FS::payment_gateway ( { - map { - $_, scalar($cgi->param($_)); - } fields('payment_gateway') -} ); - -my @options = split(/\r?\n/, $cgi->param('gateway_options') ); -pop @options - if scalar(@options) % 2 && $options[-1] =~ /^\s*$/; -my %options = @options; - -my $error; -if ( $gatewaynum ) { - $error=$new->replace($old); -} else { - $error=$new->insert(\%options); - $gatewaynum=$new->getfield('gatewaynum'); -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "payment_gateway.html?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "browse/payment_gateway.html"); -} - -%> diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 928e3daad..477f58508 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -9,24 +9,15 @@ $cgi->param('amount') =~ /^\s*(\d+(\.\d{1,2})?)\s*$/ or die 'illegal amount '. $cgi->param('amount'); my $amount = $1; -my( $error, $cust_main); -if ( $cgi->param('taxclass') eq '(select)' ) { - - - $error = 'Must select a tax class'; -} else { - - my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) - or die "unknown custnum $custnum"; - - $error = $cust_main->charge( - $amount, - $cgi->param('pkg'), - '$'. sprintf("%.2f",$amount), - $cgi->param('taxclass') - ); - -} +my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or die "unknown custnum $custnum"; + +my $error = $cust_main->charge( + $amount, + $cgi->param('pkg'), + '$'. sprintf("%.2f",$amount), + $cgi->param('taxclass') +); if ($error) { %> diff --git a/httemplate/edit/process/rate.cgi b/httemplate/edit/process/rate.cgi index 87c082d64..005caf90a 100755 --- a/httemplate/edit/process/rate.cgi +++ b/httemplate/edit/process/rate.cgi @@ -1,3 +1,4 @@ <% - my $server = new FS::UI::Web::JSRPC 'FS::rate::process', $cgi; -%><%= $server->process %> +my $server = new FS::UI::Web::JSRPC 'FS::rate::process'; +$server->process; +%> diff --git a/httemplate/edit/rate.cgi b/httemplate/edit/rate.cgi index 1771f0105..ce56768d1 100644 --- a/httemplate/edit/rate.cgi +++ b/httemplate/edit/rate.cgi @@ -17,12 +17,12 @@ my %granularity = ( '60' => 'minute', ); -#my $nous = <<END; -# WHERE 0 < ( SELECT COUNT(*) FROM rate_prefix -# WHERE rate_region.regionnum = rate_prefix.regionnum -# AND countrycode != '1' -# ) -#END +my $nous = <<END; + WHERE 0 < ( SELECT COUNT(*) FROM rate_prefix + WHERE rate_region.regionnum = rate_prefix.regionnum + AND countrycode != '1' + ) +END %> @@ -56,17 +56,11 @@ Rate plan </TR> <% foreach my $rate_region ( - sort { lc($a->regionname) cmp lc($b->regionname) } - qsearch({ - 'select' => 'DISTINCT ON ( regionnum ) rate_region.*', - 'table' => 'rate_region', - 'addl_from' => 'INNER JOIN rate_prefix USING ( regionnum )', - 'hashref' => {}, - 'extra_sql' => "WHERE countrycode != '1'", - # 'ORDER BY regionname' - # ERROR: SELECT DISTINCT ON expressions must - # match initial ORDER BY expressions - }) + qsearch( 'rate_region', + {}, + '', + "$nous ORDER BY regionname", + ) ) { my $n = $rate_region->regionnum; my $rate_detail = @@ -76,7 +70,6 @@ Rate plan 'sec_granularity' => '60' }; %> - <TR> <TD><A HREF="<%=$p%>edit/rate_region.cgi?<%= $rate_region->regionnum %>"><%= $rate_region->regionname %></A></TD> <TD><%= $rate_region->prefixes_short %></TD> @@ -89,7 +82,6 @@ Rate plan <% } %> </SELECT> </TR> - <% } %> <TR> diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index e74d84d53..f1b8b800b 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -1,3 +1,4 @@ +<!-- mason kludge --> <% my $conf = new FS::Conf; @@ -5,7 +6,6 @@ my @shells = $conf->config('shells'); my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups); if ( $cgi->param('error') ) { - $svc_acct = new FS::svc_acct ( { map { $_, scalar($cgi->param($_)) } fields('svc_acct') } ); @@ -15,9 +15,7 @@ if ( $cgi->param('error') ) { $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); die "No part_svc entry for svcpart $svcpart!" unless $part_svc; @groups = $cgi->param('radius_usergroup'); - } else { - my($query) = $cgi->keywords; if ( $query =~ /^(\d+)$/ ) { #editing $svcnum=$1; @@ -48,43 +46,35 @@ if ( $cgi->param('error') ) { $svcnum=''; - } -} - -my( $cust_pkg, $cust_main ) = ( '', '' ); -if ( $pkgnum ) { - $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } ); - $cust_main = $cust_pkg->cust_main; -} - -unless ( $svcnum || $cgi->param('error') ) { #adding - - #set gecos - if ($cust_main) { - unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) { - $svc_acct->setfield('finger', - $cust_main->getfield('first') . " " . $cust_main->getfield('last') - ); + #set gecos + my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); + if ($cust_pkg) { + my($cust_main)=qsearchs('cust_main',{'custnum'=> $cust_pkg->custnum } ); + unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) { + $svc_acct->setfield('finger', + $cust_main->getfield('first') . " " . $cust_main->getfield('last') + ); + } } - } - #set fixed and default fields from part_svc - foreach my $part_svc_column ( - grep { $_->columnflag } $part_svc->all_part_svc_column - ) { - if ( $part_svc_column->columnname eq 'usergroup' ) { - @groups = split(',', $part_svc_column->columnvalue); - } else { - $svc_acct->setfield( $part_svc_column->columnname, - $part_svc_column->columnvalue, - ); + #set fixed and default fields from part_svc + foreach my $part_svc_column ( + grep { $_->columnflag } $part_svc->all_part_svc_column + ) { + if ( $part_svc_column->columnname eq 'usergroup' ) { + @groups = split(',', $part_svc_column->columnvalue); + } else { + $svc_acct->setfield( $part_svc_column->columnname, + $part_svc_column->columnvalue, + ); + } } - } + } } #fixed radius groups always override & display -if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) { +if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) { @groups = split(',', $part_svc->part_svc_column('usergroup')->columnvalue); } @@ -106,91 +96,55 @@ if ( $svc_acct->_password ) { $password = ''; } -my $ulen = - $conf->exists('usernamemax') - ? $conf->config('usernamemax') - : dbdef->table('svc_acct')->column('username')->length; +my $ulen = $conf->config('usernamemax') + || $svc_acct->dbdef_table->column('username')->length; my $ulen2 = $ulen+2; my $pmax = $conf->config('passwordmax') || 8; my $pmax2 = $pmax+2; my $p1 = popurl(1); - -%> - -<%= header("$action $svc account") %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> - <BR><BR> -<% } %> - -<% if ( $cust_main ) { %> - <%= include( '/elements/small_custview.html', $cust_main, '', 1 ) %> - <BR> -<% } %> - -<FORM NAME="OneTrueForm" ACTION="<%= $p1 %>process/svc_acct.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%= $svcnum %>"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> -<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>"> - -Service # <%= $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR> - -<%= ntable("#cccccc",2) %> - -<TR> - <TD ALIGN="right">Service</TD> - <TD BGCOLOR="#eeeeee"><%= $part_svc->svc %></TD> -</TR> - -<TR> - <TD ALIGN="right">Username</TD> - <TD> - <INPUT TYPE="text" NAME="username" VALUE="<%= $username %>" SIZE=<%= $ulen2 %> MAXLENGTH=<%= $ulen %>> - </TD> -</TR> - -<TR> - <TD ALIGN="right">Password</TD> - <TD> - <INPUT TYPE="text" NAME="_password" VALUE="<%= $password %>" SIZE=<%= $pmax2 %> MAXLENGTH=<%= $pmax %>> - (blank to generate) - </TD> +print header("$action $svc account"); + +print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), + "</FONT><BR><BR>" + if $cgi->param('error'); + +print 'Service # '. ( $svcnum ? "<B>$svcnum</B>" : " (NEW)" ). '<BR>'. + 'Service: <B>'. $part_svc->svc. '</B><BR><BR>'. + <<END; + <FORM NAME="OneTrueForm" ACTION="${p1}process/svc_acct.cgi" METHOD=POST> + <INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum"> + <INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum"> + <INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart"> +END + +print &ntable("#cccccc",2), <<END; +<TR><TD ALIGN="right">Username</TD> +<TD><INPUT TYPE="text" NAME="username" VALUE="$username" SIZE=$ulen2 MAXLENGTH=$ulen></TD></TR> +<TR><TD ALIGN="right">Password</TD> +<TD><INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=$pmax2 MAXLENGTH=$pmax> +(blank to generate)</TD> </TR> +END - -<% my $sec_phrase = $svc_acct->sec_phrase; if ( $conf->exists('security_phrase') ) { -%> - - <TR> - <TD ALIGN="right">Security phrase</TD> - <TD> - <INPUT TYPE="text" NAME="sec_phrase" VALUE="<%= $sec_phrase %>" SIZE=32> - (for forgotten passwords) - </TD> + print <<END; + <TR><TD ALIGN="right">Security phrase</TD> + <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase" SIZE=32> + (for forgotten passwords)</TD> </TD> +END +} else { + print qq!<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="$sec_phrase">!; +} -<% } else { %> - - <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<%= $sec_phrase %>"> - -<% } %> - - -<% #domain my $domsvc = $svc_acct->domsvc || 0; if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) { -%> - - <INPUT TYPE="hidden" NAME="domsvc" VALUE="<%= $domsvc %>"> - -<% } else { - + print qq!<INPUT TYPE="hidden" NAME="domsvc" VALUE="$domsvc">!; +} else { my %svc_domain = (); if ( $domsvc ) { @@ -214,6 +168,7 @@ if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) { } } + my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } ); if ($cust_pkg && !$conf->exists('svc_acct-alldomains') ) { my @cust_svc = map { qsearch('cust_svc', { 'pkgnum' => $_->pkgnum } ) } @@ -226,221 +181,121 @@ if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) { } else { %svc_domain = map { $_->svcnum => $_ } qsearch('svc_domain', {} ); } + print qq!<TR><TD ALIGN="right">Domain</TD>!. + qq!<TD><SELECT NAME="domsvc" SIZE=1>\n!; + foreach my $svcnum ( + sort { $svc_domain{$a}->domain cmp $svc_domain{$b}->domain } + keys %svc_domain + ) { + my $svc_domain = $svc_domain{$svcnum}; + print qq!<OPTION VALUE="!. $svc_domain->svcnum. qq!"!. + ( $svc_domain->svcnum == $domsvc ? ' SELECTED' : '' ). + '>'. $svc_domain->domain. "\n" ; + } + print "</SELECT></TD></TR>"; +} -%> - - <TR> - <TD ALIGN="right">Domain</TD> - <TD> - <SELECT NAME="domsvc" SIZE=1> - - <% foreach my $svcnum ( - sort { $svc_domain{$a}->domain cmp $svc_domain{$b}->domain } - keys %svc_domain - ) { - my $svc_domain = $svc_domain{$svcnum}; - %> - - <OPTION VALUE="<%= $svc_domain->svcnum %>" <%= $svc_domain->svcnum == $domsvc ? ' SELECTED' : '' %>><%= $svc_domain->domain %> - - <% } %> - </SELECT> - </TD> - </TR> - -<% } %> - - -<% #pop my $popnum = $svc_acct->popnum || 0; -if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) { -%> - - <INPUT TYPE="hidden" NAME="popnum" VALUE="<%= $popnum %>"> - - -<% } else { %> - - <TR> - <TD ALIGN="right">Access number</TD> - <TD><%= FS::svc_acct_pop::popselector($popnum) %></TD> - </TR> - -<% } %> - - -<% #uid/gid %> -<% foreach my $xid (qw( uid gid )) { %> - - <% - if ( $part_svc->part_svc_column($xid)->columnflag eq 'F' - || ! $conf->exists("svc_acct-edit_$xid") - ) { - %> - - <% if ( length($svc_acct->$xid()) ) { %> - - <TR> - <TD ALIGN="right"><%= uc($xid) %></TD> - <TD BGCOLOR="#eeeeee"><%= $svc_acct->$xid() %></TD> - <TD> - </TD> - </TR> - - <% } %> - - <INPUT TYPE="hidden" NAME="<%= $xid %>" VALUE="<%= $svc_acct->$xid() %>"> - - <% } else { %> - - <TR> - <TD ALIGN="right"><%= uc($xid) %></TD> - <TD> - <INPUT TYPE="text" NAME="<%= $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<%= $svc_acct->$xid() %>"> - </TD> - </TR> - - <% } %> - -<% } %> - - -<% -#finger -if ( $part_svc->part_svc_column('uid')->columnflag eq 'F' - && ! $svc_acct->finger ) { -%> - - <INPUT TYPE="hidden" NAME="finger" VALUE=""> - -<% } else { %> - - <TR> - <TD ALIGN="right">GECOS</TD> - <TD> - <INPUT TYPE="text" NAME="finger" VALUE="<%= $svc_acct->finger %>"> - </TD> - </TR> - -<% } %> +if ( $part_svc->part_svc_column('popnum')->columnflag eq "F" ) { + print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$popnum">!; +} else { + print qq!<TR><TD ALIGN="right">Access number</TD>!. + qq!<TD>!. FS::svc_acct_pop::popselector($popnum). '</TD></TR>'; +} +my($uid,$gid,$finger,$dir)=( + $svc_acct->uid, + $svc_acct->gid, + $svc_acct->finger, + $svc_acct->dir, +); -<INPUT TYPE="hidden" NAME="dir" VALUE="<%= $svc_acct->dir %>"> +print <<END; +<INPUT TYPE="hidden" NAME="uid" VALUE="$uid"> +<INPUT TYPE="hidden" NAME="gid" VALUE="$gid"> +END +if ( !$finger && $part_svc->part_svc_column('uid')->columnflag eq 'F' ) { + print '<INPUT TYPE="hidden" NAME="finger" VALUE="">'; +} else { + print '<TR><TD ALIGN="right">GECOS</TD>'. + qq!<TD><INPUT TYPE="text" NAME="finger" VALUE="$finger"></TD></TR>!; +} +print qq!<INPUT TYPE="hidden" NAME="dir" VALUE="$dir">!; -<% -#shell my $shell = $svc_acct->shell; -if ( $part_svc->part_svc_column('shell')->columnflag eq 'F' +if ( $part_svc->part_svc_column('shell')->columnflag eq "F" || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' ) ) { -%> - - <INPUT TYPE="hidden" NAME="shell" VALUE="<%= $shell %>"> - -<% } else { %> - - <TR> - <TD ALIGN="right">Shell</TD> - <TD> - <SELECT NAME="shell" SIZE=1> - - <% - my($etc_shell); - foreach $etc_shell (@shells) { - %> - - <OPTION<%= $etc_shell eq $shell ? ' SELECTED' : '' %>><%= $etc_shell %> - - <% } %> - - </SELECT> - </TD> - </TR> - -<% } %> - - -<% if ( $part_svc->part_svc_column('quota')->columnflag eq 'F' ) { %> - - <INPUT TYPE="hidden" NAME="quota" VALUE="<%= $svc_acct->quota %>"> - -<% } else { %> - - <TR> - <TD ALIGN="right">Quota:</TD> - <TD><INPUT TYPE="text" NAME="quota" VALUE="<%= $svc_acct->quota %>"></TD> - </TR> - -<% } %> - - -<% if ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) { %> - - <INPUT TYPE="hidden" NAME="slipip" VALUE="<%= $svc_acct->slipip %>"> - -<% } else { %> + print qq!<INPUT TYPE="hidden" NAME="shell" VALUE="$shell">!; +} else { + print qq!<TR><TD ALIGN="right">Shell</TD><TD><SELECT NAME="shell" SIZE=1>!; + my($etc_shell); + foreach $etc_shell (@shells) { + print "<OPTION", $etc_shell eq $shell ? ' SELECTED' : '', ">", + $etc_shell, "\n"; + } + print "</SELECT></TD></TR>"; +} - <TR> - <TD ALIGN="right">IP</TD> - <TD><INPUT TYPE="text" NAME="slipip" VALUE="<%= $svc_acct->slipip %>"></TD> - </TR> +my($quota,$slipip)=( + $svc_acct->quota, + $svc_acct->slipip, +); -<% } %> +if ( $part_svc->part_svc_column('quota')->columnflag eq "F" ) +{ + print qq!<INPUT TYPE="hidden" NAME="quota" VALUE="$quota">!; +} else { + print <<END; + <TR><TD ALIGN="right">Quota:</TD> + <TD> <INPUT TYPE="text" NAME="quota" VALUE="$quota" ></TD> + </TR> +END +} +if ( $part_svc->part_svc_column('slipip')->columnflag eq "F" ) { + print qq!<INPUT TYPE="hidden" NAME="slipip" VALUE="$slipip">!; +} else { + print qq!<TR><TD ALIGN="right">IP</TD><TD><INPUT TYPE="text" NAME="slipip" VALUE="$slipip"></TD></TR>!; +} -<% foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) { $r =~ /^^r(adius|[cr])_(.+)$/ or next; #? my $a = $2; -%> - - <% if ( $part_svc->part_svc_column($r)->columnflag eq 'F' ) { %> - - <INPUT TYPE="hidden" NAME="<%= $r %>" VALUE="<%= $svc_acct->getfield($r) %>"> - - <% } else { %> - - <TR> - <TD ALIGN="right"><%= $FS::raddb::attrib{$a} %></TD> - <TD><INPUT TYPE="text" NAME="<%= $r %>" VALUE="<%= $svc_acct->getfield($r) %>"></TD> - </TR> - - <% } %> - -<% } %> - - -<TR> - <TD ALIGN="right">RADIUS groups</TD> - - <% if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) { %> - - <TD BGCOLOR="#eeeeee"><%= join('<BR>', @groups) %></TD> - - <% } else { %> - - <TD><%= FS::svc_acct::radius_usergroup_selector( \@groups ) %></TD> - - <% } %> - -</TR> - -<% foreach my $field ($svc_acct->virtual_fields) { %> - - <% # If the flag is X, it won't even show up in $svc_acct->virtual_fields. %> - <% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { %> - - <%= $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %> + if ( $part_svc->part_svc_column($r)->columnflag eq 'F' ) { + print qq!<INPUT TYPE="hidden" NAME="$r" VALUE="!. + $svc_acct->getfield($r). '">'; + } else { + print qq!<TR><TD ALIGN="right">$FS::raddb::attrib{$a}</TD><TD><INPUT TYPE="text" NAME="$r" VALUE="!. + $svc_acct->getfield($r). '"></TD></TR>'; + } +} - <% } %> +print '<TR><TD ALIGN="right">RADIUS groups</TD>'; +if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) { + print '<TD BGCOLOR="#ffffff">'. join('<BR>', @groups); +} else { + print '<TD>'. &FS::svc_acct::radius_usergroup_selector( \@groups ); +} +print '</TD></TR>'; -<% } %> +foreach my $field ($svc_acct->virtual_fields) { + if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { + # If the flag is X, it won't even show up in $svc_acct->virtual_fields. + print $svc_acct->pvf($field)->widget('HTML', 'edit', + $svc_acct->getfield($field)); + } +} -</TABLE> -<BR> +#submit +print qq!</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">!; -<INPUT TYPE="submit" VALUE="Submit"> +print <<END; + </FORM> + </BODY> +</HTML> +END -</FORM></BODY></HTML> +%> diff --git a/httemplate/elements/jsrsServer.html b/httemplate/elements/jsrsServer.html index fd6dc5465..d6d537070 100644 --- a/httemplate/elements/jsrsServer.html +++ b/httemplate/elements/jsrsServer.html @@ -1,3 +1,4 @@ <% - my $server = new FS::UI::Web::JSRPC '', $cgi; -%><%= $server->process %> +my $server = new FS::UI::Web::JSRPC; +$server->process; +%> diff --git a/httemplate/elements/overlibmws_draggable.js b/httemplate/elements/overlibmws_draggable.js deleted file mode 100644 index 14e4a6062..000000000 --- a/httemplate/elements/overlibmws_draggable.js +++ /dev/null @@ -1,78 +0,0 @@ -/*
- overlibmws_draggable.js plug-in module - Copyright Foteos Macrides 2002=2005
- For support of the DRAGGABLE feature.
- Initial: August 24, 2002 - Last Revised: January 12, 2005
- See the Change History and Command Reference for overlibmws via:
-
- http://www.macridesweb.com/oltest/
-
- Published under an open source license: http://www.macridesweb.com/oltest/license.html
-*/
-
-OLloaded=0;
-OLregCmds('draggable');
-
-// DEFAULT CONFIGURATION
-if(OLud('draggable'))var ol_draggable=0;
-// END CONFIGURATION
-
-var o3_draggable=0,o3_dragging=0,OLmMv,OLcX,OLcY,OLcbX,OLcbY;
-function OLloadDraggable(){OLload('draggable');}
-function OLparseDraggable(pf,i,ar){
-var k=i;
-if(k<ar.length){if(Math.abs(ar[k])==DRAGGABLE){OLtoggle(ar[k],pf+'draggable');return k;}}
-return -1;
-}
-
-function OLcheckDrag(){
-if(o3_draggable){if(o3_sticky&&(o3_frame==self))initDrag();else o3_draggable=0;}
-}
-function initDrag(){
-OLmMv=OLdw.onmousemove;o3_dragging=0;
-if(OLns4){document.captureEvents(Event.MOUSEDOWN|Event.CLICK);
-document.onmousedown=OLgrabEl;;document.onclick=function(e){return routeEvent(e);}}
-else{over.onmousedown=OLgrabEl;OLsetDrgCur(1);}
-}
-function OLsetDrgCur(d){if(!OLns4)over.style.cursor=(d?'move':'auto');}
-
-function OLgrabEl(e){
-var e=(e||event);
-var cKy=(OLns4?e.modifiers&Event.ALT_MASK:(!OLop7?e.altKey:e.ctrlKey));o3_dragging=1;
-if(cKy){OLsetDrgCur(0);document.onmouseup=function(){OLsetDrgCur(1);o3_dragging=0;}
-return(OLns4?routeEvent(e):true);}
-OLx=(e.pageX||e.clientX+OLfd().scrollLeft);OLy=(e.pageY||e.clientY+OLfd().scrollTop);
-if(OLie4)over.onselectstart=function(){return false;}
-if(OLns4){OLcX=OLx;OLcY=OLy;document.captureEvents(Event.MOUSEUP)}else{
-OLcX=OLx-(OLns4?over.left:parseInt(over.style.left));
-OLcY=OLy-(OLns4?over.top:parseInt(over.style.top));
-if((OLshadowPI)&&bkdrop&&o3_shadow){OLcbX=OLx-(parseInt(bkdrop.style.left));
-OLcbY=OLy-(parseInt(bkdrop.style.top));}}OLdw.onmousemove=OLmoveEl;
-document.onmouseup=function(){
-if(OLie4)over.onselectstart=null;o3_dragging=0;OLdw.onmousemove=OLmMv;}
-return(OLns4?routeEvent(e):false);
-}
-
-function OLmoveEl(e){
-var e=(e||event);
-OLx=(e.pageX||e.clientX+OLfd().scrollLeft);OLy=(e.pageY||e.clientY+OLfd().scrollTop);
-if(o3_dragging){if(OLns4){over.moveBy(OLx-OLcX,OLy-OLcY);
-if(OLshadowPI&&bkdrop&&o3_shadow)bkdrop.moveBy(OLx-OLcX,OLy-OLcY);}
-else{OLrepositionTo(over,OLx-OLcX,OLy-OLcY);
-if((OLiframePI)&&OLie55&&OLifsP1)OLrepositionTo(OLifsP1,OLx-OLcX,OLy-OLcY);
-if((OLshadowPI)&&bkdrop&&o3_shadow){OLrepositionTo(bkdrop,OLx-OLcbX,OLy-OLcbY);
-if((OLiframePI)&&OLie55&&OLifsSh)OLrepositionTo(OLifsSh,OLx-OLcbX,OLy-OLcbY);}}
-if(OLhidePI)OLhideUtil(0,1,1,0,0,0);}if(OLns4){OLcX=OLx;OLcY=OLy;}
-return false;
-}
-
-function OLclearDrag(){
-if(OLns4){document.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP|Event.CLICK);
-document.onmousedown=document.onclick=null;}else{over.onmousedown=null;OLsetDrgCur(0);}
-document.onmouseup=null;o3_dragging=0;
-}
-
-OLregRunTimeFunc(OLloadDraggable);
-OLregCmdLineFunc(OLparseDraggable);
-
-OLdraggablePI=1;
-OLloaded=1;
diff --git a/httemplate/elements/overlibmws_iframe.js b/httemplate/elements/overlibmws_iframe.js deleted file mode 100644 index e3032f2ee..000000000 --- a/httemplate/elements/overlibmws_iframe.js +++ /dev/null @@ -1,93 +0,0 @@ -/*
- overlibmws_iframe.js plug-in module - Copyright Foteos Macrides 2003-2005
- Masks system controls to prevent obscuring of popops for IE v5.5 or higher.
- Initial: October 19, 2003 - Last Revised: May 15, 2005
- See the Change History and Command Reference for overlibmws via:
-
- http://www.macridesweb.com/oltest/
-
- Published under an open source license: http://www.macridesweb.com/oltest/license.html
-*/
-
-OLloaded=0;
-
-var OLifsP1=null,OLifsSh=null,OLifsP2=null;
-
-// IFRAME SHIM SUPPORT FUNCTIONS
-function OLinitIfs(){
-if(!OLie55)return;
-if((OLovertwoPI)&&over2&&over==over2){
-var o=o3_frame.document.all['overIframeOvertwo'];
-if(!o||OLifsP2!=o){OLifsP2=null;OLgetIfsP2Ref();}return;}
-o=o3_frame.document.all['overIframe'];
-if(!o||OLifsP1!=o){OLifsP1=null;OLgetIfsRef();}
-if((OLshadowPI)&&o3_shadow){o=o3_frame.document.all['overIframeShadow'];
-if(!o||OLifsSh!=o){OLifsSh=null;OLgetIfsShRef();}}
-}
-
-function OLsetIfsRef(o,i,z){
-o.id=i;o.src='javascript:false;';o.scrolling='no';var os=o.style;
-os.position='absolute';os.top=0;os.left=0;os.width=1;os.height=1;os.visibility='hidden';
-os.zIndex=over.style.zIndex-z;os.filter='Alpha(style=0,opacity=0)';
-}
-
-function OLgetIfsRef(){
-if(OLifsP1||!OLie55)return;
-OLifsP1=o3_frame.document.createElement('iframe');
-OLsetIfsRef(OLifsP1,'overIframe',2);
-o3_frame.document.body.appendChild(OLifsP1);
-}
-
-function OLgetIfsShRef(){
-if(OLifsSh||!OLie55)return;
-OLifsSh=o3_frame.document.createElement('iframe');
-OLsetIfsRef(OLifsSh,'overIframeShadow',3);
-o3_frame.document.body.appendChild(OLifsSh);
-}
-
-function OLgetIfsP2Ref(){
-if(OLifsP2||!OLie55)return;
-OLifsP2=o3_frame.document.createElement('iframe');
-OLsetIfsRef(OLifsP2,'overIframeOvertwo',1);
-o3_frame.document.body.appendChild(OLifsP2);
-}
-
-function OLsetDispIfs(o,w,h){
-var os=o.style;
-os.width=w+'px';os.height=h+'px';os.clip='rect(0px '+w+'px '+h+'px 0px)';
-o.filters.alpha.enabled=true;
-}
-
-function OLdispIfs(){
-if(!OLie55)return;
-var wd=over.offsetWidth,ht=over.offsetHeight;
-if(OLfilterPI&&o3_filter&&o3_filtershadow){wd+=5;ht+=5;}
-if((OLovertwoPI)&&over2&&over==over2){
-if(!OLifsP2)return;
-OLsetDispIfs(OLifsP2,wd,ht);return;}
-if(!OLifsP1)return;
-OLsetDispIfs(OLifsP1,wd,ht);
-if((!OLshadowPI)||!o3_shadow||!OLifsSh)return;
-OLsetDispIfs(OLifsSh,wd,ht);
-}
-
-function OLshowIfs(){
-if(OLifsP1){OLifsP1.style.visibility="visible";
-if((OLshadowPI)&&o3_shadow&&OLifsSh)OLifsSh.style.visibility="visible";}
-}
-
-function OLhideIfs(o){
-if(!OLie55||o!=over)return;
-if(OLifsP1)OLifsP1.style.visibility="hidden";
-if((OLshadowPI)&&o3_shadow&&OLifsSh)OLifsSh.style.visibility="hidden";
-}
-
-function OLrepositionIfs(X,Y){
-if(OLie55){if((OLovertwoPI)&&over2&&over==over2){
-if(OLifsP2)OLrepositionTo(OLifsP2,X,Y);}
-else{if(OLifsP1){OLrepositionTo(OLifsP1,X,Y);if((OLshadowPI)&&o3_shadow&&OLifsSh)
-OLrepositionTo(OLifsSh,X+o3_shadowx,Y+o3_shadowy);}}}
-}
-
-OLiframePI=1;
-OLloaded=1;
diff --git a/httemplate/elements/progress-init.html b/httemplate/elements/progress-init.html index 7844f5678..a8268c12c 100644 --- a/httemplate/elements/progress-init.html +++ b/httemplate/elements/progress-init.html @@ -11,14 +11,8 @@ } %> -<%= include('/elements/xmlhttp.html', - 'method' => 'POST', - 'url' => $action, - 'subs' => [ 'start_job' ], - ) -%> +<SCRIPT TYPE="text/javascript" SRC="../elements/jsrsClient.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT> <SCRIPT TYPE="text/javascript"> function OLiframeContent(src, width, height, name) { return ('<iframe src="'+src+'" width="'+width+'" height="'+height+'"' @@ -28,8 +22,6 @@ function OLiframeContent(src, width, height, name) { function <%=$key%>process () { - //alert('<%=$key%>process for form <%=$formname%>'); - document.<%=$formname%>.submit.disabled=true; overlib( 'Submitting job to server...', WIDTH, 432, HEIGHT, 136, CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 ); @@ -43,10 +35,8 @@ function <%=$key%>process () { ) { if ( field.type == 'select-multiple' ) { - //alert('select-multiple ' + field.name); for (var j=0; j < field.options.length; j++) { if ( field.options[j].selected ) { - //alert(field.name + ' => ' + field.options[j].value); Hash[x++] = field.name; Hash[x++] = field.options[j].value; } @@ -63,12 +53,8 @@ function <%=$key%>process () { } } - // jsrsPOST = true; - // jsrsExecute( '<%= $action %>', <%=$key%>myCallback, 'start_job', Hash ); - - //alert('start_job( ' + Hash + ', <%=$key%>myCallback )' ); - //alert('start_job()' ); - start_job( Hash, <%=$key%>myCallback ); + jsrsPOST = true; + jsrsExecute( '<%= $action %>', <%=$key%>myCallback, 'start_job', Hash ); } diff --git a/httemplate/elements/progress-popup.html b/httemplate/elements/progress-popup.html index 200f97d9b..20bb5fc5a 100644 --- a/httemplate/elements/progress-popup.html +++ b/httemplate/elements/progress-popup.html @@ -10,35 +10,25 @@ </HEAD> <BODY BGCOLOR="#ccccff" onLoad="refreshStatus()"> -<%= include('/elements/xmlhttp.html', - 'url' => $p.'elements/jsrsServer.html', - 'subs' => [ 'job_status' ], - ) -%> +<SCRIPT TYPE="text/javascript" SRC="../elements/jsrsClient.js"></SCRIPT> <SCRIPT TYPE="text/javascript" src="../elements/qlib/control.js"></SCRIPT> <SCRIPT TYPE="text/javascript" src="../elements/qlib/imagelist.js"></SCRIPT> <SCRIPT TYPE="text/javascript" src="../elements/qlib/progress.js"></SCRIPT> <SCRIPT TYPE="text/javascript"> function refreshStatus () { - //jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' ); - - job_status( '<%= $jobnum %>', updateStatus ); + jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' ); } function updateStatus( status_statustext ) { - - //var Array = status_statustext.split("\n"); - var statusArray = eval('(' + status_statustext + ')'); - var status = statusArray[0]; - var statustext = statusArray[1]; - + var Array = status_statustext.split("\n"); + var status = Array[0]; + var statustext = Array[1]; //if ( status == 'progress' ) { //IE workaround, no i have no idea why if ( status.indexOf('progress') > -1 ) { document.getElementById("progress_percent").innerHTML = statustext + '%'; bar1.set(statustext); bar1.update; - //jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' ); - job_status( '<%= $jobnum %>', updateStatus ); + jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' ); } else if ( status.indexOf('complete') > -1 ) { <% if ( $message ) { %> document.getElementById("progress_message").innerHTML = "<%= $message %>"; diff --git a/httemplate/elements/select-agent.html b/httemplate/elements/select-agent.html deleted file mode 100644 index c2a5e4bde..000000000 --- a/httemplate/elements/select-agent.html +++ /dev/null @@ -1,24 +0,0 @@ -<% - my( $agentnum, %opt ) = @_; - - my @agents; - if ( $opt{'agents'} ) { - @agents = @{ $opt{'agents'} }; - } else { - @agents = qsearch( 'agent', { disabled=>'' } ); - } - -%> - -<SELECT NAME="agentnum"> - - <OPTION VALUE="">all</OPTION> - - <% foreach my $agent ( sort { $a->agent cmp $b->agent } @agents ) { %> - - <OPTION VALUE="<%= $agent->agentnum %>"<%= $agentnum == $agent->agentnum ? ' SELECTED' : '' %>><%= $agent->agent %> - - <% } %> - -</SELECT> - diff --git a/httemplate/elements/select-month_year.html b/httemplate/elements/select-month_year.html deleted file mode 100644 index a0ea74ddd..000000000 --- a/httemplate/elements/select-month_year.html +++ /dev/null @@ -1,50 +0,0 @@ -<% - - my %opt = @_; - - my $prefix = $opt{'prefix'} || ''; - my $disabled = $opt{'disabled'} || ''; - my $empty = $opt{'empty_option'} || ''; - my $date = $opt{'selected_date'} || ''; - $date = '' if $date eq '-'; - #$date ||= '01-2000' unless $empty; - my $start_year = $opt{'start_year'}; - my $end_year = $opt{'end_year'} || '2037'; - - my( $mon, $year ) = (0, 0); - if ( $date ) { - if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); - } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); - } else { - die "unrecognized expiration date format: $date"; - } - } - - unless ( $start_year ) { - my @t = localtime; - $start_year = $t[5] + 1900; - } - $start_year = $year if $start_year > $year && $year > 0; - -%> - -<SELECT NAME="<%= $prefix %>_month" SIZE="1" <%= $disabled%>> - -<%= $empty ? '<OPTION VALUE="">' : '' %> - -<% for ( 1 .. 12 ) { %> - <OPTION<%= $_ == $mon ? ' SELECTED' : '' %> VALUE="<%= $_ %>"><%= $_ %> -<% } %> - -</SELECT>/<SELECT NAME="<%= $prefix %>_year" SIZE="1" <%= $disabled%>> - -<%= $empty ? '<OPTION VALUE="">' : '' %> - -<% for ( $start_year .. $end_year ) { %> - <OPTION<%= $_ == $year ? ' SELECTED' : '' %> VALUE="<%= $_ %>"><%= $_ %> -<% } %> - -</SELECT> - diff --git a/httemplate/elements/select-taxclass.html b/httemplate/elements/select-taxclass.html deleted file mode 100644 index e5a1abba1..000000000 --- a/httemplate/elements/select-taxclass.html +++ /dev/null @@ -1,42 +0,0 @@ -<% - my $conf = new FS::Conf; - my $selected_taxclass = scalar(@_) ? shift : ''; -%> - -<% if ( $conf->exists('enable_taxclasses') ) { %> - - <SELECT NAME="taxclass"> - - <% if ( $conf->exists('require_taxclasses') ) { %> - - <OPTION VALUE="(select)">Select tax class - - <% } else { %> - - <OPTION VALUE=""> - - <% } %> - - <% - my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county') - or die dbh->errstr; - $sth->execute or die $sth->errstr; - my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref}; - my @taxclasses = grep $_, keys %taxclasses; - %> - - <% foreach my $taxclass ( @taxclasses ) { %> - - <OPTION VALUE="<%= $taxclass %>"<%= $taxclass eq $selected_taxclass ? ' SELECTED' : '' %>><%= $taxclass %> - - <% } %> - - </SELECT> - -<% } else { %> - - <INPUT TYPE="hidden" NAME="taxclass" VALUE="<%= $selected_taxclass %>"> - -<% } %> - - diff --git a/httemplate/elements/small_custview.html b/httemplate/elements/small_custview.html index e0c22e0c4..1e8ae739a 100644 --- a/httemplate/elements/small_custview.html +++ b/httemplate/elements/small_custview.html @@ -1,2 +1,2 @@ <% my $conf = new FS::Conf; %> -<%= small_custview( shift, shift || scalar($conf->config('countrydefault')), @_ ) %> +<%= small_custview( shift, shift || $conf->config('countrydefault') ) %> diff --git a/httemplate/elements/table-grid.html b/httemplate/elements/table-grid.html deleted file mode 100644 index 80611f511..000000000 --- a/httemplate/elements/table-grid.html +++ /dev/null @@ -1,8 +0,0 @@ -<STYLE TYPE="text/css"> -.grid table { border: solid; empty-cells: show } -.grid TH { padding-left: 3px; padding-right: 3px; border: 1px solid #dddddd; border-bottom: dashed 1px black; border-right: none } -.grid TD { padding-left: 3px; padding-right: 3px; 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"> - diff --git a/httemplate/elements/tr-input-beginning_ending.html b/httemplate/elements/tr-input-beginning_ending.html deleted file mode 100644 index 9fa936bca..000000000 --- a/httemplate/elements/tr-input-beginning_ending.html +++ /dev/null @@ -1,39 +0,0 @@ -<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> - - -<TR> - <TD ALIGN="right">From: </TD> - <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> -<SCRIPT TYPE="text/javascript"> - Calendar.setup({ - inputField: "beginning_text", - ifFormat: "%m/%d/%Y", - button: "beginning_button", - align: "BR" - }); -</SCRIPT> -</TR> - -<TR> - <TD ALIGN="right">To: </TD> - <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> -<SCRIPT TYPE="text/javascript"> - Calendar.setup({ - inputField: "ending_text", - ifFormat: "%m/%d/%Y", - button: "ending_button", - align: "BR" - }); -</SCRIPT> -</TR> - -<TR> - <TD></TD> - <TD> - <FONT SIZE="-1">(leave one or both dates blank for an open-ended search)</FONT> - </TD> -</TR> - diff --git a/httemplate/elements/tr-select-agent.html b/httemplate/elements/tr-select-agent.html deleted file mode 100644 index 2227262b6..000000000 --- a/httemplate/elements/tr-select-agent.html +++ /dev/null @@ -1,29 +0,0 @@ -<% - my( $agentnum, %opt ) = @_; - - my @agents; - if ( $opt{'agents'} ) { - @agents = @{ $opt{'agents'} }; - } else { - @agents = qsearch( 'agent', { disabled=>'' } ); - } - -%> - -<% if ( scalar(@agents) == 1 ) { %> - - <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agents[0]->agentnum %>"> - -<% } else { %> - - <TR> - <TD ALIGN="right"><%= $opt{'label'} || 'Agent: ' %></TD> - <TD> - <%= include( '/elements/select-agent.html', $agentnum, - 'agents' => \@agents, - ) - %> - </TD> - </TR> - -<% } %> diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html deleted file mode 100644 index 28130e501..000000000 --- a/httemplate/elements/xmlhttp.html +++ /dev/null @@ -1,109 +0,0 @@ -<% - my ( %opt ) = @_; - - my $url = $opt{'url'}; - my $method = exists($opt{'method'}) ? $opt{'method'} : 'GET'; - #my @subs = @{ $opt{'subs'}; - - $url .= ( ($url =~ /\?/) ? '&' : '?' ) - if $method eq 'GET'; - -%> - -<SCRIPT TYPE="text/javascript"> - - function rs_init_object() { - var A; - try { - A=new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - A=new ActiveXObject("Microsoft.XMLHTTP"); - } catch (oc) { - A=null; - } - } - if(!A && typeof XMLHttpRequest != "undefined") - A = new XMLHttpRequest(); - if (!A) - alert("Can't create XMLHttpRequest object"); - return A; - - } - - <% foreach my $func ( @{$opt{'subs'}} ) { - - my $furl = $url; - $furl =~ s/\"/\\\\\"/; #javascript escape - - %> - - function <%=$func%>() { - // count args; build URL - var url = "<%=$furl%>"; - var a = <%=$func%>.arguments; - - var args; - var len; - var content = 'sub=<%= uri_escape($func) %>'; - if ( a && typeof a == 'object' && a[0].constructor == Array ) { - args = a[0]; - len = args.length - } else { - args = a; - len = args.length - 1; - } - for (var i = 0; i < len; i++) - content = content + "&arg=" + escape(args[i]); - content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs - - if ( '<%=$method%>' == 'GET' ) { - url = url + content; - } - - //alert('<%=$method%> ' + url); - - var xmlhttp = rs_init_object(); - xmlhttp.open("<%=$method%>", url, true); - - xmlhttp.onreadystatechange = function() { - if (xmlhttp.readyState != 4) - return; - - if (xmlhttp.status != 200) { - alert(xmlhttp.status + " status connecting to " + url); - } else { - var data = xmlhttp.responseText; - //alert('received response: ' + data); - a[a.length-1](data); - if ( data.indexOf("<b>System error</b>") > -1 ) { - var w; - if ( w = window.open("about:blank") ) { - w.document.write(data); - } else { - // popup blocking? should use an overlib popup instead - alert("Error popup disabled; try disabling popup blocking to see"); - } - } - } - } - - if ( '<%=$method%>' == 'POST' ) { - - xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - xmlhttp.send(content); - - } else { - - xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); - xmlhttp.send(null); - - } - - //rs_debug("x_$func_name url = " + url); - //rs_debug("x_$func_name waiting.."); - } - - <% } %> - -</SCRIPT> diff --git a/httemplate/images/cvv2.png b/httemplate/images/cvv2.png Binary files differindex 48c58d561..4610dcbe6 100644 --- a/httemplate/images/cvv2.png +++ b/httemplate/images/cvv2.png diff --git a/httemplate/images/cvv2_amex.png b/httemplate/images/cvv2_amex.png Binary files differindex 82d1f4715..21c36a0ab 100644 --- a/httemplate/images/cvv2_amex.png +++ b/httemplate/images/cvv2_amex.png diff --git a/httemplate/index.html b/httemplate/index.html index b8f300d2d..167cd6f7b 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -120,7 +120,7 @@ <TABLE CELLSPACING=2 CELLPADDING=0 BORDER=0 WIDTH="100%" BGCOLOR="#eeeeee"> <TR><TH BGCOLOR="#cccccc">Bookkeeping / Collections</TH></TR> <TR><TD> - <BR><A HREF="misc/batch-cust_pay.html">Quick payment entry</A> + <BR><A HREF="search/cust_main-quickpay.html">Quick payment entry</A> <BR> <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> @@ -173,7 +173,7 @@ Auditing pre-Freeside services with no customer record <UL> <LI>unlinked accounts (<A HREF="search/svc_acct.cgi?UN_svcnum">by service number</A>) (<A HREF="search/svc_acct.cgi?UN_username">by username</A>) (<A HREF="search/svc_acct.cgi?UN_uid">by uid</A>) - <LI>unlinked mail forwards (<A HREF="search/svc_forward.cgi?UN_svcnum">by service number</A>) +<!-- <LI>unlinked mail forwards (<A HREF="search/svc_forward.cgi?UN_svcnum">by service number</A>) (by ?)) --> <LI>unlinked domains (<A HREF="search/svc_domain.cgi?UN_svcnum">by service number</A>) (<A HREF="search/svc_domain.cgi?UN_domain">by domain</A>) <LI>unlinked externals (<A HREF="search/svc_external.cgi?UN_svcnum">by service number</A>) (<A HREF="search/svc_external.cgi?UN_id">by id</A>) </UL> @@ -185,7 +185,7 @@ <LI><A HREF="search/cust_pkg_report.cgi">packages (by next bill date range)</A> </UL> <A HREF="browse/part_pkg.cgi?active=1">Package definitions (by number of active packages)</A><BR><BR> - <A HREF="browse/part_svc.cgi?orderby=active">Service definitions (by number of active services)</A><BR><BR> + <A HREF="browse/part_svc.cgi?active=1">Service definitions (by number of active services)</A><BR><BR> Customers <UL> <LI><A HREF="search/cust_main-otaker.cgi">Search customers by ordering employee</A> @@ -244,8 +244,6 @@ </ul> <A NAME="admin_billing">Billing</a> <ul> - <LI><A HREF="browse/payment_gateway.html">View/Edit payment gateways</A> - - Credit card and electronic check processors <LI><A HREF="browse/part_bill_event.cgi">View/Edit invoice events</A> - Actions for overdue invoices <LI><A HREF="search/prepay_credit.html">View/Edit prepaid cards</A> diff --git a/httemplate/misc/batch-cust_pay.html b/httemplate/misc/batch-cust_pay.html deleted file mode 100644 index 20cc89045..000000000 --- a/httemplate/misc/batch-cust_pay.html +++ /dev/null @@ -1,396 +0,0 @@ -<%= header( 'Quick payment entry', - menubar( - 'Main Menu' => $p, #popurl(1), - 'Old-style quick payment entry' => - $p. 'search/cust_main-quickpay.html', - ), - ( $cgi->param('error') ? '' : 'onload="addRow()"' ), - ) -%> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000"><%= $cgi->param('error') %></FONT><BR><BR> -<% } %> - - -<FORM ACTION="process/batch-cust_pay.cgi" NAME="OneTrueForm" METHOD="POST" onsubmit="document.OneTrueForm.submit.disabled=true;"> - -<!-- <B>Batch</B> <INPUT TYPE="text" NAME="paybatch"><BR><BR> --> - -<SCRIPT TYPE="text/javascript"> - - function clearhint_custnum() { - - //this.style.color = '#000000'; - - if ( this.value == 'Not found' || this.value == 'Multiple' ) { - this.value = ''; - this.style.color = '#000000'; - } - - } - - function clearhint_customer() { - - this.style.color = '#000000'; - - if ( this.value == '(last name or company)' || this.value == 'Not found' ) - this.value = ''; - - } - - function search_custnum() { - - this.style.color = '#000000' - - var custnum_obj = this; - var searchrow = this.getAttribute('rownum'); - var custnum = this.value; - - if ( custnum == 'searching...' || custnum == 'Not found' || custnum == '' ) - return; - - if ( this.getAttribute('magic') == 'nosearch' ) { - this.setAttribute('magic', ''); - return; - } - - if ( ( rownum - searchrow ) == 1 ) { - addRow(); - } - var customer = document.getElementById('customer'+searchrow); - customer.value = 'searching...'; - customer.disabled = true; - customer.style.color = '#000000'; - customer.style.backgroundColor = '#dddddd'; - - var customer_select = document.getElementById('cust_select'+searchrow); - - //alert('search for custnum ' + custnum + ', row#' + searchrow ); - - customer.style.display = ''; - customer_select.style.display = 'none'; - - function search_custnum_update(name) { - - var name = eval('(' + name + ')' ); - - customer.disabled = false; - customer.style.backgroundColor = '#ffffff'; - - if ( name.length > 0 ) { - //alert('custnum found: ' + name); - customer.value = name; - customer.setAttribute('magic', 'nosearch'); - } else { - customer.value = 'Not found'; - customer.style.color = '#ff0000'; - custnum_obj.style.color = '#ff0000'; - - } - - } - - custnum_search( custnum, search_custnum_update ); - - } - - function search_customer() { - - var customer_obj = this; - var searchrow = this.getAttribute('rownum'); - var customer = this.value; - - if ( customer == 'searching...' || customer == 'Not found' || customer == '' ) - return; - - if ( this.getAttribute('magic') == 'nosearch' ) { - this.setAttribute('magic', ''); - return; - } - - if ( ( rownum - searchrow ) == 1 ) { - addRow(); - } - - var custnum_obj = document.getElementById('custnum'+searchrow); - custnum_obj.value = 'searching...'; - custnum_obj.disabled = true; - custnum_obj.style.color = '#000000'; - custnum_obj.style.backgroundColor = '#dddddd'; - - var customer_select = document.getElementById('cust_select'+searchrow); - - //alert('search for customer ' + customer + ', row#' + searchrow ); - - function search_customer_update(customers) { - - //alert('customers returned: ' + customers); - - var customerArray = eval('(' + customers + ')'); - - custnum_obj.disabled = false; - custnum_obj.style.backgroundColor = '#ffffff'; - - if ( customerArray.length == 0 ) { - - custnum_obj.value = 'Not found'; - custnum_obj.style.color = '#ff0000'; - customer_obj.style.color = '#ff0000'; - - customer_obj.style.display = ''; - customer_select.style.display = 'none'; - - - } else if ( customerArray.length == 1 ) { - - //alert('one customer found: ' + customerArray[0]); - - custnum_obj.value = customerArray[0][0]; - customer_obj.value = customerArray[0][1]; - - customer_obj.style.display = ''; - customer_select.style.display = 'none'; - - - } else { - - custnum_obj.value = 'Multiple'; // or something - custnum_obj.style.color = '#ff0000'; - - //alert('multiple customers found, have to create select dropdown'); - - //blank the current list - for ( var i = customer_select.length; i >= 0; i-- ) - customer_select.options[i] = null; - - opt(customer_select, '', 'Multiple customers match "' + customer + '" - select one', '#ff0000'); - - //add the multiple customers - for ( var s = 0; s < customerArray.length; s++ ) - opt(customer_select, customerArray[s][0], customerArray[s][1], '#000000'); - - opt(customer_select, 'cancel', '(Edit search string)', '#000000'); - - customer_obj.style.display = 'none'; - - customer_select.style.display = ''; - - } - - } - - smart_search( customer, search_customer_update ); - - } - - function select_customer() { - - var custnum = this.options[this.selectedIndex].value; - var customer = this.options[this.selectedIndex].text; - - var searchrow = this.getAttribute('rownum'); - var custnum_obj = document.getElementById('custnum'+searchrow); - var customer_obj = document.getElementById('customer'+searchrow); - - if ( custnum == '' ) { - //this.style.color = '#ff0000'; - - } else if ( custnum == 'cancel' ) { - - custnum_obj.value = ''; - custnum_obj.style.color = '#000000'; - - this.style.display = 'none'; - customer_obj.style.display = ''; - customer_obj.focus(); - - } else { - - - custnum_obj.value = custnum; - custnum_obj.style.color = '#000000'; - - customer_obj.value = customer; - customer_obj.style.color = '#000000'; - - this.style.display = 'none'; - customer_obj.style.display = ''; - - } - - } - - function opt(what,value,text,color) { - var optionName = new Option(text, value, false, false); - optionName.style.color = color; - var length = what.length; - what.options[length] = optionName; - } - -</SCRIPT> - -<TABLE ID="OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0> - -<TR> - <TH>Cust #</TH> - <TH>Customer</TH> - <TH>Amount</TH> - <TH>Check #</TH> - <TH BGCOLOR="#e8e8e8"></TH> -</TR> - -<% my $row = 0; - if ( $cgi->param('error') ) { - my $param = $cgi->Vars; -%> - - <% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { %> - - <TR> - - <TD> - <INPUT TYPE="text" NAME="custnum<%= $row %>" ID="custnum<%= $row %>" SIZE=8 MAXLENGTH=12 VALUE="<%= $param->{"custnum$row"} %>" rownum="<%= $row %>"> - <SCRIPT TYPE="text/javascript"> - var custnum_input<%= $row %> = document.getElementById("custnum<%= $row %>"); - custnum_input<%= $row %>.onfocus = clearhint_custnum; - custnum_input<%= $row %>.onchange = search_custnum; - </SCRIPT> - </TD> - - <TD> - <INPUT TYPE="text" NAME="customer<%= $row %>" ID="customer<%= $row %>" SIZE=64 VALUE="<%= $param->{"customer$row"} %>" rownum="<%= $row %>"> - <SCRIPT TYPE="text/javascript"> - var customer_input<%= $row %> = document.getElementById("customer<%= $row %>"); - customer_input<%= $row %>.onfocus = clearhint_customer; - customer_input<%= $row %>.onclick = clearhint_customer; - customer_input<%= $row %>.onchange = search_customer; - </SCRIPT> - <SELECT NAME="cust_select<%= $row %>" ID="cust_select<%= $row %>" rownum="<%= $row %>" STYLE="color:#ff0000; display:none""> - </SELECT> - <SCRIPT TYPE="text/javascript"> - var customer_select<%= $row %> = document.getElementById("cust_select<%= $row %>"); - customer_select<%= $row %>.onchange = select_customer; - </SCRIPT> - </TD> - - <TD> - $<INPUT TYPE="text" NAME="paid<%= $row %>" SIZE=8 MAXLENGTH=8 VALUE="<%= $param->{"paid$row"} %>" > - </TD> - - <TD> - <INPUT TYPE="text" NAME="payinfo<%= $row %>" SIZE=10 VALUE="<%= $param->{"payinfo$row"} %>" > - </TD> - - <TD BGCOLOR="#e8e8e8"> - <% if ( $param->{"error$row"} ) { %> - <FONT SIZE="-1" COLOR="#ff0000">Error: <%= $param->{"error$row"} %></FONT> - <% } %> - </TD> - - </TR> - - <% } %> - -<% } %> - -</TABLE> - -<!-- <BR> -<INPUT TYPE="button" VALUE="TEST addrow" onclick="addRow()"> --> - -<BR> -<INPUT TYPE="submit" NAME="submit" VALUE="Post payment batch"> - -</FORM> - - -<%= include('/elements/xmlhttp.html', - 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi', - 'subs' => [qw( custnum_search smart_search )], - ) -%> - -<SCRIPT TYPE="text/javascript"> - - var rownum = <%= $row %>; - - function addRow() { - - var table = document.getElementById('OneTrueTable'); - var tablebody = table.getElementsByTagName('tbody').item(0); - - var row = document.createElement('TR'); - - var custnum_cell = document.createElement('TD'); - - var custnum_input = document.createElement('INPUT'); - custnum_input.setAttribute('name', 'custnum'+rownum); - custnum_input.setAttribute('id', 'custnum'+rownum); - custnum_input.setAttribute('size', 8); - custnum_input.setAttribute('maxlength', 12); - custnum_input.setAttribute('rownum', rownum); - custnum_input.onfocus = clearhint_custnum; - custnum_input.onchange = search_custnum; - custnum_cell.appendChild(custnum_input); - - row.appendChild(custnum_cell); - - var customer_cell = document.createElement('TD'); - - var customer_input = document.createElement('INPUT'); - customer_input.setAttribute('name', 'customer'+rownum); - customer_input.setAttribute('id', 'customer'+rownum); - customer_input.setAttribute('size', 64); - customer_input.setAttribute('value', '(last name or company)' ); - customer_input.setAttribute('rownum', rownum); - customer_input.onfocus = clearhint_customer; - customer_input.onclick = clearhint_customer; - customer_input.onchange = search_customer; - customer_cell.appendChild(customer_input); - - var customer_select = document.createElement('SELECT'); - customer_select.setAttribute('name', 'cust_select'+rownum); - customer_select.setAttribute('id', 'cust_select'+rownum); - customer_select.setAttribute('rownum', rownum); - customer_select.style.color = '#ff0000'; - customer_select.style.display = 'none'; - customer_select.onchange = select_customer; - customer_cell.appendChild(customer_select); - - row.appendChild(customer_cell); - - var paid_cell = document.createElement('TD'); - - var paid_text = document.createTextNode('$'); - paid_cell.appendChild(paid_text); - - var paid_input = document.createElement('INPUT'); - paid_input.setAttribute('name', 'paid'+rownum); - paid_input.setAttribute('size', 8); - paid_input.setAttribute('maxlength', 8); - paid_cell.appendChild(paid_input); - - row.appendChild(paid_cell); - - var payinfo_cell = document.createElement('TD'); - var payinfo_input = document.createElement('INPUT'); - payinfo_input.setAttribute('name', 'payinfo'+rownum); - payinfo_input.setAttribute('size', 10); - payinfo_cell.appendChild(payinfo_input); - row.appendChild(payinfo_cell); - - var error_cell = document.createElement('TD'); - error_cell.style.backgroundColor = '#e8e8e8'; - row.appendChild(error_cell); - - tablebody.appendChild(row); - - rownum++; - - } - -</SCRIPT> - -</BODY> -</HTML> diff --git a/httemplate/misc/counties.cgi b/httemplate/misc/counties.cgi deleted file mode 100644 index 80ae616c9..000000000 --- a/httemplate/misc/counties.cgi +++ /dev/null @@ -1,17 +0,0 @@ -<% - - my( $state, $country ) = $cgi->param('arg'); - - my @counties = - sort - map { s/[\n\r]//g; $_; } - map { $_->county; } - qsearch( 'cust_main_county', - { 'state' => $state, - 'country' => $country, - }, - ) - ; - - -%>[ <%= join(', ', map { qq("$_") } @counties) %> ] diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 519e6c2b2..257c3384f 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -1,19 +1,13 @@ <% -my $custnum; -my $ban = ''; -if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { - $custnum = $1; - $ban = $cgi->param('ban'); -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/ || die "Illegal custnum"; - $custnum = $1; -} +#untaint custnum +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/ || die "Illegal custnum"; +my $custnum = $1; my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); -my @errors = $cust_main->cancel( 'ban' => $ban ); +my @errors = $cust_main->cancel; eidiot(join(' / ', @errors)) if scalar(@errors); #print $cgi->redirect($p. "view/cust_main.cgi?". $cust_main->custnum); diff --git a/httemplate/misc/process/batch-cust_pay.cgi b/httemplate/misc/process/batch-cust_pay.cgi deleted file mode 100644 index 12d72e8a0..000000000 --- a/httemplate/misc/process/batch-cust_pay.cgi +++ /dev/null @@ -1,42 +0,0 @@ -<% - my $param = $cgi->Vars; - - #my $paybatch = $param->{'paybatch'}; - my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); - - my @cust_pay = (); - #my $row = 0; - #while ( exists($param->{"custnum$row"}) ) { - for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) { - push @cust_pay, new FS::cust_pay { - 'custnum' => $param->{"custnum$row"}, - 'paid' => $param->{"paid$row"}, - 'payby' => 'BILL', - 'payinfo' => $param->{"payinfo$row"}, - 'paybatch' => $paybatch, - } - if $param->{"custnum$row"} - || $param->{"paid$row"} - || $param->{"payinfo$row"}; - #$row++; - } - - my @errors = FS::cust_pay->batch_insert(@cust_pay); - my $num_errors = scalar(grep $_, @errors); - - if ( $num_errors ) { - - $cgi->param('error', "$num_errors error". ($num_errors>1 ? 's' : ''). - ' - Batch not processed, correct and resubmit' - ); - - my $erow=0; - $cgi->param('error'. $erow++, shift @errors) while @errors; - - %><%= $cgi->redirect($p.'batch-cust_pay.html?'. $cgi->query_string) - - %><% } else { - - %><%= $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %> - - <% } %> diff --git a/httemplate/misc/states.cgi b/httemplate/misc/states.cgi deleted file mode 100644 index cff2c9774..000000000 --- a/httemplate/misc/states.cgi +++ /dev/null @@ -1,16 +0,0 @@ -<% - - my $country = $cgi->param('arg'); - - my @states = - sort - map { s/[\n\r]//g; $_; } - map { $_->state; } - qsearch( 'cust_main_county', - { 'country' => $country }, - 'DISTINCT ON ( state ) *', - ) - ; - - -%>[ <%= join(', ', map { qq("$_") } @states) %> ] diff --git a/httemplate/misc/unvoid-cust_pay_void.cgi b/httemplate/misc/unvoid-cust_pay_void.cgi deleted file mode 100755 index 539cd4a23..000000000 --- a/httemplate/misc/unvoid-cust_pay_void.cgi +++ /dev/null @@ -1,16 +0,0 @@ -<% - -#untaint paynum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal paynum"; -my $paynum = $1; - -my $cust_pay_void = qsearchs('cust_pay_void', { 'paynum' => $paynum } ); -my $custnum = $cust_pay_void->custnum; - -my $error = $cust_pay_void->unvoid; -eidiot($error) if $error; - -print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); - -%> diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi deleted file mode 100644 index 8dbd5a4f2..000000000 --- a/httemplate/misc/xmlhttp-cust_main-search.cgi +++ /dev/null @@ -1,21 +0,0 @@ -<% - my $sub = $cgi->param('sub'); - - if ( $sub eq 'custnum_search' ) { - - my $custnum = $cgi->param('arg'); - my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); - - %>"<%= $cust_main ? $cust_main->name : '' %>" - -<% } elsif ( $sub eq 'smart_search' ) { - - my $string = $cgi->param('arg'); - my @cust_main = smart_search( 'search' => $string ); - my $return = [ map [ $_->custnum, $_->name ], @cust_main ]; - - %><%= objToJson($return) %> - -<% } %> - - diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi deleted file mode 100755 index 5b0538ca3..000000000 --- a/httemplate/search/cust_bill.cgi +++ /dev/null @@ -1,165 +0,0 @@ -<% - -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, $tot_amount, $tot_balance); - -my(@cust_bill); -if ( $cgi->keywords ) { - my($query) = $cgi->keywords; - my $owed = "charged - ( select coalesce(sum(amount),0) from cust_bill_pay - where cust_bill_pay.invnum = cust_bill.invnum ) - - ( select coalesce(sum(amount),0) from cust_credit_bill - where cust_credit_bill.invnum = cust_bill.invnum )"; - my @where; - if ( $query =~ /^(OPEN(\d*)_)?(invnum|date|custnum)$/ ) { - my($open, $days, $field) = ($1, $2, $3); - $field = "_date" if $field eq 'date'; - $orderby = "ORDER BY cust_bill.$field"; - push @where, "0 != $owed" if $open; - push @where, "cust_bill._date < ". (time-86400*$days) if $days; - } else { - die "unknown query string $query"; - } - - my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; - - my $statement = "SELECT COUNT(*), sum(charged), sum($owed) - FROM cust_bill $extra_sql"; - my $sth = dbh->prepare($statement) or die dbh->errstr. " doing $statement"; - $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; - - ( $total, $tot_amount, $tot_balance ) = @{$sth->fetchrow_arrayref}; - - @cust_bill = qsearch( - 'cust_bill', - {}, - "cust_bill.*, $owed as owed", - "$extra_sql $orderby $limit" - ); -} else { - $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/; - my $invnum = $2; - @cust_bill = qsearchs('cust_bill', { 'invnum' => $invnum } ); - $total = scalar(@cust_bill); -} - -#if ( scalar(@cust_bill) == 1 ) { -if ( $total == 1 ) { - my $invnum = $cust_bill[0]->invnum; - print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect -} elsif ( scalar(@cust_bill) == 0 ) { -%> -<!-- mason kludge --> -<% - eidiot("Invoice not found."); -} else { -%> -<!-- mason kludge --> -<% - - #begin pager - my $pager = ''; - if ( $total != scalar(@cust_bill) && $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("Invoice Search Results", menubar( - 'Main Menu', popurl(2) - )). - "$total matching invoices found<BR>". - "\$$tot_balance total balance<BR>". - "\$$tot_amount total amount<BR>". - "<BR>$pager". table(). <<END; - <TR> - <TH></TH> - <TH>Balance</TH> - <TH>Amount</TH> - <TH>Date</TH> - <TH>Contact name</TH> - <TH>Company</TH> - </TR> -END - - foreach my $cust_bill ( @cust_bill ) { - my($invnum, $owed, $charged, $date ) = ( - $cust_bill->invnum, - sprintf("%.2f", $cust_bill->getfield('owed')), - sprintf("%.2f", $cust_bill->charged), - $cust_bill->_date, - ); - my $pdate = time2str("%b %d %Y", $date); - - my $rowspan = 1; - - my $view = popurl(2). "view/cust_bill.cgi?$invnum"; - print <<END; - <TR> - <TD ROWSPAN=$rowspan><A HREF="$view">$invnum</A></TD> - <TD ROWSPAN=$rowspan ALIGN="right"><A HREF="$view">\$$owed</A></TD> - <TD ROWSPAN=$rowspan ALIGN="right"><A HREF="$view">\$$charged</A></TD> - <TD ROWSPAN=$rowspan><A HREF="$view">$pdate</A></TD> -END - my $custnum = $cust_bill->custnum; - my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); - if ( $cust_main ) { - my $cview = popurl(2). "view/cust_main.cgi?". $cust_main->custnum; - my ( $name, $company ) = ( - $cust_main->last. ', '. $cust_main->first, - $cust_main->company, - ); - print <<END; - <TD ROWSPAN=$rowspan><A HREF="$cview">$name</A></TD> - <TD ROWSPAN=$rowspan><A HREF="$cview">$company</A></TD> -END - } else { - print <<END - <TD ROWSPAN=$rowspan COLSPAN=2>WARNING: couldn't find cust_main.custnum $custnum (cust_bill.invnum $invnum)</TD> -END - } - - print "</TR>"; - } - $tot_balance = sprintf("%.2f", $tot_balance); - $tot_amount = sprintf("%.2f", $tot_amount); - print "</TABLE>$pager<BR>". table(). <<END; - <TR><TD> </TD><TH>Total<BR>Balance</TH><TH>Total<BR>Amount</TH></TR> - <TR><TD></TD><TD ALIGN="right">\$$tot_balance</TD><TD ALIGN="right">\$$tot_amount</TD></TD></TR> - </TABLE> - </BODY> -</HTML> -END - -} - -%> diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 2108653a8..5e904e114 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -95,7 +95,7 @@ 'cust_bill.*', #( map "cust_main.$_", qw(custnum last first company) ), 'cust_main.custnum as cust_main_custnum', - FS::UI::Web::cust_sql_fields(), + ( map "cust_main.$_", qw(last first company) ), "$owed as owed", ), 'extra_sql' => "$extra_sql $orderby" @@ -106,7 +106,8 @@ my $link = [ "${p}view/cust_bill.cgi?", 'invnum', ]; my $clink = sub { my $cust_bill = shift; - $cust_bill->cust_main_custnum + my $cust_main = $cust_bill->cust_main; + $cust_main ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; }; @@ -153,18 +154,32 @@ 'count_query' => $count_query, 'count_addl' => $count_addl, 'redirect' => $link, - 'header' => [ 'Invoice #', - 'Balance', - 'Amount', - 'Date', - FS::UI::Web::cust_header(), - ], + 'header' => + [ 'Invoice #', qw(Balance Amount Date), 'Contact name', + 'Company' ], 'fields' => [ 'invnum', sub { sprintf($money_char.'%.2f', shift->get('owed') ) }, sub { sprintf($money_char.'%.2f', shift->charged ) }, sub { time2str('%b %d %Y', shift->_date ) }, - \&FS::UI::Web::cust_fields, + 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. ')'; + if ( $cust_bill->cust_main_custnum ) { + FS::cust_main::name($cust_bill); + } else { + "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 : ''; + }, ], 'align' => 'rrrrll', 'links' => [ @@ -172,7 +187,8 @@ $link, $link, $link, - ( map { $clink } FS::UI::Web::cust_header() ), + $clink, + $clink, ], ) diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi index d82a83368..f34bb68f4 100644 --- a/httemplate/search/cust_bill_event.cgi +++ b/httemplate/search/cust_bill_event.cgi @@ -15,16 +15,8 @@ my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); my $where = " WHERE cust_bill_event._date >= $beginning". " AND cust_bill_event._date <= $ending"; - -if ( $cgi->param('failed') ) { - $where .= " AND statustext != '' ". - " AND statustext IS NOT NULL ". - " AND statustext != 'N/A' " -} - -if ( $cgi->param('part_bill_event.payby') =~ /^(\w+)$/ ) { - $where .= " AND part_bill_event.payby = '$1' "; -} +$where .= " AND statustext != '' AND statustext IS NOT NULL" + if $cgi->param('failed'); my $sql_query = { 'table' => 'cust_bill_event', @@ -35,8 +27,8 @@ my $sql_query = { 'part_bill_event.event', 'cust_bill.custnum', 'cust_bill._date AS cust_bill_date', - 'cust_main.custnum AS cust_main_custnum', - FS::UI::Web::cust_sql_fields(), + map "cust_main.$_", qw(last first company) + ), 'extra_sql' => "$where ORDER BY _date ASC", 'addl_from' => 'LEFT JOIN part_bill_event USING ( eventpart ) '. @@ -44,9 +36,7 @@ my $sql_query = { 'LEFT JOIN cust_main USING ( custnum ) ', }; -my $count_sql = "SELECT COUNT(*) FROM cust_bill_event ". - "LEFT JOIN part_bill_event USING ( eventpart ) ". - $where; +my $count_sql = "select count(*) from cust_bill_event $where"; my $conf = new FS::Conf; @@ -81,13 +71,6 @@ push @$menubar, 'Re-fax these events' => "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, @@ -95,12 +78,9 @@ my $link_cust = sub { 'name' => 'billing events', 'query' => $sql_query, 'count_query' => $count_sql, - 'header' => [ 'Event', - 'Date', - 'Status', + 'header' => [ qw( Event Date Status ), #'Inv #', 'Inv Date', 'Cust #', - 'Invoice', - FS::UI::Web::cust_header(), + 'Invoice', 'Cust #', ], 'fields' => [ 'event', @@ -119,7 +99,9 @@ my $link_cust = sub { time2str("%D", $_[0]->cust_bill_date). ')'; }, - \&FS::UI::Web::cust_fields, + sub { FS::cust_main::name($_[0]) }, + + ], 'links' => [ '', @@ -131,7 +113,8 @@ my $link_cust = sub { $template .= '-' if $template; [ "${p}view/cust_bill.cgi?$template", 'invnum']; }, - ( map { $link_cust } FS::UI::Web::cust_header() ), + [ "${p}view/cust_main.cgi?", 'custnum' ], + [ "${p}view/cust_main.cgi?", 'custnum' ], ], ) %> diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html index 197f28028..476d22161 100755 --- a/httemplate/search/cust_bill_event.html +++ b/httemplate/search/cust_bill_event.html @@ -7,6 +7,10 @@ ) %> + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> <FORM ACTION="cust_bill_event.cgi" METHOD="GET"> <INPUT TYPE="hidden" NAME="failed" VALUE="<%= $cgi->param('failed') %>"> @@ -23,33 +27,29 @@ </TD> </TR> --> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> - <!-- <TR> - <TD ALIGN="right">Events: </TD> - <TD> - <SELECT NAME="eventpart"> - <OPTION SELECTED VALUE=""><%= $cgi->param('failed') ? '(all failed events)' : '(all events)' %> - <% foreach my $part_bill_event ( qsearch( 'part_bill_event', {} ) ) { %> - <% } %> - </SELECT> - </TD> + <TD ALIGN="right">From: </TD> + <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "beginning_text", + ifFormat: "%m/%d/%Y", + button: "beginning_button", + align: "BR" + }); +</SCRIPT> </TR> - --> <TR> - <TD ALIGN="right">Events for payment type: </TD> - <TD> - <SELECT NAME="part_bill_event.payby"> - <OPTION SELECTED VALUE="">(all) - <OPTION VALUE="CARD">Credit card (automatic) - <OPTION VALUE="BILL">Billing - <OPTION VALUE="CHEK">Electronic check (automatic) - <OPTION VALUE="DCRD">Credit card (on-demand) - <OPTION VALUE="DCHK">Electronic check (on-demand) - <OPTION VALUE="LECB">Phone bill billing - <OPTION VALUE="COMP">Complimentary - </SELECT> - </TD> + <TD ALIGN="right">To: </TD> + <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "ending_text", + ifFormat: "%m/%d/%Y", + button: "ending_button", + align: "BR" + }); +</SCRIPT> </TR> </TABLE> <BR><INPUT TYPE="submit" VALUE="Get Report"> diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi deleted file mode 100644 index 082ccc893..000000000 --- a/httemplate/search/cust_bill_pkg.cgi +++ /dev/null @@ -1,148 +0,0 @@ -<% - -my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - -my $join_cust = " - JOIN cust_bill USING ( invnum ) - JOIN cust_main USING ( custnum ) -"; - -my $join_pkg = " - LEFT JOIN cust_pkg USING ( pkgnum ) - LEFT JOIN part_pkg USING ( pkgpart ) -"; - -my $where = " - WHERE _date >= $beginning AND _date <= $ending - AND payby != 'COMP' -"; - -if ( $cgi->param('out') ) { - - $where .= " - AND 0 = ( - SELECT COUNT(*) FROM cust_main_county - WHERE ( cust_main_county.county = cust_main.county - OR ( cust_main_county.county IS NULL AND cust_main.county = '' ) - OR ( cust_main_county.county = '' AND cust_main.county IS NULL) - OR ( cust_main_county.county IS NULL AND cust_main.county IS NULL) - ) - AND ( cust_main_county.state = cust_main.state - OR ( cust_main_county.state IS NULL AND cust_main.state = '' ) - OR ( cust_main_county.state = '' AND cust_main.state IS NULL ) - OR ( cust_main_county.state IS NULL AND cust_main.state IS NULL ) - ) - AND cust_main_county.country = cust_main.country - AND cust_main_county.tax > 0 - ) - "; - -} elsif ( $cgi->param('country' ) ) { - - my $county = dbh->quote( $cgi->param('county') ); - my $state = dbh->quote( $cgi->param('state') ); - my $country = dbh->quote( $cgi->param('country') ); - $where .= " - AND ( county = $county OR $county = '' ) - AND ( state = $state OR $state = '' ) - AND country = $country - "; - $where .= ' AND taxclass = '. dbh->quote( $cgi->param('taxclass') ) - if $cgi->param('taxclass'); - -} - -$where .= ' AND pkgnum != 0' if $cgi->param('nottax'); - -$where .= ' AND pkgnum = 0' if $cgi->param('istax'); - -$where .= " AND tax = 'Y'" if $cgi->param('cust_tax'); - -my $count_query; -if ( $cgi->param('pkg_tax') ) { - - $count_query = - "SELECT COUNT(*), SUM( ( CASE WHEN part_pkg.setuptax = 'Y' - THEN cust_bill_pkg.setup - ELSE 0 ) - + - ( CASE WHEN part_pkg.recurtax = 'Y' - THEN cust_bill_pkg.recur - ELSE 0 ) - )"; - - $where .= " AND ( - ( part_pkg.setuptax = 'Y' AND cust_bill_pkg.setup > 0 ) - OR ( part_pkg.recurtax = 'Y' AND cust_bill_pkg.recur > 0 ) - )"; - -} else { - - $count_query = - "SELECT COUNT(*), SUM(cust_bill_pkg.setup + cust_bill_pkg.recur)"; - -} -$count_query .= " FROM cust_bill_pkg $join_cust $join_pkg $where"; - -my $query = { - 'table' => 'cust_bill_pkg', - 'addl_from' => "$join_cust $join_pkg", - 'hashref' => {}, - 'select' => join(', ', - 'cust_bill_pkg.*', - 'cust_bill._date', - 'part_pkg.pkg', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => $where, -}; - -my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ]; -my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; - -my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; - -%><%= include( 'elements/search.html', - 'title' => 'Line items', - 'name' => 'line items', - 'query' => $query, - 'count_query' => $count_query, - 'count_addl' => [ $money_char. '%.2f total', ], - 'header' => [ - '#', - 'Description', - 'Setup charge', - 'Recurring charge', - 'Invoice', - 'Date', - FS::UI::Web::cust_header(), - ], - 'fields' => [ - 'billpkgnum', - sub { $_[0]->pkgnum > 0 - ? $_[0]->get('pkg') - : $_[0]->get('itemdesc') - }, - #strikethrough or "N/A ($amount)" or something these when - # they're not applicable to pkg_tax search - sub { sprintf($money_char.'%.2f', shift->setup ) }, - sub { sprintf($money_char.'%.2f', shift->recur ) }, - 'invnum', - sub { time2str('%b %d %Y', shift->_date ) }, - \&FS::UI::Web::cust_fields, - ], - 'links' => [ - '', - '', - '', - '', - $ilink, - $ilink, - ( map { $clink } FS::UI::Web::cust_header() ), - ], - 'align' => 'rlrrrc', - ) -%> - diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index 279d682cd..b978e6238 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -5,7 +5,7 @@ my @search = (); if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) { - push @search, "cust_credit.otaker = '$1'"; + push @search, "otaker = '$1'"; } if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { @@ -46,22 +46,13 @@ my $sql_query = { 'table' => 'cust_credit', - 'select' => join(', ', - 'cust_credit.*', - 'cust_main.custnum as cust_main_custnum', - FS::UI::Web::cust_sql_fields(), - ), + 'select' => 'cust_credit.*, cust_main.last, cust_main.first, cust_main.company', 'hashref' => {}, 'extra_sql' => $where, 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', }; - my $clink = sub { - my $cust_bill = shift; - $cust_bill->cust_main_custnum - ? [ "${p}view/cust_main.cgi?", 'custnum' ] - : ''; - }; + my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; %><%= include( 'elements/search.html', 'title' => $title, @@ -70,26 +61,26 @@ 'count_query' => $count_query, 'count_addl' => [ '$%.2f total credited', ], #'redirect' => $link, - 'header' => [ 'Amount', - 'Date', - FS::UI::Web::cust_header(), - 'By', - 'Reason' - ], + '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 ) }, - \&FS::UI::Web::cust_fields, + 'custnum', + sub { $_[0]->get('last'). ', '. $_[0]->first; }, + 'company', 'otaker', 'reason', ], - #'align' => 'rrrllll', - 'align' => 'rr', + 'align' => 'rrrllll', 'links' => [ '', '', - ( map { $clink } FS::UI::Web::cust_header() ), + $clink, + $clink, + $clink, '', '', ], diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 99ffc3d20..c23653aa9 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -1,122 +1,84 @@ <% my $title = 'Payment Search Results'; my( $count_query, $sql_query ); - if ( $cgi->param('magic') ) { - + if ( $cgi->param('magic') && $cgi->param('magic') eq '_date' ) { + my @search = (); - my $orderby; - if ( $cgi->param('magic') eq '_date' ) { + + if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { + push @search, "agentnum = $1"; # $search{'agentnum'} = $1; + my $agent = qsearchs('agent', { 'agentnum' => $1 } ); + die "unknown agentnum $1" unless $agent; + $title = $agent->agent. " $title"; + } - - if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { - push @search, "agentnum = $1"; # $search{'agentnum'} = $1; - my $agent = qsearchs('agent', { 'agentnum' => $1 } ); - die "unknown agentnum $1" unless $agent; - $title = $agent->agent. " $title"; - } - - if ( $cgi->param('payby') ) { - $cgi->param('payby') =~ - /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/ - or die "illegal payby ". $cgi->param('payby'); - push @search, "cust_pay.payby = '$1'"; - if ( $3 ) { - if ( $3 eq 'VisaMC' ) { - #avoid posix regexes for portability - push @search, - " ( ( substring(cust_pay.payinfo from 1 for 1) = '4' ". - " AND substring(cust_pay.payinfo from 1 for 4) != '4936' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49030[2-9]' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49033[5-9]' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49110[1-2]' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49117[4-9]' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49118[1-2]' ". - " )". - " OR substring(cust_pay.payinfo from 1 for 2) = '51' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '52' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '53' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '55' ". - " ) "; - } elsif ( $3 eq 'Amex' ) { - push @search, - " ( substring(cust_pay.payinfo from 1 for 2 ) = '34' ". - " OR substring(cust_pay.payinfo from 1 for 2 ) = '37' ". - " ) "; - } elsif ( $3 eq 'Discover' ) { - push @search, - " ( substring(cust_pay.payinfo from 1 for 4 ) = '6011' ". - " OR substring(cust_pay.payinfo from 1 for 3 ) = '650' ". - " ) "; - } elsif ( $3 eq 'Maestro' ) { - push @search, - " ( substring(cust_pay.payinfo from 1 for 2 ) = '63' ". - " OR substring(cust_pay.payinfo from 1 for 2 ) = '67' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ". - " OR substring(cust_pay.payinfo from 1 for 4 ) = '4936' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49030[2-9]' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49033[5-9]' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49110[1-2]' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49117[4-9]' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49118[1-2]' ". - " ) "; - } else { - die "unknown card type $3"; - } + if ( $cgi->param('payby') ) { + $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ + or die "illegal payby ". $cgi->param('payby'); + push @search, "cust_pay.payby = '$1'"; + if ( $3 ) { + if ( $3 eq 'VisaMC' ) { + #avoid posix regexes for portability + push @search, + " ( substring(cust_pay.payinfo from 1 for 1) = '4' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '51' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '52' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '53' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". + " OR substring(cust_pay.payinfo from 1 for 2) = '55' ". + " ) "; + } elsif ( $3 eq 'Amex' ) { + push @search, + " ( substring(cust_pay.payinfo from 1 for 2 ) = '34' ". + " OR substring(cust_pay.payinfo from 1 for 2 ) = '37' ". + " ) "; + } elsif ( $3 eq 'Discover' ) { + push @search, + " substring(cust_pay.payinfo from 1 for 4 ) = '6011' "; + } else { + die "unknown card type $3"; } } - - my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - push @search, "_date >= $beginning ", - "_date <= $ending"; - - $orderby = '_date'; + } - } elsif ( $cgi->param('magic') eq 'paybatch' ) { - - $cgi->param('paybatch') =~ /^([\w\/\:\-\.]+)$/ - or die "illegal paybatch: ". $cgi->param('paybatch'); - - push @search, "paybatch = '$1'"; - - $orderby = "LOWER(company || ' ' || last || ' ' || first )"; - - } else { - die "unknown search magic: ". $cgi->param('magic'); + #false laziness with cust_pkg.cgi + if ( $cgi->param('beginning') + && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $beginning = str2time($1); + push @search, "_date >= $beginning "; } - + if ( $cgi->param('ending') + && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $ending = str2time($1) + 86399; + push @search, " _date <= $ending "; + } + if ( $cgi->param('begin') + && $cgi->param('begin') =~ /^(\d+)$/ ) { + push @search, "_date >= $1 "; + } + if ( $cgi->param('end') + && $cgi->param('end') =~ /^(\d+)$/ ) { + push @search, " _date < $1 "; + } + my $search = ''; if ( @search ) { $search = ' WHERE '. join(' AND ', @search); } - + $count_query = "SELECT COUNT(*), SUM(paid) ". "FROM cust_pay LEFT JOIN cust_main USING ( custnum )". $search; - + $sql_query = { 'table' => 'cust_pay', - 'select' => join(', ', - 'cust_pay.*', - 'cust_main.custnum as cust_main_custnum', - FS::UI::Web::cust_sql_fields(), - ), + 'select' => 'cust_pay.*, cust_main.last, cust_main.first, cust_main.company', 'hashref' => {}, - 'extra_sql' => "$search ORDER BY $orderby", + 'extra_sql' => "$search ORDER BY _date", 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', }; - + } else { $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; @@ -137,12 +99,7 @@ } - my $link = sub { - my $cust_pay = shift; - $cust_pay->cust_main_custnum - ? [ "${p}view/cust_main.cgi?", 'custnum' ] - : ''; - }; + my $link = [ "${p}view/cust_main.cgi?", 'custnum' ]; %><%= include( 'elements/search.html', 'title' => $title, @@ -150,11 +107,9 @@ 'query' => $sql_query, 'count_query' => $count_query, 'count_addl' => [ '$%.2f total paid', ], - 'header' => [ 'Payment', - 'Amount', - 'Date', - FS::UI::Web::cust_header(), - ], + 'header' => + [ qw(Payment Amount Date), 'Cust #', 'Contact name', + 'Company', ], 'fields' => [ sub { my $cust_pay = shift; @@ -164,29 +119,24 @@ '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; - } elsif ( $cust_pay->payby eq 'CASH' ) { - 'Cash '. $cust_pay->payinfo; - } elsif ( $cust_pay->payby eq 'WEST' ) { - 'Western Union'; #. $cust_pay->payinfo; - } elsif ( $cust_pay->payby eq 'MCRD' ) { - 'Manual credit card'; #. $cust_pay->payinfo; } else { $cust_pay->payby. ' '. $cust_pay->payinfo; } }, sub { sprintf('$%.2f', shift->paid ) }, sub { time2str('%b %d %Y', shift->_date ) }, - \&FS::UI::Web::cust_fields, + 'custnum', + sub { $_[0]->get('last'). ', '. $_[0]->first; }, + 'company', ], - #'align' => 'lrrrll', - 'align' => 'rrr', + 'align' => 'lrrrll', 'links' => [ '', '', '', - ( map { $link } FS::UI::Web::cust_header() ), + $link, + $link, + $link, ], ) %> diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 5da4d82fb..6d26317e0 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,234 +1,363 @@ <% +my $conf = new FS::Conf; +my $maxrecords = $conf->config('maxsearchrecordsperpage'); + my %part_pkg = map { $_->pkgpart => $_ } qsearch('part_pkg', {}); -my($query) = $cgi->keywords; +my $limit = ''; +$limit .= "LIMIT $maxrecords" if $maxrecords; -my $orderby; -my @where; -my $cjoin = ''; +my $offset = $cgi->param('offset') || 0; +$limit .= " OFFSET $offset" if $offset; -if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { - $cjoin = "LEFT JOIN cust_main USING ( custnum )"; - push @where, - "agentnum = $1"; -} +my $total; + +my($query) = $cgi->keywords; +my $sortby; +my @cust_pkg; if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { - $orderby = 'ORDER BY bill'; + $sortby=\*bill_sort; + + #false laziness with cust_pay.cgi + my $range = ''; + if ( $cgi->param('beginning') + && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $beginning = str2time($1); + $range = " WHERE bill >= $beginning "; + } + if ( $cgi->param('ending') + && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { + my $ending = str2time($1) + 86399; + $range .= ( $range ? ' AND ' : ' WHERE ' ). " bill <= $ending "; + } - my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - push @where, - "bill >= $beginning ", - "bill <= $ending", - '( cancel IS NULL OR cancel = 0 )'; + $range .= ( $range ? 'AND ' : ' WHERE ' ). '( cancel IS NULL OR cancel = 0 )'; + + if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { + $range .= ( $range ? 'AND ' : ' WHERE ' ). + "$1 = ( SELECT agentnum FROM cust_main". + " WHERE cust_main.custnum = cust_pkg.custnum )"; + } + + #false laziness with below + my $statement = "SELECT COUNT(*) FROM cust_pkg $range"; + warn $statement; + my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; + $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; + + $total = $sth->fetchrow_arrayref->[0]; + + @cust_pkg = qsearch('cust_pkg',{}, '', " $range ORDER BY bill $limit" ); } else { + my $qual = ''; if ( $cgi->param('magic') && - $cgi->param('magic') =~ /^(active|suspended|cancell?ed)$/ + $cgi->param('magic') =~ /^(active|suspended|canceled)$/ ) { - $orderby = 'ORDER BY pkgnum'; - if ( $cgi->param('magic') eq 'active' ) { - - #push @where, - # '( susp IS NULL OR susp = 0 )', - # '( cancel IS NULL OR cancel = 0)'; - push @where, FS::cust_pkg->active_sql(); - + $qual = 'WHERE ( susp IS NULL OR susp = 0 )'. + ' AND ( cancel IS NULL OR cancel = 0)'; } elsif ( $cgi->param('magic') eq 'suspended' ) { - - push @where, - 'susp IS NOT NULL', - 'susp != 0', - '( cancel IS NULL OR cancel = 0)'; - - } elsif ( $cgi->param('magic') =~ /^cancell?ed$/ ) { - - push @where, - 'cancel IS NOT NULL', - 'cancel != 0'; - + $qual = 'WHERE susp IS NOT NULL AND susp != 0'. + ' AND ( cancel IS NULL OR cancel = 0)'; + } elsif ( $cgi->param('magic') eq 'canceled' ) { + $qual = 'WHERE cancel IS NOT NULL AND cancel != 0'; } else { die "guru meditation #420"; } + $sortby = \*pkgnum_sort; + if ( $cgi->param('pkgpart') =~ /^(\d+)$/ ) { - push @where, "pkgpart = $1"; + $qual .= " AND pkgpart = $1"; } } elsif ( $query eq 'pkgnum' ) { - $orderby = 'ORDER BY pkgnum'; + $sortby=\*pkgnum_sort; } elsif ( $query eq 'APKG_pkgnum' ) { - $orderby = 'ORDER BY pkgnum'; + $sortby=\*pkgnum_sort; + + #@cust_pkg=(); + ##perhaps this should go in cust_pkg as a qsearch-like constructor? + #my($cust_pkg); + #foreach $cust_pkg ( + # qsearch('cust_pkg',{}, '', "ORDER BY pkgnum $limit" ) + #) { + # my($flag)=0; + # my($pkg_svc); + # PKG_SVC: + # foreach $pkg_svc (qsearch('pkg_svc',{ 'pkgpart' => $cust_pkg->pkgpart })) { + # if ( $pkg_svc->quantity + # > scalar(qsearch('cust_svc',{ + # 'pkgnum' => $cust_pkg->pkgnum, + # 'svcpart' => $pkg_svc->svcpart, + # })) + # ) + # { + # $flag=1; + # last PKG_SVC; + # } + # } + # push @cust_pkg, $cust_pkg if $flag; + #} + + if ( driver_name eq 'mysql' ) { + #$query = "DROP TABLE temp1_$$,temp2_$$;"; + #my $sth = dbh->prepare($query); + #$sth->execute; + + $query = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM + SELECT cust_svc.pkgnum,cust_svc.svcpart,COUNT(*) as count + FROM cust_pkg,cust_svc,pkg_svc + WHERE cust_pkg.pkgnum = cust_svc.pkgnum + AND cust_svc.svcpart = pkg_svc.svcpart + AND cust_pkg.pkgpart = pkg_svc.pkgpart + GROUP BY cust_svc.pkgnum,cust_svc.svcpart"; + my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; + + $sth->execute or die "Error executing \"$query\": ". $sth->errstr; - push @where, '0 < ( - SELECT count(*) FROM pkg_svc - WHERE pkg_svc.pkgpart = cust_pkg.pkgpart - AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc - WHERE cust_svc.pkgnum = cust_pkg.pkgnum - AND cust_svc.svcpart = pkg_svc.svcpart - ) - )'; + $query = "CREATE TEMPORARY TABLE temp2_$$ TYPE=MYISAM + SELECT cust_pkg.pkgnum FROM cust_pkg + LEFT JOIN pkg_svc ON (cust_pkg.pkgpart=pkg_svc.pkgpart) + LEFT JOIN temp1_$$ ON (cust_pkg.pkgnum = temp1_$$.pkgnum + AND pkg_svc.svcpart=temp1_$$.svcpart) + WHERE ( pkg_svc.quantity > temp1_$$.count + OR temp1_$$.pkgnum IS NULL ) + AND pkg_svc.quantity != 0;"; + $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; + $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + $qual = " LEFT JOIN temp2_$$ ON cust_pkg.pkgnum = temp2_$$.pkgnum + WHERE temp2_$$.pkgnum IS NOT NULL"; + + } else { + + $qual = " + WHERE 0 < + ( SELECT count(*) FROM pkg_svc + WHERE pkg_svc.pkgpart = cust_pkg.pkgpart + AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc + WHERE cust_svc.pkgnum = cust_pkg.pkgnum + AND cust_svc.svcpart = pkg_svc.svcpart + ) + ) + "; + + } } else { die "Empty or unknown QUERY_STRING!"; } + + my $statement = "SELECT COUNT(*) FROM cust_pkg $qual"; + my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; + $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; + + $total = $sth->fetchrow_arrayref->[0]; + + my $tblname = driver_name eq 'mysql' ? 'cust_pkg.' : ''; + @cust_pkg = + qsearch('cust_pkg',{}, '', "$qual ORDER BY ${tblname}pkgnum $limit" ); + + if ( driver_name eq 'mysql' ) { + $query = "DROP TABLE temp1_$$,temp2_$$;"; + my $sth = dbh->prepare($query) or die dbh->errstr. " doing $query"; + $sth->execute; # or die "Error executing \"$query\": ". $sth->errstr; + } + +} + +if ( scalar(@cust_pkg) == 1 ) { + print $cgi->redirect("${p}view/cust_main.cgi?". $cust_pkg[0]->custnum. + "#cust_pkg". $cust_pkg[0]->pkgnum ); + #exit; +} elsif ( scalar(@cust_pkg) == 0 ) { #error +%> +<!-- mason kludge --> +<% + eidiot("No packages found"); +} else { +%> +<!-- mason kludge --> +<% + $total ||= scalar(@cust_pkg); + + #begin pager + my $pager = ''; + if ( $total != scalar(@cust_pkg) && $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('Package Search Results',''), + "$total matching packages found<BR><BR>$pager", &table(), <<END; + <TR> + <TH>Package</TH> + <TH><FONT SIZE=-1>Setup</FONT></TH> +END + + print '<TH><FONT SIZE=-1>Last<BR>bill</FONT></TH>' + if defined dbdef->table('cust_pkg')->column('last_bill'); + + print <<END; + <TH><FONT SIZE=-1>Next<BR>bill</FONT></TH> + <TH><FONT SIZE=-1>Susp.</FONT></TH> + <TH><FONT SIZE=-1>Expire</FONT></TH> + <TH><FONT SIZE=-1>Cancel</FONT></TH> + <TH><FONT SIZE=-1>Cust#</FONT></TH> + <TH>(bill) name</TH> + <TH>company</TH> +END + + print '<TH>(service) name</TH><TH>company</TH>' + if defined dbdef->table('cust_main')->column('ship_last'); + + print '<TH COLSPAN=2>Services</TH></TR>'; + + my $n1 = '<TR>'; + my(%saw,$cust_pkg); + foreach $cust_pkg ( + sort $sortby grep(!$saw{$_->pkgnum}++, @cust_pkg) + ) { + my($cust_main)=qsearchs('cust_main',{'custnum'=>$cust_pkg->custnum}); + my($pkgnum, $setup, $bill, $susp, $expire, $cancel, + $custnum, $last, $first, $company ) = ( + $cust_pkg->pkgnum, + $cust_pkg->getfield('setup') + ? time2str("%D", $cust_pkg->getfield('setup') ) + : '', + $cust_pkg->getfield('bill') + ? time2str("%D", $cust_pkg->getfield('bill') ) + : '', + $cust_pkg->getfield('susp') + ? time2str("%D", $cust_pkg->getfield('susp') ) + : '', + $cust_pkg->getfield('expire') + ? time2str("%D", $cust_pkg->getfield('expire') ) + : '', + $cust_pkg->getfield('cancel') + ? time2str("%D", $cust_pkg->getfield('cancel') ) + : '', + $cust_pkg->custnum, + $cust_main ? $cust_main->last : '', + $cust_main ? $cust_main->first : '', + $cust_main ? $cust_main->company : '', + ); + + my $last_bill = $cust_pkg->getfield('last_bill') + ? time2str("%D", $cust_pkg->getfield('last_bill') ) + : '' + if defined dbdef->table('cust_pkg')->column('last_bill'); + + my($ship_last, $ship_first, $ship_company); + if ( defined dbdef->table('cust_main')->column('ship_last') ) { + ($ship_last, $ship_first, $ship_company) = ( + $cust_main + ? ( $cust_main->ship_last || $cust_main->getfield('last') ) + : '', + $cust_main + ? ( $cust_main->ship_last + ? $cust_main->ship_first + : $cust_main->first ) + : '', + $cust_main + ? ( $cust_main->ship_last + ? $cust_main->ship_company + : $cust_main->company ) + : '', + ); + } + my $pkg = $part_pkg{$cust_pkg->pkgpart}->pkg; + #$pkg .= ' - '. $part_pkg{$cust_pkg->pkgpart}->comment; + my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); + my $rowspan = scalar(@cust_svc) || 1; + my $p = popurl(2); + print $n1, <<END; + <TD ROWSPAN=$rowspan><A HREF="${p}view/cust_main.cgi?$custnum#cust_pkg$pkgnum"><FONT SIZE=-1>$pkgnum - $pkg</FONT></A></TD> + <TD ROWSPAN=$rowspan>$setup</TD> +END + + print "<TD ROWSPAN=$rowspan>$last_bill</TD>" + if defined dbdef->table('cust_pkg')->column('last_bill'); + + print <<END; + <TD ROWSPAN=$rowspan>$bill</TD> + <TD ROWSPAN=$rowspan>$susp</TD> + <TD ROWSPAN=$rowspan>$expire</TD> + <TD ROWSPAN=$rowspan>$cancel</TD> +END + if ( $cust_main ) { + print <<END; + <TD ROWSPAN=$rowspan><FONT SIZE=-1><A HREF="${p}view/cust_main.cgi?$custnum">$custnum</A></FONT></TD> + <TD ROWSPAN=$rowspan><FONT SIZE=-1><A HREF="${p}view/cust_main.cgi?$custnum">$last, $first</A></FONT></TD> + <TD ROWSPAN=$rowspan><FONT SIZE=-1><A HREF="${p}view/cust_main.cgi?$custnum">$company</A></FONT></TD> +END + if ( defined dbdef->table('cust_main')->column('ship_last') ) { + print <<END; + <TD ROWSPAN=$rowspan><FONT SIZE=-1><A HREF="${p}view/cust_main.cgi?$custnum">$ship_last, $ship_first</A></FONT></TD> + <TD ROWSPAN=$rowspan><FONT SIZE=-1><A HREF="${p}view/cust_main.cgi?$custnum">$ship_company</A></FONT></TD> +END + } + } else { + my $colspan = defined dbdef->table('cust_main')->column('ship_last') + ? 5 : 3; + print <<END; + <TD ROWSPAN=$rowspan COLSPAN=$colspan>WARNING: couldn't find cust_main.custnum $custnum (cust_pkg.pkgnum $pkgnum)</TD> +END + } + + my $n2 = ''; + foreach my $cust_svc ( @cust_svc ) { + my($label, $value, $svcdb) = $cust_svc->label; + my $svcnum = $cust_svc->svcnum; + my $sview = $p. "view"; + print $n2,qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!, + qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!; + $n2="</TR><TR>"; + } + + $n1 = "</TR><TR>"; + + } + print '</TR>'; + + print "</TABLE>$pager</BODY></HTML>"; + +} +sub pkgnum_sort { + $a->getfield('pkgnum') <=> $b->getfield('pkgnum'); } -my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : ''; - -my $count_query = "SELECT COUNT(*) FROM cust_pkg $cjoin $extra_sql"; - -my $sql_query = { - 'table' => 'cust_pkg', - 'hashref' => {}, - 'select' => join(', ', - 'cust_pkg.*', - 'cust_main.custnum as cust_main_custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => "$extra_sql $orderby", - 'addl_from' => ' LEFT JOIN cust_main USING ( custnum ) ', - #' LEFT JOIN part_pkg USING ( pkgpart ) ' -}; - -my $link = sub { - [ "${p}view/cust_main.cgi?".shift->custnum.'#cust_pkg', 'pkgnum' ]; -}; - -my $clink = sub { - my $cust_pkg = shift; - $cust_pkg->cust_main_custnum - ? [ "${p}view/cust_main.cgi?", 'custnum' ] - : ''; -}; - -#if ( scalar(@cust_pkg) == 1 ) { -# print $cgi->redirect("${p}view/cust_main.cgi?". $cust_pkg[0]->custnum. -# "#cust_pkg". $cust_pkg[0]->pkgnum ); - -# my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); -# my $rowspan = scalar(@cust_svc) || 1; - -# my $n2 = ''; -# foreach my $cust_svc ( @cust_svc ) { -# my($label, $value, $svcdb) = $cust_svc->label; -# my $svcnum = $cust_svc->svcnum; -# my $sview = $p. "view"; -# print $n2,qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!, -# qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!; -# $n2="</TR><TR>"; -# } - -sub time_or_blank { - my $column = shift; - return sub { - my $record = shift; - my $value = $record->get($column); #mmm closures - $value ? time2str('%b %d %Y', $value ) : ''; - }; +sub bill_sort { + $a->getfield('bill') <=> $b->getfield('bill'); } -%><%= include( 'elements/search.html', - 'title' => 'Package Search Results', - 'name' => 'packages', - 'query' => $sql_query, - 'count_query' => $count_query, - 'redirect' => $link, - 'header' => [ '#', - 'Package', - 'Status', - 'Freq.', - 'Setup', - 'Last bill', - 'Next bill', - 'Susp.', - 'Expire', - 'Cancel', - FS::UI::Web::cust_header(), - 'Services', - ], - 'fields' => [ - 'pkgnum', - sub { my $part_pkg = $part_pkg{shift->pkgpart}; - $part_pkg->pkg; # ' - '. $part_pkg->comment; - }, - sub { ucfirst(shift->status); }, - sub { #shift->part_pkg->freq_pretty; - my $part_pkg = $part_pkg{shift->pkgpart}; - $part_pkg->freq_pretty; - }, - - #sub { time2str('%b %d %Y', shift->setup); }, - #sub { time2str('%b %d %Y', shift->last_bill); }, - #sub { time2str('%b %d %Y', shift->bill); }, - #sub { time2str('%b %d %Y', shift->susp); }, - #sub { time2str('%b %d %Y', shift->expire); }, - #sub { time2str('%b %d %Y', shift->get('cancel')); }, - ( map { time_or_blank($_) } - qw( setup last_bill bill susp expire cancel ) ), - - \&FS::UI::Web::cust_fields, - #sub { '<table border=0 cellspacing=0 cellpadding=0 STYLE="border:none">'. - # join('', map { '<tr><td align="right" style="border:none">'. $_->[0]. - # ':</td><td style="border:none">'. $_->[1]. '</td></tr>' } - # shift->labels - # ). - # '</table>'; - # }, - sub { - [ map { - [ - { 'data' => $_->[0]. ':', - 'align'=> 'right', - }, - { 'data' => $_->[1], - 'align'=> 'left', - 'link' => $p. 'view/' . - $_->[2]. '.cgi?'. $_->[3], - }, - ]; - } shift->labels - ]; - }, - ], - 'color' => [ - '', - '', - sub { shift->statuscolor; }, - '', - '', - '', - '', - '', - '', - '', - ( map { '' } FS::UI::Web::cust_header() ), - '', - ], - 'style' => [ '', '', 'b' ], - 'size' => [ '', '', '-1', ], - 'align' => 'rlclrrrrrr', - 'links' => [ - $link, - $link, - '', - '', - '', - '', - '', - '', - '', - '', - ( map { $clink } FS::UI::Web::cust_header() ), - '', - ], - ) %> diff --git a/httemplate/search/cust_pkg_report.cgi b/httemplate/search/cust_pkg_report.cgi index 412c3f79d..6bd918995 100755 --- a/httemplate/search/cust_pkg_report.cgi +++ b/httemplate/search/cust_pkg_report.cgi @@ -1,6 +1,10 @@ <HTML> <HEAD> <TITLE>Packages</TITLE> + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Packages</H1> @@ -8,11 +12,47 @@ <INPUT TYPE="hidden" NAME="magic" VALUE="bill"> Return packages with next bill date:<BR><BR> <TABLE> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> - <%= include( '/elements/tr-select-agent.html', - $cgi->param('agentnum'), - ) - %> + <TR> + <TD ALIGN="right">From: </TD> + <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><I>m/d/y</I></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "beginning_text", + ifFormat: "%m/%d/%Y", + button: "beginning_button", + align: "BR" + }); +</SCRIPT> + </TR> + <TR> + <TD ALIGN="right">To: </TD> + <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><I>m/d/y</I></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "ending_text", + ifFormat: "%m/%d/%Y", + button: "ending_button", + align: "BR" + }); +</SCRIPT> + </TR> +<% my %agent_search = dbdef->table('agent')->column('disabled') + ? ( 'disabled' => '' ) : (); + my @agents = qsearch( 'agent', \%agent_search ); + if ( scalar(@agents) == 1 ) { +%> + <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agents[0]->agentnum %>"> +<% } else { %> + + <TR> + <TD ALIGN="right">Agent: </TD> + <TD><SELECT NAME="agentnum"><OPTION VALUE="">(all) + <% foreach my $agent ( sort { $a->agent cmp $b->agent; } @agents) { %> + <OPTION VALUE="<%= $agent->agentnum %>"><%= $agent->agent %> + <% } %> + </TD> + </TR> +<% } %> </TABLE> <BR><INPUT TYPE="submit" VALUE="Get Report"> diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index d19fb4acd..47d619444 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -91,12 +91,7 @@ foreach my $field ( @{$opt{'fields'}} ) { if ( ref($field) eq 'CODE' ) { - push @line, map { - ref($_) eq 'ARRAY' - ? '(N/A)' #unimplemented - : $_; - } - &{$field}($row); + push @line, &{$field}($row); } else { push @line, $row->$field(); } @@ -157,13 +152,7 @@ # } #} if ( ref($field) eq 'CODE' ) { - foreach my $value ( &{$field}($row) ) { - if ( ref($value) eq 'ARRAY' ) { - $worksheet->write($r, $c++, '(N/A)' ); #unimplemented - } else { - $worksheet->write($r, $c++, $value ); - } - } + $worksheet->write($r, $c++, &{$field}($row) ); } else { $worksheet->write($r, $c++, $row->$field() ); } @@ -183,9 +172,7 @@ } else { # regular HTML if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 && $total == 1 ) { - my $redirect = $opt{'redirect'}; - $redirect = &{$redirect}($rows->[0]) if ref($redirect) eq 'CODE'; - my( $url, $method ) = @$redirect; + my( $url, $method ) = @{$opt{'redirect'}}; redirect( $url. $rows->[0]->$method() ); } else { ( my $xlsname = $opt{'name'} ) =~ s/\W//g; @@ -234,10 +221,14 @@ </TR> <TR> <TD COLSPAN=2> + <%= $pager %> - - <%= include('/elements/table-grid.html') %> - + <STYLE TYPE="text/css"> + .grid table { border: solid; empty-cells: show } + .grid TH { padding-left: 3px; padding-right: 3px; border: 1px solid #dddddd; border-bottom: dashed 1px black; border-right: none } + .grid TD { padding-left: 3px; padding-right: 3px; 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> @@ -262,64 +253,7 @@ my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : []; my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : []; - foreach my $field ( - - map { - if ( ref($_) eq 'ARRAY' ) { - - my $tableref = $_; - - '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0'. - ' STYLE="border:none">'. - - join('', map { - - my $rowref = $_; - - '<tr>'. - - join('', map { - - my $element = $_; - - '<TD STYLE="border:none"'. - ( $element->{'align'} - ? ' ALIGN="'. $element->{'align'}. '"' - : '' - ). '>'. - ( $element->{'link'} - ? '<A HREF="'. $element->{'link'}.'">' - : '' - ). - $element->{'data'}. - ( $element->{'link'} - ? '</A>' - : '' - ). - '</td>'; - - } @$rowref ). - - '</tr>'; - } @$tableref ). - - '</table>'; - - } else { - $_; - } - } - - map { - if ( ref($_) eq 'CODE' ) { - &{$_}($row); - } else { - $row->$_(); - } - } - @{$opt{'fields'}} - - ) { + foreach my $field ( @{$opt{'fields'}} ) { my $align = $aligns ? shift @$aligns : ''; $align = " ALIGN=$align" if $align; @@ -360,7 +294,11 @@ } %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $font %><%= $a %><%= $s %><%= $field %><%= $es %><%= $a ? '</A>' : '' %><%= $font ? '</FONT>' : '' %></TD> + <% if ( ref($field) eq 'CODE' ) { %> + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $font %><%= $a %><%= $s %><%= &{$field}($row) %><%= $es %><%= $a ? '</A>' : '' %><%= $font ? '</FONT>' : '' %></TD> + <% } else { %> + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $font %><%= $a %><%= $s %><%= $row->$field() %><%= $es %><%= $a ? '</A>' : '' %><%= $font ? '</FONT>' : '' %></TD> + <% } %> <% } %> <% } else { %> <% foreach ( @$row ) { %> diff --git a/httemplate/search/report_cust_bill.html b/httemplate/search/report_cust_bill.html index a7be76689..0f6e6814e 100644 --- a/httemplate/search/report_cust_bill.html +++ b/httemplate/search/report_cust_bill.html @@ -1,17 +1,49 @@ <HEAD> <TITLE>Invoice report criteria</TITLE> + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Invoice report criteria</H1> <FORM ACTION="cust_bill.html" METHOD="GET"> <INPUT TYPE="hidden" NAME="magic" VALUE="_date"> <TABLE> - <%= include( '/elements/tr-select-agent.html', - $cgi->param('agentnum'), - 'label' => 'Invoices for agent: ', - ) - %> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <TR> + <TD ALIGN="right">for agent: </TD> + <TD><SELECT NAME="agentnum"> + <OPTION VALUE="">all</OPTION> + <% foreach my $agent ( qsearch('agent', { disabled=>'' } ) ) { %> + <OPTION VALUE="<%= $agent->agentnum %>"<%= $cgi->param('agentnum') == $agent->agentnum ? ' SELECTED' : '' %>><%= $agent->agent %> + <% } %> + </SELECT> + </TD> + </TR> + <TR> + <TD ALIGN="right">From: </TD> + <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "beginning_text", + ifFormat: "%m/%d/%Y", + button: "beginning_button", + align: "BR" + }); +</SCRIPT> + </TR> + <TR> + <TD ALIGN="right">To: </TD> + <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "ending_text", + ifFormat: "%m/%d/%Y", + button: "ending_button", + align: "BR" + }); +</SCRIPT> + </TR> <TR> <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="open" VALUE="1" CHECKED></TD> <TD>Show only open invoices</TD> diff --git a/httemplate/search/report_cust_credit.html b/httemplate/search/report_cust_credit.html index 56bbd0ac0..3a14f44e2 100644 --- a/httemplate/search/report_cust_credit.html +++ b/httemplate/search/report_cust_credit.html @@ -1,6 +1,10 @@ <HTML> <HEAD> <TITLE>Credit report criteria</TITLE> + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Credit report criteria</H1> @@ -23,12 +27,40 @@ </SELECT> </TD> </TR> - <%= include( '/elements/tr-select-agent.html', - $cgi->param('agentnum'), - 'label' => 'for agent: ', - ) - %> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <TR> + <TD ALIGN="right">for agent: </TD> + <TD><SELECT NAME="agentnum"> + <OPTION VALUE="">all</OPTION> + <% foreach my $agent ( qsearch('agent', { disabled=>'' } ) ) { %> + <OPTION VALUE="<%= $agent->agentnum %>"<%= $cgi->param('agentnum') == $agent->agentnum ? ' SELECTED' : '' %>><%= $agent->agent %> + <% } %> + </SELECT> + </TD> + </TR> + <TR> + <TD ALIGN="right">From: </TD> + <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "beginning_text", + ifFormat: "%m/%d/%Y", + button: "beginning_button", + align: "BR" + }); +</SCRIPT> + </TR> + <TR> + <TD ALIGN="right">To: </TD> + <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "ending_text", + ifFormat: "%m/%d/%Y", + button: "ending_button", + align: "BR" + }); +</SCRIPT> + </TR> </TABLE> <BR><INPUT TYPE="submit" VALUE="Get Report"> </FORM> diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 5d8b74e77..8b9e27302 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -1,6 +1,10 @@ <HTML> <HEAD> <TITLE>Payment report criteria</TITLE> + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> </HEAD> <BODY BGCOLOR="#e8e8e8"> <H1>Payment report criteria</H1> @@ -15,22 +19,45 @@ <OPTION VALUE="CARD-VisaMC">credit card (Visa/MasterCard)</OPTION> <OPTION VALUE="CARD-Amex">credit card (American Express)</OPTION> <OPTION VALUE="CARD-Discover">credit card (Discover)</OPTION> - <OPTION VALUE="CARD-Maestro">credit card (Maestro/Switch/Solo)</OPTION> <OPTION VALUE="CHEK">electronic check / ACH</OPTION> - <OPTION VALUE="BILL">check</OPTION> - <OPTION VALUE="PREP">prepaid card</OPTION> - <OPTION VALUE="CASH">cash</OPTION> - <OPTION VALUE="WEST">Western Union</OPTION> - <OPTION VALUE="MCRD">manual credit card</OPTION> + <OPTION VALUE="BILL">check / cash</OPTION> </SELECT> </TD> </TR> - <%= include( '/elements/tr-select-agent.html', - $cgi->param('agentnum'), - 'label' => 'for agent: ', - ) - %> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <TR> + <TD ALIGN="right">for agent: </TD> + <TD><SELECT NAME="agentnum"> + <OPTION VALUE="">all</OPTION> + <% foreach my $agent ( qsearch('agent', { disabled=>'' } ) ) { %> + <OPTION VALUE="<%= $agent->agentnum %>"<%= $cgi->param('agentnum') == $agent->agentnum ? ' SELECTED' : '' %>><%= $agent->agent %> + <% } %> + </SELECT> + </TD> + </TR> + <TR> + <TD ALIGN="right">From: </TD> + <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "beginning_text", + ifFormat: "%m/%d/%Y", + button: "beginning_button", + align: "BR" + }); +</SCRIPT> + </TR> + <TR> + <TD ALIGN="right">To: </TD> + <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "ending_text", + ifFormat: "%m/%d/%Y", + button: "ending_button", + align: "BR" + }); +</SCRIPT> + </TR> </TABLE> <BR><INPUT TYPE="submit" VALUE="Get Report"> </FORM> diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index d675346f0..82ce5d777 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -118,18 +118,14 @@ END my $conf = new FS::Conf; my $money_char = $conf->config('money_char') || '$'; - my $align = join('', map { /#/ ? 'r' : 'l' } FS::UI::Web::cust_header() ). - 'crrrrr'; - - my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; - %><%= include( 'elements/search.html', 'title' => 'Accounts Receivable Aging Summary', 'name' => 'customers', 'query' => $sql_query, 'count_query' => $count_sql, 'header' => [ - FS::UI::Web::cust_header(), + '#', + 'Customer', 'Status', # (me)', #'Status', # (cust_main)', '0-30', @@ -139,12 +135,8 @@ END 'Total', ], 'footer' => [ + '', 'Total', - ( map '', - ( 1 .. - scalar(FS::UI::Web::cust_header()-1) - ) - ), '', #'', sprintf( $money_char.'%.2f', @@ -159,7 +151,8 @@ END $row->{'owed_total'} ), ], 'fields' => [ - \&FS::UI::Web::cust_fields, + 'custnum', + 'name', sub { my $row = shift; my $status = 'Cancelled'; @@ -187,7 +180,8 @@ END shift->get('owed_total') ) }, ], 'links' => [ - ( map $clink, FS::UI::Web::cust_header() ), + [ "${p}view/cust_main.cgi?", 'custnum' ], + [ "${p}view/cust_main.cgi?", 'custnum' ], '', #'', '', @@ -197,15 +191,14 @@ END '', ], #'align' => 'rlccrrrrr', - 'align' => $align, + 'align' => 'rlcrrrrr', #'size' => [ '', '', '-1', '-1', '', '', '', '', '', ], #'style' => [ '', '', 'b', 'b', '', '', '', '', 'b', ], - 'size' => [ ( map '', FS::UI::Web::cust_header() ), - '-1', '', '', '', '', '', ], - 'style' => [ ( map '', FS::UI::Web::cust_header() ), - 'b', '', '', '', '', 'b', ], + 'size' => [ '', '', '-1', '', '', '', '', '', ], + 'style' => [ '', '', 'b', '', '', '', '', 'b', ], 'color' => [ - ( map '', FS::UI::Web::cust_header() ), + '', + '', sub { my $row = shift; my $status = 'Cancelled'; diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 9062f0626..587665740 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -1,11 +1,15 @@ +<!-- mason kludge --> <% -my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; - my $user = getotaker; -my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; +my $pbeginning = $1; +my $beginning = $1 ? str2time($1) : 0; + +$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/; +my $pending = $1; +my $ending = ( $1 ? str2time($1) : 4294880896 ) + 86399; my $from_join_cust = " FROM cust_bill_pkg @@ -20,19 +24,11 @@ my $where = " WHERE _date >= $beginning AND _date <= $ending AND ( county = ? OR ? = '' ) AND ( state = ? OR ? = '' ) - AND country = ? + AND ( country = ? ) AND payby != 'COMP' "; my @base_param = qw( county county state state country ); -my $agentname = ''; -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - my $agent = qsearchs('agent', { 'agentnum' => $1 } ); - die "agent not found" unless $agent; - $agentname = $agent->agent; - $where .= ' AND agentnum = '. $agent->agentnum; -} - my $gotcust = " WHERE 0 < ( SELECT COUNT(*) FROM cust_main WHERE ( cust_main.county = cust_main_county.county @@ -47,72 +43,52 @@ my $gotcust = " "; my $monthly_exempt_warning = 0; -my $taxclass_flag = 0; -my($total, $tot_taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); -my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0 ); +my($total, $exempt, $taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); my $out = 'Out of taxable region(s)'; -my %regions = (); +my %regions; foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { #warn $r->county. ' '. $r->state. ' '. $r->country. "\n"; my $label = getlabel($r); $regions{$label}->{'label'} = $label; - $regions{$label}->{'url_param'} = join(';', map "$_=".$r->$_(), qw( county state country ) ); my $fromwhere = $from_join_cust. $join_pkg. $where; - my @param = @base_param; + my @param = @base_param; if ( $r->taxclass ) { - $fromwhere .= " AND taxclass = ? "; + $fromwhere .= " AND ( taxclass = ? ) "; push @param, 'taxclass'; - $regions{$label}->{'url_param'} .= ';taxclass='. $r->taxclass - if $cgi->param('show_taxclasses'); - $taxclass_flag = 1; } -# my $label = getlabel($r); -# $regions{$label}->{'label'} = $label; - my $nottax = 'pkgnum != 0'; - ## calculate total for this region - - my $t = scalar_sql($r, \@param, + my $a = scalar_sql($r, \@param, "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere AND $nottax" ); - $total += $t; - $regions{$label}->{'total'} += $t; - - ## calculate package-exemption for this region + $total += $a; + $regions{$label}->{'total'} += $a; foreach my $e ( grep { $r->get($_.'tax') =~ /^Y/i } qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { my $x = scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax" ); - $exempt_pkg += $x; - $regions{$label}->{'exempt_pkg'} += $x; + $exempt += $x; + $regions{$label}->{'exempt'} += $x; } - ## calculate customer-exemption for this region - - my($taxable, $x_cust) = (0, 0); + my($t, $x) = (0, 0); foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { - $taxable += scalar_sql($r, \@param, + $t += scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" ); - $x_cust += scalar_sql($r, \@param, + $x += scalar_sql($r, \@param, "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" ); } - $exempt_cust += $x_cust; - $regions{$label}->{'exempt_cust'} += $x_cust; - - ## calculate monthly exemption (texas tax) for this region - my($sday,$smon,$syear) = (localtime($beginning) )[ 3, 4, 5 ]; $monthly_exempt_warning=1 if $sday != 1 && $beginning; $smon++; $syear+=1900; @@ -121,24 +97,25 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { my($eday,$emon,$eyear) = (localtime($eending) )[ 3, 4, 5 ]; $emon++; $eyear+=1900; - my $x_monthly = scalar_sql($r, [ 'taxnum' ], + my $monthly_exemption = scalar_sql($r, [ 'taxnum' ], "SELECT SUM(amount) FROM cust_tax_exempt where taxnum = ? ". " AND ( year > $syear OR ( year = $syear and month >= $smon ) )". " AND ( year < $eyear OR ( year = $eyear and month <= $emon ) )" ); - if ( $x_monthly ) { - warn $r->taxnum(). ": $x_monthly\n"; - $taxable -= $x_monthly; + #warn $r->taxnum(). ": $monthly_exemption\n"; + if ( $monthly_exemption ) { + $t -= $monthly_exemption; + $x += $monthly_exemption; } - $exempt_monthly += $x_monthly; - $regions{$label}->{'exempt_monthly'} += $x_monthly; + $taxable += $t; + $regions{$label}->{'taxable'} += $t; - $tot_taxable += $taxable; - $regions{$label}->{'taxable'} += $taxable; + $exempt += $x; + $regions{$label}->{'exempt'} += $x; - $owed += $taxable * ($r->tax/100); - $regions{$label}->{'owed'} += $taxable * ($r->tax/100); + $owed += $t * ($r->tax/100); + $regions{$label}->{'owed'} += $t * ($r->tax/100); if ( defined($regions{$label}->{'rate'}) && $regions{$label}->{'rate'} != $r->tax.'%' ) { @@ -151,7 +128,7 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { my $taxwhere = "$from_join_cust $where"; my @taxparam = @base_param; -my %base_regions = (); + #foreach my $label ( keys %regions ) { foreach my $r ( qsearch( 'cust_main_county', @@ -180,58 +157,30 @@ foreach my $r ( $tax += $x; $regions{$label}->{'tax'} += $x; - if ( $cgi->param('show_taxclasses') ) { - my $base_label = getlabel($r, 'no_taxclass'=>1 ); - $base_regions{$base_label}->{'label'} = $base_label; - $base_regions{$base_label}->{'url_param'} = - join(';', map "$_=".$r->$_(), qw( county state country ) ); - $base_regions{$base_label}->{'tax'} += $x; - } - } #ordering -my @regions = - map $regions{$_}, - sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } - keys %regions; - -my @base_regions = - map $base_regions{$_}, - sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } - keys %base_regions; +my @regions = map $regions{$_}, + sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } + keys %regions; push @regions, { - 'label' => 'Total', - 'url_param' => '', - 'total' => $total, - 'exempt_cust' => $exempt_cust, - 'exempt_pkg' => $exempt_pkg, - 'exempt_monthly' => $exempt_monthly, - 'taxable' => $tot_taxable, - 'rate' => '', - 'owed' => $owed, - 'tax' => $tax, + 'label' => 'Total', + 'total' => $total, + 'exempt' => $exempt, + 'taxable' => $taxable, + 'rate' => '', + 'owed' => $owed, + 'tax' => $tax, }; #-- sub getlabel { my $r = shift; - my %opt = @_; my $label; - if ( - $r->tax == 0 - && ! scalar( qsearch('cust_main_county', { 'state' => $r->state, - 'county' => $r->county, - 'country' => $r->country, - 'tax' => { op=>'>', value=>0 }, - } - ) - ) - - ) { + if ( $r->tax == 0 ) { #kludge to avoid "will not stay shared" warning my $out = 'Out of taxable region(s)'; $label = $out; @@ -243,10 +192,6 @@ sub getlabel { $label = $r->country; $label = $r->state.", $label" if $r->state; $label = $r->county." county, $label" if $r->county; - $label = "$label (". $r->taxclass. ")" - if $r->taxclass - && $cgi->param('show_taxclasses') - && ! $opt{'no_taxclasses'}; #$label = $r->taxname. " ($label)" if $r->taxname; } return $label; @@ -265,159 +210,35 @@ sub scalar_sql { %> -<% - -my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; - -%> - - -<%= header( "$agentname Sales Tax Report - ". - time2str('%h %o %Y through ', $beginning ). - ( $ending == 4294967295 - ? 'now' - : time2str('%h %o %Y', $ending ) - ), - menubar( 'Main Menu'=>$p, ) - ) -%> - -<%= include('/elements/table-grid.html') %> - +<%= header( "Sales Tax Report - $pbeginning through ".($pending||'now'), + menubar( 'Main Menu'=>$p, ) ) %> +<%= table() %> <TR> - <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2></TH> - <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=9>Sales</TH> - <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2></TH> - <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Rate</TH> - <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2></TH> - <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Tax owed</TH> - <% unless ( $cgi->param('show_taxclasses') ) { %> - <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Tax invoiced</TH> - <% } %> + <TH ROWSPAN=2></TH> + <TH COLSPAN=3>Sales</TH> + <TH ROWSPAN=2>Rate</TH> + <TH ROWSPAN=2>Tax owed</TH> + <TH ROWSPAN=2>Tax invoiced</TH> </TR> <TR> - <TH CLASS="grid" BGCOLOR="#cccccc">Total</TH> - <TH CLASS="grid" BGCOLOR="#cccccc"></TH> - <TH CLASS="grid" BGCOLOR="#cccccc">Non-taxable<BR><FONT SIZE=-1>(tax-exempt customer)</FONT></TH> - <TH CLASS="grid" BGCOLOR="#cccccc"></TH> - <TH CLASS="grid" BGCOLOR="#cccccc">Non-taxable<BR><FONT SIZE=-1>(tax-exempt package)</FONT></TH> - <TH CLASS="grid" BGCOLOR="#cccccc"></TH> - <TH CLASS="grid" BGCOLOR="#cccccc">Non-taxable<BR><FONT SIZE=-1>(monthly exemption)</FONT></TH> - <TH CLASS="grid" BGCOLOR="#cccccc"></TH> - <TH CLASS="grid" BGCOLOR="#cccccc">Taxable</TH> + <TH>Total</TH> + <TH>Non-taxable</TH> + <TH>Taxable</TH> </TR> - -<% my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor; -%> - - <% foreach my $region ( @regions ) { - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - - my $link = $baselink; - if ( $region->{'label'} ne 'Total' ) { - if ( $region->{'label'} eq $out ) { - $link .= ';out=1'; - } else { - $link .= ';'. $region->{'url_param'}; - } - } - %> - + <% foreach my $region ( @regions ) { %> <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $region->{'label'} %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $link %>;nottax=1"><%= $money_char %><%= sprintf('%.2f', $region->{'total'} ) %></A> - </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $link %>;nottax=1;cust_tax=Y"><%= $money_char %><%= sprintf('%.2f', $region->{'exempt_cust'} ) %></A> - </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $link %>;nottax=1;pkg_tax=Y"><%= $money_char %><%= sprintf('%.2f', $region->{'exempt_pkg'} ) %></A> - </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <%= $money_char %><%= sprintf('%.2f', $region->{'exempt_monthly'} ) %></A> - </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="+1"><B> = </B></FONT></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <%= $money_char %><%= sprintf('%.2f', $region->{'taxable'} ) %></A> - </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $region->{'label'} eq 'Total' ? '' : '<FONT FACE="sans-serif" SIZE="+1"><B> X </B></FONT>' %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"><%= $region->{'rate'} %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $region->{'label'} eq 'Total' ? '' : '<FONT FACE="sans-serif" SIZE="+1"><B> = </B></FONT>' %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <%= $money_char %><%= sprintf('%.2f', $region->{'owed'} ) %> - </TD> - <% unless ( $cgi->param('show_taxclasses') ) { %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $link %>;istax=1"><%= $money_char %><%= sprintf('%.2f', $region->{'tax'} ) %></A> - </TD> - <% } %> + <TD><%= $region->{'label'} %></TD> + <TD ALIGN="right">$<%= sprintf('%.2f', $region->{'total'} ) %></TD> + <TD ALIGN="right">$<%= sprintf('%.2f', $region->{'exempt'} ) %></TD> + <TD ALIGN="right">$<%= sprintf('%.2f', $region->{'taxable'} ) %></TD> + <TD ALIGN="right"><%= $region->{'rate'} %></TD> + <TD ALIGN="right">$<%= sprintf('%.2f', $region->{'owed'} ) %></TD> + <TD ALIGN="right">$<%= sprintf('%.2f', $region->{'tax'} ) %></TD> </TR> - <% } %> </TABLE> - -<% if ( $cgi->param('show_taxclasses') ) { %> - - <BR> - <%= include('/elements/table-grid.html') %> - <TR> - <TH CLASS="grid" BGCOLOR="#cccccc"></TH> - <TH CLASS="grid" BGCOLOR="#cccccc">Tax invoiced</TH> - </TR> - - <% #some false laziness w/above - foreach my $region ( @base_regions ) { - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - - my $link = $baselink; - #if ( $region->{'label'} ne 'Total' ) { - if ( $region->{'label'} eq $out ) { - $link .= ';out=1'; - } else { - $link .= ';'. $region->{'url_param'}; - } - #} - %> - - <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $region->{'label'} %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $link %>;istax=1"><%= $money_char %><%= sprintf('%.2f', $region->{'tax'} ) %></A> - </TD> - </TR> - - <% } %> - - <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">Total</TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $baselink %>;istax=1"><%= $money_char %><%= sprintf('%.2f', $tax ) %></A> - </TD> - </TR> - - </TABLE> - -<% } %> - - <% if ( $monthly_exempt_warning ) { %> <BR> Partial-month tax reports (except for current month) may not be correct due diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html index eeaccc1ab..85af212d7 100755 --- a/httemplate/search/report_tax.html +++ b/httemplate/search/report_tax.html @@ -1,17 +1,39 @@ <HTML> <HEAD> <TITLE>Tax Report Criteria</TITLE> - </HEAD> + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> + <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> + <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="GET"> + Return <B>tax report</B> for period: <TABLE> - <%= include( '/elements/tr-select-agent.html' ) %> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> - <TR> - <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="show_taxclasses" VALUE="1"></TD> - <TD>Show tax classes</TD> - </TR> + <TR> + <TD ALIGN="right">From: </TD> + <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "beginning_text", + ifFormat: "%m/%d/%Y", + button: "beginning_button", + align: "BR" + }); +</SCRIPT> + </TR> + <TR> + <TD ALIGN="right">To: </TD> + <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=11 MAXLENGTH=10> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y</i></TD> +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "ending_text", + ifFormat: "%m/%d/%Y", + button: "ending_button", + align: "BR" + }); +</SCRIPT> + </TR> </TABLE> <BR><INPUT TYPE="submit" VALUE="Get Report"> diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index b14591958..1e4a03d84 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,37 +1,250 @@ <% -my $orderby = 'ORDER BY svcnum'; +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($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors -my $cjoin = ''; -my @extra_sql = (); +my $unlinked = ''; if ( $query =~ /^UN_(.*)$/ ) { $query = $1; - $cjoin = 'LEFT JOIN cust_svc USING ( svcnum )'; - push @extra_sql, 'pkgnum IS NULL'; + 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 ) + ) + "; + } } +my $tblname = driver_name eq 'mysql' ? 'svc_acct.' : ''; +my(@svc_acct, $sortby); if ( $query eq 'svcnum' ) { - #$orderby = "ORDER BY svcnum"; + $sortby=\*svcnum_sort; + $orderby = "ORDER BY ${tblname}svcnum"; } elsif ( $query eq 'username' ) { - $orderby = "ORDER BY LOWER(username)"; + $sortby=\*username_sort; + $orderby = "ORDER BY ${tblname}username"; } elsif ( $query eq 'uid' ) { - $orderby = "ORDER BY uid"; - push @extra_sql, "uid IS NOT NULL"; + $sortby=\*uid_sort; + $orderby = ( $unlinked ? ' AND' : ' WHERE' ). + " ${tblname}uid IS NOT NULL ORDER BY ${tblname}uid"; } elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) { - push @extra_sql, "popnum = $1"; - $orderby = "ORDER BY LOWER(username)"; + $unlinked .= ( $unlinked ? 'AND' : 'WHERE' ). + " popnum = $1"; + $sortby=\*username_sort; + $orderby = "ORDER BY ${tblname}username"; } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { - $cjoin ||= 'LEFT JOIN cust_svc USING ( svcnum )'; - push @extra_sql, "svcpart = $1"; - $orderby = "ORDER BY uid"; - #$orderby = "ORDER BY svcnum"; + $unlinked .= ( $unlinked ? ' AND' : ' WHERE' ). + " $1 = ( SELECT svcpart FROM cust_svc ". + " WHERE cust_svc.svcnum = svc_acct.svcnum ) "; + $sortby=\*uid_sort; + #$sortby=\*svcnum_sort; } else { - $orderby = "ORDER BY uid"; + $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"); +} 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 @username_sql; + 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 { + + my @svc_acct; my %username_type; foreach ( $cgi->param('username_type') ) { @@ -41,13 +254,17 @@ if ( $query eq 'svcnum' ) { $cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text my $username = $1; - push @username_sql, "username ILIKE '$username'" - if $username_type{'Exact'} - || $username_type{'Fuzzy'}; + 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{'Substring'} - || $username_type{'All'}; + if ( $username_type{'Substring'} || $username_type{'All'} ) { + push @svc_acct, qsearch( 'svc_acct', + { 'username' => { 'op' => 'ILIKE', + 'value' => "%$username%" } } ); + } if ( $username_type{'Fuzzy'} || $username_type{'All'} ) { &FS::svc_acct::check_and_rebuild_fuzzyfiles; @@ -63,78 +280,15 @@ if ( $query eq 'svcnum' ) { #if ($username_type{'Sound-alike'}) { #} - push @username_sql, "username = '$_'" - foreach (keys %username); + foreach ( keys %username ) { + push @svc_acct, qsearch('svc_acct',{'username'=>$_}); + } } - push @extra_sql, '( '. join( ' OR ', @username_sql). ' )'; + #[ qsearch('svc_acct',{'username'=>$username}) ]; + \@svc_acct; } -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() - ), - ], - ) %> diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index f261ea9f3..06041e03b 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -37,6 +37,7 @@ if ( keys %svc_domain ) { join(' AND ', map "$_ = ". dbh->quote($svc_domain{$_}), keys %svc_domain ); + } my $sql_query = { @@ -44,13 +45,12 @@ my $sql_query = { 'hashref' => \%svc_domain, 'select' => join(', ', 'svc_domain.*', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), + map "cust_main.$_", qw(custnum last first company) ), '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,17 +69,15 @@ my $link_cust = sub { 'redirect' => $link, 'header' => [ '#', 'Domain', - FS::UI::Web::cust_header(), + 'Customer', ], 'fields' => [ 'svcnum', 'domain', - \&FS::UI::Web::cust_fields, + \&FS::svc_Common::cust_name, ], 'links' => [ $link, $link, - ( map { $link_cust } - FS::UI::Web::cust_header() - ), + $link_cust, ], ) %> diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index a204e345f..1c1c6e4dd 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -4,43 +4,25 @@ my $conf = new FS::Conf; my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors - - my $orderby; - -my $cjoin = ''; -my @extra_sql = (); -if ( $query =~ /^UN_(.*)$/ ) { - $query = $1; - $cjoin = 'LEFT JOIN cust_svc USING ( svcnum )'; - push @extra_sql, 'pkgnum IS NULL'; -} - if ( $query eq 'svcnum' ) { $orderby = 'ORDER BY svcnum'; } else { eidiot('unimplemented'); } -my $extra_sql = - scalar(@extra_sql) - ? ' WHERE '. join(' AND ', @extra_sql ) - : ''; - -my $count_query = "SELECT COUNT(*) FROM svc_forward $cjoin $extra_sql"; +my $count_query = 'SELECT COUNT(*) FROM svc_forward'; my $sql_query = { 'table' => 'svc_forward', 'hashref' => {}, 'select' => join(', ', 'svc_forward.*', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), + map "cust_main.$_", qw(custnum last first company) ), - '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 ) ', + 'extra_sql' => $orderby, + 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. + 'LEFT JOIN cust_pkg USING ( pkgnum )'. + 'LEFT JOIN cust_main USING ( custnum )', }; # <TH>Service #<BR><FONT SIZE=-1>(click to view forward)</FONT></TH> @@ -93,7 +75,7 @@ my $link_cust = sub { $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, @@ -102,19 +84,17 @@ my $link_cust = sub { 'header' => [ '#', 'Mail to', 'Forwards to', - FS::UI::Web::cust_header(), + 'Customer', ], 'fields' => [ 'svcnum', $format_src, $format_dst, - \&FS::UI::Web::cust_fields, + \&FS::svc_Common::cust_name, ], 'links' => [ $link, $link_src, $link_dst, - ( map { $link_cust } - FS::UI::Web::cust_header() - ), + $link_cust, ], - ) + ) %> diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi index ae51c61fc..de1f5dd78 100755 --- a/httemplate/search/svc_www.cgi +++ b/httemplate/search/svc_www.cgi @@ -17,8 +17,7 @@ my $sql_query = { 'hashref' => {}, 'select' => join(', ', 'svc_www.*', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), + map "cust_main.$_", qw(custnum last first company) ), 'extra_sql' => $orderby, 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. @@ -45,25 +44,17 @@ my $link_cust = sub { 'header' => [ '#', 'Zone', 'User', - FS::UI::Web::cust_header(), + 'Customer', ], 'fields' => [ 'svcnum', sub { $_[0]->domain_record->zone }, - sub { - my $svc_www = shift; - my $svc_acct = $svc_www->svc_acct; - $svc_acct - ? $svc_acct->email - : ''; - }, - \&FS::UI::Web::cust_fields, + sub { $_[0]->svc_acct->email }, + \&FS::svc_Common::cust_name, ], 'links' => [ $link, '', $ulink, - ( map { $link_cust } - FS::UI::Web::cust_header() - ), + $link_cust, ], ) %> diff --git a/httemplate/view/cust_bill-logo.cgi b/httemplate/view/cust_bill-logo.cgi index 235485f6b..50812ea10 100755 --- a/httemplate/view/cust_bill-logo.cgi +++ b/httemplate/view/cust_bill-logo.cgi @@ -1,15 +1,12 @@ <% -my $conf = new FS::Conf; - my($query) = $cgi->keywords; $query =~ /^([^\.\/]*)$/; my $templatename = $1; -if ( $templatename && $conf->exists("logo_$templatename.png") ) { - $templatename = "_$templatename"; -} else { - $templatename = ''; -} +$templatename = "_$templatename" if $templatename; + +my $conf = new FS::Conf; +http_header('Content-Type' => 'image/png' ); http_header('Content-Type' => 'image/png' ); %><%= $conf->config_binary("logo$templatename.png") %> diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 56c0c1736..d149cf172 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -8,12 +8,6 @@ my $invnum = $3; my $conf = new FS::Conf; -my @payby = grep /\w/, $conf->config('payby'); -#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) -@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) - unless @payby; -my %payby = map { $_=>1 } @payby; - my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); die "Invoice #$invnum not found!" unless $cust_bill; my $custnum = $cust_bill->getfield('custnum'); @@ -28,45 +22,8 @@ my $link = $templatename ? "$templatename-$invnum" : $invnum; "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", )) %> -<% if ( $cust_bill->owed > 0 - && ( $payby{'BILL'} || $payby{'CASH'} || $payby{'WEST'} || $payby{'MCRD'} ) - ) - { - my $s = 0; -%> - - Post - - <% if ( $payby{'BILL'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=BILL;invnum=<%= $invnum %>">check</A> - - <% } %> - - <% if ( $payby{'CASH'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=CASH;invnum=<%= $invnum %>">cash</A> - - <% } %> - - <% if ( $payby{'WEST'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;invnum=<%= $invnum %>">Western Union</A> - - <% } %> - - <% if ( $payby{'MCRD'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<%= $invnum %>">manual credit card</A> - - <% } %> - - payment against this invoice<BR> - +<% if ( $cust_bill->owed > 0 ) { %> + <A HREF="<%= $p %>edit/cust_pay.cgi?<%= $invnum %>">Enter payments (check/cash) against this invoice</A> | <% } %> <A HREF="<%= $p %>misc/print-invoice.cgi?<%= $link %>">Re-print this invoice</A> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 59c1a4b73..8794f3074 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -16,6 +16,12 @@ foreach my $part_svc ( qsearch('part_svc',{}) ) { 'Main Menu' => $p, )) %> +<STYLE TYPE="text/css"> +.package TH { font-size: medium } +.package TR { font-size: smaller } +.package .provision { font-weight: bold } +</STYLE> + <% die "No customer specified (bad URL)!" unless $cgi->keywords; @@ -29,43 +35,18 @@ print qq!<A HREF="${p}edit/cust_main.cgi?$custnum">Edit this customer</A>!; %> -<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT> -<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT> - -<SCRIPT TYPE="text/javascript"> +<SCRIPT> function areyousure(href, message) { - if (confirm(message) == true) - window.location.href = href; + if (confirm(message) == true) + window.location.href = href; } </SCRIPT> -<SCRIPT TYPE="text/javascript"> - <% -my $ban = ''; -if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) { - $ban = '<BR><P ALIGN="center">'. - '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\\\'s '; - if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { - $ban .= 'credit card'; - } elsif ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) { - $ban .= 'ACH account'; - } -} -%> - -var confirm_cancel = '<FORM METHOD="POST" ACTION="<%= $p %>misc/cust_main-cancel.cgi"> <INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>"> <BR><P ALIGN="center"><B>Permanently delete all services and cancel this customer?</B> <%= $ban%><BR><P ALIGN="CENTER"> <INPUT TYPE="submit" VALUE="Cancel customer"> <INPUT TYPE="BUTTON" VALUE="Don\'t cancel" onClick="cClick()"> </FORM> '; -</SCRIPT> - -<% if ( $cust_main->ncancelled_pkgs ) { %> - - | <A HREF="javascript:void(0);" onClick="overlib(confirm_cancel, CAPTION, 'Confirm cancellation', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH, 576, HEIGHT, 128, TEXTSIZE, 3, BGCOLOR, '#ff0000', CGCOLOR, '#ff0000' ); return false; ">Cancel this customer</A> - -<% } %> - -<% +print qq! | <A HREF="javascript:areyousure('${p}misc/cust_main-cancel.cgi?$custnum', 'Perminantly delete all services and cancel this customer?')">!. + 'Cancel this customer</A>' + if $cust_main->ncancelled_pkgs; print qq! | <A HREF="${p}misc/delete-customer.cgi?$custnum">!. 'Delete this customer</A>' diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 5786a0711..561fff992 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -6,7 +6,28 @@ Billing information (<A HREF="<%= $p %>misc/bill.cgi?<%= $cust_main->custnum %>">Bill now</A>) <%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %> - +<TR> + <TD ALIGN="right">Tax exempt</TD> + <TD BGCOLOR="#ffffff"><%= $cust_main->tax ? 'yes' : 'no' %></TD> +</TR> +<TR> + <TD ALIGN="right">Postal invoices</TD> + <TD BGCOLOR="#ffffff"> + <%= ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %> + </TD> +</TR> +<TR> + <TD ALIGN="right">FAX invoices</TD> + <TD BGCOLOR="#ffffff"> + <%= ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %> + </TD> +</TR> +<TR> + <TD ALIGN="right">Email invoices</TD> + <TD BGCOLOR="#ffffff"> + <%= join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %> + </TD> +</TR> <TR> <TD ALIGN="right">Billing type</TD> <TD BGCOLOR="#ffffff"> @@ -20,37 +41,10 @@ Billing information <TD ALIGN="right">Card number</TD> <TD BGCOLOR="#ffffff"><%= $cust_main->payinfo_masked %></TD> </TR> - -<% -#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html -my( $mon, $year ); -my $date = $cust_main->paydate || '12-2037'; -if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); -} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); -} else { - warn "unrecognized expiration date format: $date"; - ( $mon, $year ) = ( '', '' ); -} -%> <TR> <TD ALIGN="right">Expiration</TD> - <TD BGCOLOR="#ffffff"><%= "$mon/$year" %></TD> -</TR> - -<% if ( $cust_main->paystart_month ) { %> - <TR> - <TD ALIGN="right">Start date</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->paystart_month. '/'. $cust_main->paystart_year %> - </TR> -<% } elsif ( $cust_main->payissue ) { %> - <TR> - <TD ALIGN="right">Issue #</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->payissue %> - </TR> -<% } %> - + <TD BGCOLOR="#ffffff"><%= $cust_main->paydate %></TD> +</TR> <TR> <TD ALIGN="right">Name on card</TD> <TD BGCOLOR="#ffffff"><%= $cust_main->payname %></TD> @@ -69,7 +63,7 @@ if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format </TR> <TR> <TD ALIGN="right">Account number</TD> - <TD BGCOLOR="#ffffff"><%= 'x'x(length($account)-2). substr($account,(length($account)-2)) %></TD> + <TD BGCOLOR="#ffffff"><%= $account %></TD> </TR> <TR> <TD ALIGN="right">Bank name</TD> @@ -103,6 +97,10 @@ if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format <% } %> <TR> + <TD ALIGN="right">Expiration</TD> + <TD BGCOLOR="#ffffff"><%= $cust_main->paydate %></TD> +</TR> +<TR> <TD ALIGN="right">Attention</TD> <TD BGCOLOR="#ffffff"><%= $cust_main->payname %></TD> </TR> @@ -116,49 +114,12 @@ if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format <TD ALIGN="right">Authorized by</TD> <TD BGCOLOR="#ffffff"><%= $cust_main->payinfo %></TD> </TR> - -<% -#false laziness w/above etc. -my( $mon, $year ); -my $date = $cust_main->paydate || '12-2037'; -if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); -} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); -} else { - warn "unrecognized expiration date format: $date"; - ( $mon, $year ) = ( '', '' ); -} -%> <TR> <TD ALIGN="right">Expiration</TD> - <TD BGCOLOR="#ffffff"><%= "$mon/$year" %></TD> + <TD BGCOLOR="#ffffff"><%= $cust_main->paydate %></TD> </TR> <% } %> -<TR> - <TD ALIGN="right">Tax exempt</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->tax ? 'yes' : 'no' %></TD> -</TR> -<TR> - <TD ALIGN="right">Postal invoices</TD> - <TD BGCOLOR="#ffffff"> - <%= ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %> - </TD> -</TR> -<TR> - <TD ALIGN="right">FAX invoices</TD> - <TD BGCOLOR="#ffffff"> - <%= ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %> - </TD> -</TR> -<TR> - <TD ALIGN="right">Email invoices</TD> - <TD BGCOLOR="#ffffff"> - <%= join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %> - </TD> -</TR> - </TABLE></TD></TR></TABLE> diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html index ece1b62bb..068a8276f 100755 --- a/httemplate/view/cust_main/packages.html +++ b/httemplate/view/cust_main/packages.html @@ -5,10 +5,6 @@ my $packages = get_packages($cust_main, $conf); %> -<STYLE TYPE="text/css"> -.package .provision { font-weight: bold } -</STYLE> - <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A> <%= include('order_pkg.html', $cust_main ) %> @@ -75,10 +71,12 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { ( <%=pkg_dates_link($pkg)%> | <%=pkg_customize_link($pkg,$cust_main->custnum)%> ) <% } %> </TD> - <TD ROWSPAN=<%=$rowspan%>> - <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> - <% + #foreach (qw(setup last_bill next_bill susp expire cancel)) { + # print qq! <TD ROWSPAN=$rowspan>! . pkg_datestr($pkg,$_,$conf) . qq!</TD>\n!; + #} + print "<TD ROWSPAN=$rowspan>". &itable(''); + sub myfreq { my $part_pkg = shift; my $freq = $part_pkg->freq_pretty; @@ -86,190 +84,92 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { $freq; } - #this should use cust_pkg->status and cust_pkg->statuscolor eventually - - my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4; - my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%'; + if ( $pkg->{cancel} ) { #status: cancelled + + print '<TR><TD><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD>'. + '<TD>'. pkg_datestr($pkg,'cancel',$conf). '</TD></TR>'; + unless ( $pkg->{setup} ) { + print '<TR><TD COLSPAN=2>Never billed</TD></TR>'; + } else { + print "<TR><TD>Setup </TD><TD>". + pkg_datestr($pkg, 'setup',$conf). '</TD></TR>'; + print "<TR><TD>Last bill </TD><TD>". + pkg_datestr($pkg, 'last_bill',$conf). '</TD></TR>' + if $pkg->{'last_bill'}; + print "<TR><TD>Suspended </TD><TD>". + pkg_datestr($pkg, 'susp',$conf). '</TD></TR>' + if $pkg->{'susp'}; + } - #false laziness w/edit/REAL_cust_pkg.cgi - my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until ); - unless ( $pkg->{'part_pkg'}->is_prepaid ) { - $billed_or_prepaid = 'billed'; - $last_bill_or_renewed = 'Last bill'; - $next_bill_or_prepaid_until = 'Next bill'; } else { - $billed_or_prepaid = 'prepaid'; - $last_bill_or_renewed = 'Renewed'; - $next_bill_or_prepaid_until = 'Prepaid until'; - } - -%> - -<% if ( $pkg->{cancel} ) { %> <!-- #status: cancelled --> - - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD> - <%= pkg_datestr($pkg,'cancel',$conf) %> - </TR> - - <% unless ( $pkg->{setup} ) { %> - - <TR> - <TD COLSPAN=<%=$colspan%>>Never billed</TD> - </TR> - - <% } else { %> - - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Setup </TD> - <%= pkg_datestr($pkg, 'setup',$conf) %> - </TR> - - <% if ( $pkg->{'last_bill'} ) { %> - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><%= $last_bill_or_renewed %> </TD> - <%= pkg_datestr($pkg, 'last_bill',$conf) %> - </TR> - <% } %> - - <% if ( $pkg->{'susp'} ) { %> - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Suspended </TD> - <%= pkg_datestr($pkg, 'susp',$conf) %> - </TR> - <% } %> - - <% } %> - -<% } else { %> - - <% if ( $pkg->{susp} ) { %> <!-- #status: suspended --> - - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><FONT COLOR="#FF9900"><B>Suspended</B> </FONT></TD> - <%= pkg_datestr($pkg,'susp',$conf) %> - </TR> - - <% unless ( $pkg->{setup} ) { %> - - <TR> - <TD COLSPAN=<%=$colspan%>>Never billed</TD> - </TR> - - <% } else { %> - - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Setup </TD> - <%= pkg_datestr($pkg, 'setup',$conf) %> - </TR> - - <% } %> - - <% if ( $pkg->{'last_bill'} ) { %> - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><%= $last_bill_or_renewed %> </TD> - <%= pkg_datestr($pkg, 'last_bill',$conf) %> - </TR> - <% } %> - - <!-- # next bill ?? --> - <% if ( $pkg->{'expire'} ) { %> - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Expires </TD> - <%= pkg_datestr($pkg, 'expire',$conf) %> - </TR> - <% } %> + if ( $pkg->{susp} ) { #status: suspended + print '<TR><TD><FONT COLOR="#FF9900"><B>Suspended</B> </FONT></TD>'. + '<TD>'. pkg_datestr($pkg,'susp',$conf). '</TD></TR>'; + unless ( $pkg->{setup} ) { + print '<TR><TD COLSPAN=2>Never billed</TD></TR>'; + } else { + print "<TR><TD>Setup </TD><TD>". + pkg_datestr($pkg, 'setup',$conf). '</TD></TR>'; + } + print "<TR><TD>Last bill </TD><TD>". + pkg_datestr($pkg, 'last_bill',$conf). '</TD></TR>' + if $pkg->{'last_bill'}; + # next bill ?? + print "<TR><TD>Expires </TD><TD>". + pkg_datestr($pkg, 'expire',$conf). '</TD></TR>' + if $pkg->{'expire'}; + print '<TR><TD COLSPAN=2>( '. pkg_unsuspend_link($pkg). + ' | '. pkg_cancel_link($pkg). ' )</TD></TR>'; + + } else { #status: active + + unless ( $pkg->{setup} ) { #not setup + + print '<TR><TD COLSPAN=2>Not yet billed ('; + unless ( $pkg->{freq} ) { + print 'one-time charge)</TD></TR>'; + print '<TR><TD COLSPAN=2>( '. pkg_cancel_link($pkg). + ' )</TD</TR>'; + } else { + print 'billed '. myfreq($pkg->{part_pkg}). ')</TD></TR>'; + } + + } else { #setup + + unless ( $pkg->{freq} ) { + print "<TR><TD COLSPAN=2>One-time charge</TD></TR>". + '<TR><TD>Billed </TD><TD>'. + pkg_datestr($pkg,'setup',$conf). '</TD></TR>'; + } else { + print '<TR><TD COLSPAN=2><FONT COLOR="#00CC00"><B>Active</B></FONT>'. + ', billed '. myfreq($pkg->{part_pkg}). '</TD></TR>'. + '<TR><TD>Setup </TD><TD>'. + pkg_datestr($pkg, 'setup',$conf). '</TD></TR>'; + } + + } + + print "<TR><TD>Last bill </TD><TD>". + pkg_datestr($pkg, 'last_bill',$conf). '</TD></TR>' + if $pkg->{'last_bill'}; + print "<TR><TD>Next bill </TD><TD>". + pkg_datestr($pkg, 'next_bill',$conf). '</TD></TR>' + if $pkg->{'next_bill'}; + print "<TR><TD>Expires </TD><TD>". + pkg_datestr($pkg, 'expire',$conf). '</TD></TR>' + if $pkg->{'expire'}; + if ( $pkg->{freq} ) { + print '<TR><TD COLSPAN=2>( '. pkg_suspend_link($pkg). + ' | '. pkg_cancel_link($pkg). ' )</TD></TR>'; + } - <TR> - <TD COLSPAN=<%=$colspan%>>( <%= pkg_unsuspend_link($pkg) %> | <%= pkg_cancel_link($pkg) %> )</TD> - </TR> - - <% } else { %> <!-- #status: active --> - - <% unless ( $pkg->{setup} ) { %> <!-- #not setup --> - - <% unless ( $pkg->{'freq'} ) { %> - - <TR> - <TD COLSPAN=<%=$colspan%>>Not yet billed (one-time charge)</TD> - </TR> - - <TR> - <TD COLSPAN=<%=$colspan%>>( <%= pkg_cancel_link($pkg) %> )</TD> - </TR> - - <% } else { %> - - <TR> - <TD COLSPAN=<%=$colspan%>>Not yet billed (<%= $billed_or_prepaid %> <%= myfreq($pkg->{part_pkg}) %>)</TD> - </TR> - - <% } %> - - <% } else { %> <!-- #setup --> - - <% unless ( $pkg->{freq} ) { %> - - <TR> - <TD COLSPAN=<%=$colspan%>>One-time charge</TD> - </TR> - - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Billed </TD> - <%= pkg_datestr($pkg,'setup',$conf) %> - </TR> - - <% } else { %> - - <TR> - <TD COLSPAN=<%=$colspan%>><FONT COLOR="#00CC00"><B>Active</B></FONT>, <%= $billed_or_prepaid %> <%= myfreq($pkg->{part_pkg}) %></TD> - </TR> - - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Setup </TD> - <%= pkg_datestr($pkg, 'setup',$conf) %> - </TR> - - <% } %> - - <% } %> - - <% if ( $pkg->{'last_bill'} ) { %> - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><%= $last_bill_or_renewed %> </TD> - <%= pkg_datestr($pkg, 'last_bill',$conf) %> - </TR> - <% } %> - - <% if ( $pkg->{'next_bill'} ) { %> - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><%= $next_bill_or_prepaid_until %> </TD> - <%= pkg_datestr($pkg, 'next_bill',$conf) %> - </TR> - <% } %> - - <% if ( $pkg->{'expire'} ) { %> - <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Expires </TD> - <%= pkg_datestr($pkg, 'expire',$conf) %> - </TR> - <% } %> - - <% if ( $pkg->{freq} ) { %> - <TR> - <TD COLSPAN=<%=$colspan%>>( <%= pkg_suspend_link($pkg) %> | <%= pkg_cancel_link($pkg) %> )</TD> - </TR> - <% } %> - - <% } %> + } -<% } %> + } -</TABLE> -</TD> + print "</TABLE></TD>\n"; -<% if ($rowspan == 0) { print qq!</TR>\n!; next; } my $cnt = 0; @@ -442,15 +342,9 @@ sub pkgsort_pkgnum_cancel { sub pkg_datestr { my($pkg, $field, $conf) = @_ or return ''; return ' ' unless $pkg->{$field}; - my $format = '<TD align="left"><B>%b</B></TD>'. - '<TD align="right"><B> %o,</B></TD>'. - '<TD align="right"><B> %Y</B></TD>'; - #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>' - $format .= '<TD ALIGN="right"><B> %l</TD>'. - '<TD ALIGN="center"><B>:</B></TD>'. - '<TD ALIGN="left"><B>%M</B></TD>'. - '<TD ALIGN="left"><B> %P</B></TD>' - if $conf->exists('cust_pkg-display_times'); + my $format = $conf->exists('pkg_showtimes') + ? '<B>%D</B> <FONT SIZE=-3>%l:%M:%S%P %z</FONT>' + : '<B>%b %o, %Y</B>'; ( my $strip = time2str($format, $pkg->{$field}) ) =~ s/ (\d)/$1/g; $strip; } diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index ec99b8c54..db01ebbcf 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -1,63 +1,13 @@ <% my( $cust_main ) = @_; - my $custnum = $cust_main->custnum; - my $conf = new FS::Conf; - - my @payby = grep /\w/, $conf->config('payby'); - #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) - @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) - unless @payby; - my %payby = map { $_=>1 } @payby; - - my $s = 0; - + my $custnum = $cust_main->custnum; %> <BR><BR><A NAME="history"><FONT SIZE="+2">Payment History</FONT></A><BR> - -<% if ( $payby{'BILL'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=BILL;custnum=<%= $custnum %>">Post check payment</A> - -<% } %> - -<% if ( $payby{'CASH'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=CASH;custnum=<%= $custnum %>">Post cash payment</A> - -<% } %> - -<% if ( $payby{'WEST'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;custnum=<%= $custnum %>">Post Western Union payment</A> - -<% } %> - -<% if ( $payby{'CARD'} || $payby{'DCRD'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>misc/payment.cgi?payby=CARD;custnum=<%= $custnum %>">Process credit card payment</A> - -<% } %> - -<% if ( $payby{'CHEK'} || $payby{'DCHK'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>misc/payment.cgi?payby=CHEK;custnum=<%= $custnum %>">Process electronic check (ACH) payment</A> - -<% } %> - -<% if ( $payby{'MCRD'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=MCRD;custnum=<%= $custnum %>">Post manual credit card payment</A> - -<% } %> - +<A HREF="<%= $p %>edit/cust_pay.cgi?custnum=<%= $custnum %>">Post cash/check payment</A> +| <A HREF="<%= $p %>misc/payment.cgi?payby=CARD;custnum=<%= $custnum %>">Process credit card payment</A> +| <A HREF="<%= $p %>misc/payment.cgi?payby=CHEK;custnum=<%= $custnum %>">Process electronic check (ACH) payment</A> <BR><A HREF="<%= $p %>edit/cust_credit.cgi?<%= $custnum %>">Post credit</A> <BR> @@ -101,12 +51,8 @@ foreach my $cust_pay ($cust_main->cust_pay) { $payby =~ s/^BILL$/Check #/ if $payinfo; $payby =~ s/^CHEK$/Electronic check /; $payby =~ s/^PREP$/Prepaid card /; - $payby =~ s/^CARD$/Credit card #/; - $payby =~ s/^COMP$/Complimentary by /; - $payby =~ s/^CASH$/Cash/; - $payby =~ s/^WEST$/Western Union/; - $payby =~ s/^MCRD$/Manual credit card/; $payby =~ s/^BILL$//; + $payby =~ s/^(CARD|COMP)$/$1 /; my $info = $payby ? " ($payby$payinfo)" : ''; my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' ); @@ -172,14 +118,14 @@ foreach my $cust_pay ($cust_main->cust_pay) { my $void = ''; if ( $cust_pay->closed !~ /^Y/i - && ( $cust_pay->payby ne 'CARD' || $conf->exists('cc-void') ) + && $cust_pay->payby ne 'CARD' && ( $cust_pay->payby ne 'CHEK' || $conf->exists('echeck-void') ) ) { $void = qq! (<A HREF="javascript:areyousure('!. qq!${p}misc/void-cust_pay.cgi?!. $cust_pay->paynum. qq!', 'Are you sure you want to void this payment?')"!. qq! TITLE="Void this payment from the database!. - ( $cust_pay->payby =~ /^(CARD|CHEK)$/ + ( $cust_pay->payby eq 'CHEK' ? ' (do not send anything to the payment gateway)' : '' ). '"'. @@ -229,24 +175,11 @@ foreach my $cust_pay_void ($cust_main->cust_pay_void) { $payby =~ s/^(CARD|COMP)$/$1 /; my $info = $payby ? " ($payby$payinfo)" : ''; - my $unvoid = ''; - if ( $cust_pay_void->closed !~ /^Y/i && $conf->exists('unvoid') ) { - $unvoid = qq! (<A HREF="javascript:areyousure('!. - qq!${p}misc/unvoid-cust_pay_void.cgi?!. $cust_pay_void->paynum. - qq!', 'Are you sure you want to unvoid this payment?')"!. - qq! TITLE="Unvoid this payment from the database!. - ( $cust_pay_void->payby =~ /^(CARD|CHEK)$/ - ? ' (do not send anything to the payment gateway)' - : '' - ). '"'. - qq!>unvoid</A>)!; - } - push @history, { 'date' => $cust_pay_void->_date, 'desc' => "<DEL>Payment $info</DEL> <I>voided ". time2str("%D", $cust_pay_void->void_date). - " by ". $cust_pay_void->otaker. '</i>'. $unvoid, + " by ". $cust_pay_void->otaker. '</i>', 'void_payment' => $cust_pay_void->paid, }; @@ -326,10 +259,7 @@ foreach my $cust_credit ($cust_main->cust_credit) { push @history, { 'date' => $cust_credit->_date, 'desc' => $pre. "Credit$post by ". $cust_credit->otaker. - ( $cust_credit->reason - ? ' ('. $cust_credit->reason. ')' - : '' - ). + ' ('. $cust_credit->reason. ')'. "$desc$apply$delete$unapply", 'credit' => $cust_credit->amount, }; diff --git a/httemplate/view/cust_main/quick-charge.html b/httemplate/view/cust_main/quick-charge.html index 2fe3d5f3d..0b51586d1 100644 --- a/httemplate/view/cust_main/quick-charge.html +++ b/httemplate/view/cust_main/quick-charge.html @@ -1,18 +1,32 @@ <% my( $cust_main ) = @_; + my $conf = new FS::Conf; %> <FORM ACTION="<%=$p%>edit/process/quick-charge.cgi" METHOD="POST"> - <INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $cust_main->custnum %>"> - Description:<INPUT TYPE="text" NAME="pkg"> + Amount:<INPUT TYPE="text" NAME="amount" SIZE=6> + <% + + #false laziness w/ edit/part_pkg.cgi + if ( $conf->exists('enable_taxclasses') ) { + print '<SELECT NAME="taxclass">'; + my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county') + or die dbh->errstr; + $sth->execute or die $sth->errstr; + foreach my $taxclass ( map $_->[0], @{$sth->fetchall_arrayref} ) { + print qq!<OPTION VALUE="$taxclass"!; + #print ' SELECTED' if $taxclass eq $hashref->{taxclass}; + print qq!>$taxclass</OPTION>!; + } + print '</SELECT>'; + } else { + print '<INPUT TYPE="hidden" NAME="taxclass" VALUE="">'; + } -Amount:<INPUT TYPE="text" NAME="amount" SIZE=6> - -<%= include('/elements/select-taxclass.html') %> - +%> + <INPUT TYPE="submit" VALUE="One-time charge"> - </FORM> diff --git a/httemplate/view/cust_main/tickets.html b/httemplate/view/cust_main/tickets.html index 72d68152a..ea70d701d 100644 --- a/httemplate/view/cust_main/tickets.html +++ b/httemplate/view/cust_main/tickets.html @@ -30,7 +30,7 @@ Highest priority tickets (<A HREF="<%= FS::TicketSystem->href_customer_tickets($cust_main->custnum) %>">View all tickets for this customer</A>) -(<A HREF="<%= FS::TicketSystem->href_new_ticket($cust_main, join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) ) %>">New ticket for this customer</A>) +(<A HREF="<%= FS::TicketSystem->href_new_ticket($cust_main->custnum, join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) ) %>">New ticket for this customer</A>) <%= table() %> <TR> <TH>#</TH> diff --git a/httemplate/view/cust_pkg.cgi b/httemplate/view/cust_pkg.cgi index a20149ae2..5f0e6bffc 100755 --- a/httemplate/view/cust_pkg.cgi +++ b/httemplate/view/cust_pkg.cgi @@ -104,9 +104,8 @@ unless ($cancel) { #list of services this pkgpart includes my $pkg_svc; - my %pkg_svc; - #foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $cust_pkg->pkgpart }) ) { - foreach $pkg_svc ( $cust_pkg->part_pkg->pkg_svc ) { + my %pkg_svc = (); + foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $cust_pkg->pkgpart }) ) { $pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity; } diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index b42362d91..1486d7b11 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -1,3 +1,4 @@ +<!-- mason kludge --> <% my $conf = new FS::Conf; @@ -23,46 +24,41 @@ if ($pkgnum) { my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ); die "Unknown svcpart" unless $part_svc; -my $svc = $part_svc->svc; -die 'Empty domsvc for svc_acct.svcnum '. $svc_acct->svcnum - unless $svc_acct->domsvc; -my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } ); -die 'Unknown domain (domsvc '. $svc_acct->domsvc. - ' for svc_acct.svcnum '. $svc_acct->svcnum. ')' - unless $svc_domain; -my $domain = $svc_domain->domain; +my $domain; +if ( $svc_acct->domsvc ) { + my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } ); + die "Unknown domain" unless $svc_domain; + $domain = $svc_domain->domain; +} else { + die "No svc_domain.svcnum record for svc_acct.domsvc: ". $cust_svc->domsvc; +} %> -<% if ( $custnum ) { %> - - <%= header("View $svc account", menubar( - "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", - "Main menu" => $p, - )) %> - - <%= include( '/elements/small_custview.html', $custnum, '', 1 ) %> - <BR> +<SCRIPT> +function areyousure(href) { + if (confirm("Permanently delete this account?") == true) + window.location.href = href; +} +</SCRIPT> -<% } else { %> +<%= header('Account View', menubar( + ( ( $pkgnum || $custnum ) + ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", + ) + : ( "Cancel this (unaudited) account" => + "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')" ) + ), + "Main menu" => $p, +)) %> - <SCRIPT> - function areyousure(href) { - if (confirm("Permanently delete this account?") == true) - window.location.href = href; - } - </SCRIPT> - - <%= header('Account View', menubar( - "Cancel this (unaudited) account" => - "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')", - "Main menu" => $p, - )) %> - -<% } %> +<% -<% if ( $part_svc->part_export_usage ) { +#if ( $cust_pkg && $cust_pkg->part_pkg->plan eq 'sqlradacct_hour' ) { +if ( $part_svc->part_export('sqlradius') + || $part_svc->part_export('sqlradius_withdomain') +) { my $last_bill; my %plandata; @@ -155,73 +151,60 @@ function enable_change () { } %> -Service #<B><%= $svcnum %></B> -| <A HREF="<%=$p%>edit/svc_acct.cgi?<%=$svcnum%>">Edit this service</A> +Service Information +| <A HREF="<%=$p%>edit/svc_acct.cgi?<%=$svcnum%>">Edit this information</A> <% if ( @part_svc ) { %> | <SELECT NAME="svcpart" onChange="enable_change()"> <OPTION VALUE="">Change service</OPTION> <OPTION VALUE="">--------------</OPTION> - <% foreach my $opt_part_svc ( @part_svc ) { %> - <OPTION VALUE="<%= $opt_part_svc->svcpart %>"><%= $opt_part_svc->svc %></OPTION> + <% foreach my $part_svc ( @part_svc ) { %> + <OPTION VALUE="<%= $part_svc->svcpart %>"><%= $part_svc->svc %></OPTION> <% } %> </SELECT> <INPUT NAME="submit" TYPE="submit" VALUE="Change" disabled> <% } %> <%= &ntable("#cccccc") %><TR><TD><%= &ntable("#cccccc",2) %> +<TR><TD ALIGN="right">Service number</TD> + <TD BGCOLOR="#ffffff"><%= $svcnum %></TD></TR> +<TR><TD ALIGN="right">Service</TD> + <TD BGCOLOR="#ffffff"><%= $part_svc->svc %></TD></TR> +<TR><TD ALIGN="right">Username</TD> + <TD BGCOLOR="#ffffff"><%= $svc_acct->username %></TD></TR> +<TR><TD ALIGN="right">Domain</TD> + <TD BGCOLOR="#ffffff"><%= $domain %></TD></TR> + +<TR><TD ALIGN="right">Password</TD> + <TD BGCOLOR="#ffffff"><% + +my $password = $svc_acct->_password; +if ( $password =~ /^\*\w+\* (.*)$/ ) { + $password = $1; + print "<I>(login disabled)</I> "; +} +if ( $conf->exists('showpasswords') ) { + print '<PRE>'. encode_entities($password). '</PRE>'; +} else { + print "<I>(hidden)</I>"; +} +print "</TR></TD>"; +$password = ''; -<TR> - <TD ALIGN="right">Service</TD> - <TD BGCOLOR="#ffffff"><%= $part_svc->svc %></TD> -</TR> -<TR> - <TD ALIGN="right">Username</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->username %></TD> -</TR> -<TR> - <TD ALIGN="right">Domain</TD> - <TD BGCOLOR="#ffffff"><%= $domain %></TD> -</TR> - -<TR> - <TD ALIGN="right">Password</TD> - <TD BGCOLOR="#ffffff"> - - <% my $password = $svc_acct->_password; %> - <% if ( $password =~ /^\*\w+\* (.*)$/ ) { - $password = $1; - %> - <I>(login disabled)</I> - <% } %> - - <% if ( $conf->exists('showpasswords') ) { %> - <PRE><%= encode_entities($password) %></PRE> - <% } else { %> - <I>(hidden)</I> - <% } %> - - </TD> -</TR> -<% $password = ''; %> +if ( $conf->exists('security_phrase') ) { + my $sec_phrase = $svc_acct->sec_phrase; + print '<TR><TD ALIGN="right">Security phrase</TD><TD BGCOLOR="#ffffff">'. + $svc_acct->sec_phrase. '</TD></TR>'; +} -<% if ( $conf->exists('security_phrase') ) { - my $sec_phrase = $svc_acct->sec_phrase; -%> - <TR> - <TD ALIGN="right">Security phrase</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->sec_phrase %></TD> - </TR> -<% } %> +my $svc_acct_pop = $svc_acct->popnum + ? qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum}) + : ''; +print "<TR><TD ALIGN=\"right\">Access number</TD>". + "<TD BGCOLOR=\"#ffffff\">". $svc_acct_pop->text. '</TD></TR>' + if $svc_acct_pop; -<% if ( $svc_acct->popnum ) { - my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum}); %> - <TR> - <TD ALIGN="right">Access number</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct_pop->text %></TD> - </TR> -<% } %> <% if ($svc_acct->uid ne '') { %> <TR> @@ -277,56 +260,49 @@ Service #<B><%= $svcnum %></B> </TR> <% } %> -<% foreach my $attribute ( grep /^radius_/, $svc_acct->fields ) { +<% + +my($attribute); +foreach $attribute ( grep /^radius_/, $svc_acct->fields ) { + #warn $attribute; $attribute =~ /^radius_(.*)$/; my $pattribute = $FS::raddb::attrib{$1}; -%> - <TR> - <TD ALIGN="right">Radius (reply) <%= $pattribute %></TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->getfield($attribute) %></TD> - </TR> -<% } %> - -<% foreach my $attribute ( grep /^rc_/, $svc_acct->fields ) { + print "<TR><TD ALIGN=\"right\">Radius (reply) $pattribute</TD>". + "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute). + "</TD></TR>"; +} +foreach $attribute ( grep /^rc_/, $svc_acct->fields ) { + #warn $attribute; $attribute =~ /^rc_(.*)$/; my $pattribute = $FS::raddb::attrib{$1}; -%> - <TR> - <TD ALIGN="right">Radius (check) <%= $pattribute %></TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->getfield($attribute) %></TD> - </TR> -<% } %> + print "<TR><TD ALIGN=\"right\">Radius (check) $pattribute: </TD>". + "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute). + "</TD></TR>"; +} -<TR> - <TD ALIGN="right">RADIUS groups</TD> - <TD BGCOLOR="#ffffff"><%= join('<BR>', $svc_acct->radius_groups) %></TD> -</TR> +print '<TR><TD ALIGN="right">RADIUS groups</TD><TD BGCOLOR="#ffffff">'. + join('<BR>', $svc_acct->radius_groups). '</TD></TR>'; -<% if ( $svc_acct->seconds =~ /^\d+$/ ) { %> - <TR> - <TD ALIGN="right">Prepaid time</TD> - <TD BGCOLOR="#ffffff"><%= duration_exact($svc_acct->seconds) %></TD> - </TR> -<% } %> +if ( $svc_acct->seconds =~ /^\d+$/ ) { + print '<TR><TD ALIGN="right">Prepaid time</TD><TD BGCOLOR="#ffffff">'. + duration_exact($svc_acct->seconds). '</TD></TR>'; +} -<% # Can this be abstracted further? Maybe a library function like # widget('HTML', 'view', $svc_acct) ? It would definitely make UI # style management easier. -%> -<% foreach (sort { $a cmp $b } $svc_acct->virtual_fields) { %> - <%= $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)) %> -<% } %> - -</TABLE></TD></TR></TABLE> -</FORM> -<BR><BR> +foreach (sort { $a cmp $b } $svc_acct->virtual_fields) { + print $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)), + "\n"; +} +%> +</TABLE></TD></TR></TABLE></FORM> +<% -<%= join("<BR>", $conf->config('svc_acct-notes') ) %> -<BR><BR> +print '<BR><BR>'; -<%= joblisting({'svcnum'=>$svcnum}, 1) %> +print join("\n", $conf->config('svc_acct-notes') ). '<BR><BR>'. + joblisting({'svcnum'=>$svcnum}, 1). '</BODY></HTML>'; -</BODY> -</HTML> +%> diff --git a/httemplate/view/svc_domain.cgi b/httemplate/view/svc_domain.cgi index 428f3e9bf..057b15788 100755 --- a/httemplate/view/svc_domain.cgi +++ b/httemplate/view/svc_domain.cgi @@ -36,8 +36,8 @@ my $domain = $svc_domain->domain; ( ( $pkgnum || $custnum ) ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", ) - : ( "Delete this (unaudited) domain" => - "javascript:areyousure('${p}misc/cancel-unaudited.cgi?$svcnum', 'Delete $domain and all records?' )" ) + : ( "Cancel this (unaudited) domain" => + "${p}misc/cancel-unaudited.cgi?$svcnum" ) ), "Main menu" => $p, )) %> @@ -50,8 +50,8 @@ Service #<%= $svcnum %> <BR><BR><A HREF="<%= ${p} %>misc/whois.cgi?custnum=<%=$custnum%>;svcnum=<%=$svcnum%>;domain=<%=$domain%>">View whois information.</A> <BR><BR> <SCRIPT> - function areyousure(href, message) { - if ( confirm(message) == true ) + function areyousure(href) { + if ( confirm("Remove this record?") == true ) window.location.href = href; } function slave_areyousure() { @@ -74,7 +74,7 @@ Service #<%= $svcnum %> <td><%= $domain_record->recdata %> <% unless ( $domain_record->rectype eq 'SOA' ) { %> - (<A HREF="javascript:areyousure('<%=$p%>misc/delete-domain_record.cgi?<%=$domain_record->recnum%>', 'Delete \'<%= $domain_record->reczone %> <%= $type %> <%= $domain_record->recdata %>\' ?' )">delete</A>) + (<A HREF="javascript:areyousure('<%=$p%>misc/delete-domain_record.cgi?<%=$domain_record->recnum%>')">delete</A>) <% } %> </td></tr> <% } %> |