diff options
Diffstat (limited to 'httemplate')
84 files changed, 1861 insertions, 673 deletions
diff --git a/httemplate/browse/addr_block.cgi b/httemplate/browse/addr_block.cgi index ba40bfd43..9e7ef2af2 100644 --- a/httemplate/browse/addr_block.cgi +++ b/httemplate/browse/addr_block.cgi @@ -17,12 +17,13 @@ '', ], 'fields' => [ 'NetAddr', - sub { my $block = shift; - my $router = $block->router; + sub { my $b = shift; + my $router = $b->router; my $result = ''; if ($router) { - $result .= $router->routername. ' ('; - $result .= scalar($block->svc_broadband). ' services)'; + $result .= $router->routername. ' ('. + scalar($b->svc_broadband). ' broadband, '. + scalar($b->svc_acct). ' account services)'; } $result; }, diff --git a/httemplate/browse/discount.html b/httemplate/browse/discount.html index 9b2298ae4..deb98c3c7 100644 --- a/httemplate/browse/discount.html +++ b/httemplate/browse/discount.html @@ -1,22 +1,18 @@ <% include( 'elements/browse.html', 'title' => 'Discounts', 'name' => 'discounts', - 'menubar' => [ 'Add a new discount' => - $p.'edit/discount.html', - ], - 'query' => { 'table' => 'discount', }, + 'menubar' => \@menubar, + 'query' => \%query, + 'order_by_sql' => { description => 'discountnum' }, 'count_query' => 'SELECT COUNT(*) FROM discount', 'disableable' => 1, 'disabled_statuspos' => 1, - 'header' => [ 'Name', 'Comment', 'Class', 'Discount', ], + 'header' => [ 'Name', 'Class', 'Discount', ], 'fields' => [ 'name', - 'comment', 'classname', 'description', ], - 'links' => [ $link, - $link, - ], + 'links' => \@links ) %> <%init> @@ -24,6 +20,20 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $link = [ "${p}edit/discount.html?", 'discountnum' ]; +my @links = ( + [ "${p}edit/discount.html?", 'discountnum' ], + [ "${p}edit/discount_class.html?", 'classnum' ], +); + +my %query = ( + select => 'discount.*, discount_class.*', + table => 'discount', + addl_from => 'LEFT JOIN discount_class USING(classnum)', +); + +my @menubar = ( + 'Add a new discount' => $p.'edit/discount.html', + 'Discount classes' => $p.'browse/discount_class.html', +); </%init> diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 8c51b35f4..f25c00ef2 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -562,7 +562,7 @@ if ( $acl_edit_global ) { 'action' => "${p}edit/bulk-cust_pkg.html?". 'pkgpart='.$part_pkg->pkgpart, 'actionlabel' => 'Change Packages', - 'width' => 569, + 'width' => 960, 'height' => 210, ).' ]</FONT>', 'align' => 'left', @@ -796,8 +796,22 @@ if ( $acl_edit_bulk ) { $align .= 'c'; $html_form = qq!<FORM ACTION="${p}edit/bulk-part_pkg.html" METHOD="POST">!; $html_foot = include('/search/elements/checkbox-foot.html', - submit => 'edit report classes', # for now it's only report classes - ) . '</FORM>'; + actions => [ + { submit => 'edit report classes', }, + { label => 'change customer packages', + onclick=> include('/elements/popup_link_onclick.html', + 'label' => 'change', + 'js_action' => qq{ + '${p}edit/bulk-cust_pkg.html?' + \$('input[name=pkgpart]').serialize() + }, + 'actionlabel' => 'Change customer packages', + 'width' => 960, + 'height' => 420, + ) + }, + ], + ). + '</FORM>'; } my @menubar; diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index b9474636d..222433db3 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -251,6 +251,7 @@ my %flag = ( 'A' => 'Automatically filled in from inventory', 'H' => 'Selected from hardware class', 'X' => 'Excluded', + 'P' => 'From package 477 information', ); my %search; diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index 3d57b310c..d84edce00 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -75,7 +75,7 @@ configCell.innerHTML = <% $value |js_string %>; % } elsif ( $type eq 'select-sub' && ! $i->multiple ) { configCell.innerHTML = - <% $conf->config($i->key, $agentnum) |js_string %> + ': ' + + <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' |js_string %> + ': ' + <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) |js_string %>; % } else { //alert('unknown type <% $type %>'); @@ -164,7 +164,7 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { or ( $type =~ /^select(-(sub|part_svc|part_pkg|pkg_class|agent))?$/ || $i->multiple ) ) { - if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) { + if ( scalar(@{[ $cgi->param($i->key.$n) ]}) && $cgi->param($i->key.$n) ne '' ) { my $error = &{$i->validate}([ $cgi->param($i->key.$n) ], $n) if $i->validate; push @error, $error if $error; $conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum); diff --git a/httemplate/edit/agent_payment_gateway.html b/httemplate/edit/agent_payment_gateway.html index 6d15164ac..38411f12e 100644 --- a/httemplate/edit/agent_payment_gateway.html +++ b/httemplate/edit/agent_payment_gateway.html @@ -18,9 +18,12 @@ Use gateway <SELECT NAME="gatewaynum"> <OPTION VALUE="<% $payment_gateway->gatewaynum %>"><% $payment_gateway->gateway_module %> (<% $payment_gateway->gateway_username %>) % } - </SELECT> -<BR><BR> +<BR> + +<INPUT TYPE="checkbox" NAME="cardtype" VALUE="ACH"> for ACH only. +<BR> +<BR> <INPUT TYPE="submit" VALUE="Add gateway override"> </FORM> diff --git a/httemplate/edit/bulk-cust_pkg.html b/httemplate/edit/bulk-cust_pkg.html index 2ff38ca53..8a082f47f 100644 --- a/httemplate/edit/bulk-cust_pkg.html +++ b/httemplate/edit/bulk-cust_pkg.html @@ -19,24 +19,18 @@ function areyousure() { } </SCRIPT> <FORM NAME="OneTrueForm"> -% #false laziness with bulk-cust_svc.html -% $cgi->param('pkgpart') =~ /^(\d+)$/ -% or die "illegal pkgpart: ". $cgi->param('pkgpart'); -% -% my $old_pkgpart = $1; -% my $src_part_pkg = qsearchs('part_pkg', { 'pkgpart' => $old_pkgpart } ) -% or die "unknown pkgpart: $old_pkgpart"; -% +% foreach my $src_part_pkg (@src_part_pkg) { + <INPUT NAME="old_pkgpart" TYPE="hidden" VALUE="<% $src_part_pkg->pkgpart %>"> + Change <B><% $src_part_pkg->pkg_comment |h %></B><BR> +% } -<INPUT NAME="old_pkgpart" TYPE="hidden" VALUE="<% $old_pkgpart %>"> -Change <B><% $src_part_pkg->pkg_comment %></B><BR> - +<BR> to new package definition <SELECT NAME="new_pkgpart"> % foreach my $dest_part_pkg ( qsearch('part_pkg', { 'disabled' => '' } ) ) { - <OPTION VALUE="<% $dest_part_pkg->pkgpart %>"><% $dest_part_pkg->pkgpart %>: <% $dest_part_pkg->pkg %> + <OPTION VALUE="<% $dest_part_pkg->pkgpart %>"><% $dest_part_pkg->pkgpart %>: <% $dest_part_pkg->pkg |h %> % } </SELECT> @@ -57,4 +51,18 @@ to new package definition die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +my @src_part_pkg = (); +foreach my $pkgpart ( $cgi->multi_param('pkgpart') ) { + + $pkgpart =~ /^(\d+)$/ + or die "illegal pkgpart: $pkgpart"; + + my $old_pkgpart = $1; + my $src_part_pkg = qsearchs('part_pkg', { 'pkgpart' => $old_pkgpart } ) + or die "unknown pkgpart: $old_pkgpart"; + + push @src_part_pkg, $src_part_pkg; + +} + </%init> diff --git a/httemplate/edit/cust_main-contacts.html b/httemplate/edit/cust_main-contacts.html index 3b7eb07d3..317257b3b 100644 --- a/httemplate/edit/cust_main-contacts.html +++ b/httemplate/edit/cust_main-contacts.html @@ -1,13 +1,35 @@ +<%doc> + +Hmm, this is now entirely redundant with edit/cust_main/contacts_new.html, and +this one isn't being maintained well. :/ + +</%doc> + +<SCRIPT> + function checkPasswordValidation(fieldid) { + var validationResult = document.getElementById(fieldid+'_result').innerHTML; + if (validationResult.match(/Password valid!/)) { + return true; + } + else { + return false; + } + } +</SCRIPT> + +<& '/elements/validate_password_js.html', &> + <& elements/edit.html, - 'name_singular' => 'customer contacts', #yes, we're editing all of them - 'table' => 'cust_main', - 'post_url' => popurl(1). 'process/cust_main-contacts.html', - 'no_pkey_display' => 1, - 'labels' => { - 'contactnum' => ' ', #'Contact', - #'locationnum' => ' ', - }, - 'fields' => [ + 'name_singular' => 'customer contacts', #yes, we're editing all of them + 'table' => 'cust_main', + 'post_url' => popurl(1). 'process/cust_main-contacts.html', + 'no_pkey_display' => 1, + 'submit_id' => 'submit', + 'labels' => { + 'contactnum' => ' ', #'Contact', + #'locationnum' => ' ', + }, + 'fields' => [ { 'field' => 'contactnum', 'type' => 'contact', 'colspan' => 6, @@ -18,11 +40,12 @@ 'm2_error_callback' => $m2_error_callback, }, ], - #'new_callback' => $new_callback, - #'edit_callback' => $edit_callback, - #'error_callback' => $error_callback, - 'agent_virt' => 1, - 'menubar' => [], #remove "view all" link + #'new_callback' => $new_callback, + #'edit_callback' => $edit_callback, + #'error_callback' => $error_callback, + 'agent_virt' => 1, + 'html_table_class' => 'fsinnerbox', + 'menubar' => [], #remove "view all" link #XXX it would be nice if this could instead be after the error but before # the table @@ -38,6 +61,13 @@ my $curuser = $FS::CurrentUser::CurrentUser; my $conf = new FS::Conf; +if ( $cgi->param('redirect') ) { + my $session = $cgi->param('redirect'); + my $pref = $curuser->option("redirect$session"); + die "unknown redirect session $session\n" unless length($pref); + $cgi = new CGI($pref); +} + my $custnum; if ( $cgi->param('error') ) { $custnum = scalar($cgi->param('custnum')); @@ -77,7 +107,7 @@ my $m2_error_callback = sub { my($cgi, $object) = @_; #process_o2m fields in process/cust_main-contacts.html - my @fields = qw( first last title comment ); + my @fields = FS::contact->cgi_contact_fields; my @gfields = ( '', map "_$_", @fields ); map { diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 05bf4377a..3cc55f348 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -111,7 +111,7 @@ function samechanged(what) { </SCRIPT> -<& cust_main/contacts_new.html, 'cust_main'=>$cust_main, &> +<& cust_main/contacts_new.html, 'cust_main'=>$cust_main, 'submit_id'=>'submitButton', &> %# billing info <& cust_main/billing.html, $cust_main, @@ -286,7 +286,7 @@ if ( $cgi->param('error') ) { $cust_main->paycvv($paycvv); } @invoicing_list = $cust_main->invoicing_list; - $ss = $conf->exists('unmask_ss') ? $cust_main->ss : $cust_main->masked('ss'); + $ss = $cust_main->masked('ss'); $stateid = $cust_main->masked('stateid'); } else { #new customer diff --git a/httemplate/edit/cust_main/contacts_new.html b/httemplate/edit/cust_main/contacts_new.html index 1171e7df4..90314258d 100644 --- a/httemplate/edit/cust_main/contacts_new.html +++ b/httemplate/edit/cust_main/contacts_new.html @@ -1,3 +1,17 @@ +<SCRIPT> + function checkPasswordValidation(fieldid) { + var validationResult = document.getElementById(fieldid+'_result').innerHTML; + if (validationResult.match(/Password valid!/)) { + return true; + } + else { + return false; + } + } +</SCRIPT> + +<& '/elements/validate_password_js.html', &> + <DIV ID="contacts_div" STYLE="display:<% $display %>"> <BR> <FONT CLASS="fsinnerbox-title">Contacts</FONT> @@ -5,6 +19,7 @@ 'embed' => $opt{cust_main}, 'table' => 'cust_main', 'agent_virt' => 1, + 'submit_id' => $opt{submit_id}, 'html_table_class' => 'fsinnerbox', 'labels' => { 'contactnum' => '', #'Contact', #'locationnum' => ' ', diff --git a/httemplate/edit/cust_main/name.html b/httemplate/edit/cust_main/name.html index 713f54cdb..0319cf027 100644 --- a/httemplate/edit/cust_main/name.html +++ b/httemplate/edit/cust_main/name.html @@ -1,7 +1,17 @@ <%def .namepart> -% my ($field, $value, $label, $extra) = @_; +% my ($field, $value, $label, $extra, $unmask_field) = @_; <DIV STYLE="display: inline-block" ID="<% $field %>_input"> <INPUT TYPE="text" NAME="<% $field %>" VALUE="<% $value |h %>" <%$extra%>> +% if ( +% $value +% && ref $unmask_field +% && $FS::CurrentUser::CurrentUser->access_right( $unmask_field->{access_right} ) +% ) { + <& /elements/link-replace_element_text.html, { + target_id => $unmask_field->{target_id}, + replace_text => $unmask_field->{replace_text}, + } &> +% } <BR><FONT SIZE="-1" COLOR="#333333"><% emt($label) %></FONT> </DIV> </%def> @@ -13,7 +23,11 @@ <& .namepart, 'first', $cust_main->first, 'First' &> % if ( $conf->exists('show_ss') ) { - <& .namepart, 'ss', $ss, 'SS#', "SIZE=11" &> + <& .namepart, 'ss', $ss, 'SS#', "SIZE=11 ID='ss'", { + target_id => 'ss', + replace_text => $cust_main->ss, + access_right => 'Unmask customer SSN', + } &> % } else { <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"> % } @@ -47,7 +61,7 @@ my $agentnum = $cust_main->agentnum if $cust_main->custnum; my $conf = FS::Conf->new; my $ss; -if ( $cgi->param('error') or $conf->exists('unmask_ss') ) { +if ( $cgi->param('error') ) { $ss = $cust_main->ss; } else { $ss = $cust_main->masked('ss'); diff --git a/httemplate/edit/cust_main/stateid.html b/httemplate/edit/cust_main/stateid.html index 3500d631c..0f288099b 100644 --- a/httemplate/edit/cust_main/stateid.html +++ b/httemplate/edit/cust_main/stateid.html @@ -1,7 +1,12 @@ % if ( $conf->exists('show_stateid') ) { <TR> <TH ALIGN="right"><% $stateid_label %></TH> - <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>" SIZE=12></TD> + <TD> + <INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>" SIZE=12 ID="stateid"> +% if ( $stateid && $FS::CurrentUser::CurrentUser->access_right( 'Unmask customer DL' )) { + <& /elements/link-replace_element_text.html, {target_id => 'stateid', replace_text => $cust_main->stateid} &> +% } + </TD> <TD><& /elements/select-state.html, state => $cust_main->stateid_state, country => $cust_main->country, # how does this work on new customer? diff --git a/httemplate/edit/cust_refund.cgi b/httemplate/edit/cust_refund.cgi index e1975ed70..f3dec98e1 100755 --- a/httemplate/edit/cust_refund.cgi +++ b/httemplate/edit/cust_refund.cgi @@ -34,7 +34,7 @@ % } <BR>Payment - <% ntable("#cccccc", 2) %> + <TABLE class="fsinnerbox"> <TR> <TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">$<% $cust_pay->paid %></TD> @@ -85,7 +85,8 @@ <BR>Refund -<% ntable("#cccccc", 2) %> + +<TABLE class="fsinnerbox"> <TR> <TD ALIGN="right">Date</TD> @@ -102,9 +103,23 @@ <TD ALIGN="right">Check #</TD> <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD> </TR> + </TABLE> % } -% elsif ($payby eq 'CHEK') { +% elsif ($payby eq 'CHEK' || $payby eq 'CARD') { % +<SCRIPT TYPE="text/javascript"> + function cust_payby_changed (what) { + var custpaybynum = what.options[what.selectedIndex].value + if ( custpaybynum == '' || custpaybynum == '0' ) { + //what.form.payinfo.disabled = false; + $('#cust_payby').slideDown(); + } else { + //what.form.payinfo.value = ''; + //what.form.payinfo.disabled = true; + $('#cust_payby').slideUp(); + } + } +</SCRIPT> % my @cust_payby = (); % if ( $payby eq 'CARD' ) { % @cust_payby = $cust_main->cust_payby('CARD','DCRD'); @@ -117,16 +132,58 @@ % my $custpaybynum = length(scalar($cgi->param('custpaybynum'))) % ? scalar($cgi->param('custpaybynum')) % : scalar(@cust_payby) && $cust_payby[0]->custpaybynum; -<& /elements/tr-select-cust_payby.html, + +% if ($cust_pay) { + <INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10> +% } +% else { + <& /elements/tr-select-cust_payby.html, 'cust_payby' => \@cust_payby, 'curr_value' => $custpaybynum, 'onchange' => 'cust_payby_changed(this)', -&> - <INPUT TYPE="hidden" NAME="batch" VALUE="1"> + &> +% } + +% if ( $conf->exists("batch-enable") +% || grep $payby eq $_, $conf->config('batch-enable_payby') +% ) { +% if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) { + <INPUT TYPE="hidden" NAME="batch" VALUE="1"> +% } else { + <TR> + <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="batch" VALUE="1" ID="batch" <% ($batchnum || $batch) ? 'checked' : '' %> ></TD> + <TH ALIGN="left"> <% mt('Add to current batch') |h %></TH> + </TR> +% } +% } + + </TABLE> +<P> + +% if ( !$cust_pay ) { +<DIV ID="cust_payby" + <% $custpaybynum ? 'STYLE="display:none"' + : '' + %> +> +<TABLE class="fsinnerbox"> + + <& /elements/cust_payby_new.html, + 'cust_payby' => \@cust_payby, + 'curr_value' => $custpaybynum, + &> + +</TABLE> +</DIV> +% } # end if cust_pay + % } else { <INPUT TYPE="hidden" NAME="payinfo" VALUE=""> + </TABLE> % } +<P> +<TABLE class="fsinnerbox"> <& /elements/tr-select-reason.html, 'field' => 'reasonnum', 'reason_class' => 'F', @@ -159,16 +216,18 @@ my $payby = $cgi->param('payby'); my $payinfo = $cgi->param('payinfo'); my $reason = $cgi->param('reason'); my $link = $cgi->param('popup') ? 'popup' : ''; +my $batch = $cgi->param('batch'); die "access denied" unless $FS::CurrentUser::CurrentUser->refund_access_right($payby); -my( $paynum, $cust_pay ) = ( '', '' ); +my( $paynum, $cust_pay, $batchnum ) = ( '', '', '' ); if ( $cgi->param('paynum') =~ /^(\d+)$/ ) { $paynum = $1; $cust_pay = qsearchs('cust_pay', { paynum=>$paynum } ) or die "unknown payment # $paynum"; $refund ||= $cust_pay->unrefunded; + $batchnum = $cust_pay->batchnum; if ( $custnum ) { die "payment # $paynum is not for specified customer # $custnum" unless $custnum == $cust_pay->custnum; diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 8ba703a2f..1d472099b 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -114,6 +114,9 @@ Example: #we're in a popup (no title/menu/searchboxes) 'popup' => 1, + #if you need to access the submit button + 'submit_id' => 'mysubmitbuttonid', + #we're embedded (rows only: no header at all, no html_init, no error # display, no <FORM>, no hidden fields for table name or primary key, no # display of primary key, no submit button, no html_foot, no footer) @@ -398,6 +401,8 @@ Example: % % my $layer_prefix_on = ''; % +% my $submitid = $opt{submit_id} ? $opt{submit_id} : ''; +% % my $include_sub = sub { % my %opt = @_; % @@ -422,6 +427,7 @@ Example: % 'field' => "$field$fieldnum", % 'id' => "$field$fieldnum", #separate? % 'label_id' => $field."_label$fieldnum", #don't want field0_label0... +% 'submit_id' => $submitid, % %include_common, % %opt, % ); @@ -669,7 +675,7 @@ Example: var newrow = <% include(@layer_opt, html_only=>1) |js_string %>; % #until the rest have html/js_only -% if ( ($type eq 'selectlayers') || ($type eq 'selectlayersx') || ($type =~ /^select-cgp_rule_/) ) { +% if ( ($type eq 'selectlayers') || ($type eq 'selectlayersx') || ($type =~ /^select-cgp_rule_/) || ($type eq 'contact') ) { var newfunc = <% include(@layer_opt, js_only=>1) |js_string %>; % } else { var newfunc = ''; diff --git a/httemplate/edit/elements/part_export/broadband_snmp_get.html b/httemplate/edit/elements/part_export/broadband_snmp_get.html index faf179acc..a426e617d 100644 --- a/httemplate/edit/elements/part_export/broadband_snmp_get.html +++ b/httemplate/edit/elements/part_export/broadband_snmp_get.html @@ -45,20 +45,23 @@ function receive_mib_get(obj, rownum) { </script> <table bgcolor="#cccccc" border=0 cellspacing=3> -<TR><TH>Object ID</TH></TR> +<TR><TH>Object Name</TH><TH>Object ID</TH></TR> <TR id="broadband_snmp_get_template"> <TD> + <INPUT NAME="oid_name" ID="oid_name" SIZE="25"> + </TD> + <TD> <INPUT NAME="oid" ID="oid" SIZE="54"> <INPUT TYPE="button" VALUE="..." ID="openselector" onclick="open_select_mib_get(this)"> </TD> </TR> <& /elements/auto-table.html, template_row => 'broadband_snmp_get_template', - fieldorder => ['oid'], + fieldorder => ['oid_name','oid'], data => \@data, table => 'snmp', &> -<INPUT TYPE="hidden" NAME="multi_options" VALUE="snmp_oid"> +<INPUT TYPE="hidden" NAME="multi_options" VALUE="snmp_oid,snmp_oid_name"> <& foot.html, %opt &> <%init> my %opt = @_; @@ -73,11 +76,13 @@ foreach my $field ( qw(snmp_version snmp_community snmp_timeout) ) { } my @oids = split("\n", $part_export->option('snmp_oid')); +my @oid_names = split("\n", $part_export->option('snmp_oid_name')); my @data; while (@oids) { my @thisrow = (shift(@oids)); - push @data, \@thisrow if grep length($_), @thisrow; + my $name = shift(@oid_names); + push @data, [$name, \@thisrow] if grep length($_), @thisrow; } my $popup_name = 'popup-'.time."-$$-".rand() * 2**32; diff --git a/httemplate/edit/elements/part_svc_column.html b/httemplate/edit/elements/part_svc_column.html index 816f3428b..bdbce7c79 100644 --- a/httemplate/edit/elements/part_svc_column.html +++ b/httemplate/edit/elements/part_svc_column.html @@ -15,6 +15,7 @@ To be called from part_svc.cgi. # don't allow the 'inventory' flags (M, A) to be chosen for # fields that aren't free-text my $inv_sub = sub { $_[0]->{disable_inventory} || $_[0]->{type} ne 'text' }; + tie my %flag, 'Tie::IxHash', '' => { 'desc' => 'No default', 'condition' => sub { 0 } }, 'D' => { 'desc' => 'Default', @@ -38,6 +39,9 @@ tie my %flag, 'Tie::IxHash', 'H' => { 'desc' => 'Select from hardware class', 'condition' => sub { $_[0]->{type} ne 'select-hardware' }, }, + 'P' => { 'desc' => 'From package FCC 477 information', + 'condition' => sub { $_[0]->{type} ne 'fcc_477_speed' }, # get values from package fcc 477 information + }, 'X' => { 'desc' => 'Excluded', 'condition' => sub { 1 }, # obsolete }, @@ -202,6 +206,20 @@ my %communigate_fields = ( % $mode = 'hardware'; % $multiple = 0; % } +% +% if ( $def->{'type'} eq 'fcc_477_speed' ) { +% if ($field eq 'speed_up') { + <SPAN ID="<% $name %>_select"> + upstream speed + <INPUT TYPE="hidden" ID="<% $name %>_select" NAME="<% $name %>_classnum" VALUE="up"> + </SPAN> +% } elsif ($field eq 'speed_down') { + <SPAN ID="<% $name %>_select"> + downstream speed + <INPUT TYPE="hidden" ID="<% $name %>_select" NAME="<% $name %>_classnum" VALUE="down"> + </SPAN> +% } +% } else { <& /elements/select-table.html, 'field' => $name.'_classnum', 'id' => $name.'_select', @@ -211,6 +229,7 @@ my %communigate_fields = ( 'empty_label' => "Select $mode class", 'multiple' => $multiple, &> +% } % } </TD> <TD> diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index a4e345e40..e1c309080 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -169,6 +169,16 @@ ]; } # shouldn't this be enforced for all 'S' fields? + elsif ( $flag eq 'P' ) { #form fcc_477 values + $f->{type} = 'fixed'; + my $cust_pkg = FS::Record::qsearchs({ + 'table' => 'cust_pkg', + 'hashref' => { 'pkgnum' => $object->{Hash}->{pkgnum} } + }); + my $fcc_record = $cust_pkg->fcc_477_record('broadband_'.$columndef->columnvalue.'stream') if $cust_pkg; + $f->{'value'} = $fcc_record->{Hash}->{optionvalue} ? $fcc_record->{Hash}->{optionvalue} * 1000 : ''; + } # end 477 values + if ( $f->{'type'} =~ /^select-svc/ ) { $f->{'include_opt_callback'} = diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi index 5411feb5f..f6ec208be 100644 --- a/httemplate/edit/part_export.cgi +++ b/httemplate/edit/part_export.cgi @@ -290,6 +290,20 @@ my $widget = new HTML::Widgets::SelectLayers( $html .= ' CHECKED' if $part_export->no_suspend eq 'Y'; $html .= '></TD></TR>'; + foreach my $script ( keys %{$exports->{$layer}{scripts}} ) { + $html .= '<TR><TD ALIGN="left" COLSPAN=2>' . + include('/elements/progress-init.html', + $part_export->exporttype, + [ $script.'_exportnum', $script.'_script' ], + rooturl().'view/svc_export/run_script.cgi', + rooturl().'edit/part_export.cgi?'.$part_export->{Hash}->{exportnum}, + $script, + ) . + '<INPUT TYPE="hidden" NAME="'.$script.'_exportnum" VALUE="'.$part_export->{Hash}->{exportnum}.'"> + <INPUT TYPE="hidden" NAME="'.$script.'_script" VALUE="'.$script.'"> + <A HREF="#" onClick="'.$script.'process();">'.$exports->{$layer}{scripts}{$script}->{html_label}.'</A></TD></TR>'; + } + $html .= '</TABLE>'; # false laziness with config_element above diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index fed21256f..49c1c03d8 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -107,7 +107,7 @@ function flag_changed(obj) { select.multiple = false; } } - } else if ( newflag == 'M' || newflag == 'A' || newflag == 'H' ) { + } else if ( newflag == 'M' || newflag == 'A' || newflag == 'H' || newflag == 'P' ) { // these all require a class selection if ( select ) { select.disabled = false; @@ -120,7 +120,7 @@ function flag_changed(obj) { } var required = document.getElementById(layer + '__' + field + '_required'); if (required && !required.disabledinit) { - if (newflag == "F") { + if (newflag == "F" || newflag =="P") { required.checked = false; required.disabled = true; } else { diff --git a/httemplate/edit/process/access_user.html b/httemplate/edit/process/access_user.html index fcd210f83..c27262017 100644 --- a/httemplate/edit/process/access_user.html +++ b/httemplate/edit/process/access_user.html @@ -11,7 +11,7 @@ 'target_table' => 'access_group', }, 'precheck_callback' => \&precheck_callback, - #'post_new_object_callback' => \&post_new_object_callback, + 'post_new_object_callback' => \&post_new_object_callback, 'noerror_callback' => \&noerror_callback, ) %> @@ -38,24 +38,22 @@ sub precheck_callback { return ''; } -#sub post_new_object_callback { -# my( $cgi, $access_user ) = @_; -# -# if ( length($cgi->param('_password')) ) { -# my $password = scalar($cgi->param('_password')); -# my $error = $access_user->is_password_allowed($password); -# #XXX and then bubble the error back up to the UI -# } -#} +sub post_new_object_callback { + my( $cgi, $access_user ) = @_; + + return '' unless length($cgi->param('_password')); + + my $password = scalar($cgi->param('_password')); + my $error = $access_user->is_password_allowed($password); + return $error if $error; + + $access_user->change_password_fields($password); + ''; +} sub noerror_callback { my( $cgi, $access_user ) = @_; - if ( length($cgi->param('_password')) ) { - my $password = scalar($cgi->param('_password')); - $access_user->change_password($password); - } - #handle installer checkbox my @sched_item = $access_user->sched_item; my $sched_item = $sched_item[0]; diff --git a/httemplate/edit/process/cust_main-contacts.html b/httemplate/edit/process/cust_main-contacts.html index 5b8319f5a..6b7f1c2db 100644 --- a/httemplate/edit/process/cust_main-contacts.html +++ b/httemplate/edit/process/cust_main-contacts.html @@ -8,7 +8,7 @@ </%doc> <% include('elements/process.html', 'table' => 'cust_main', - 'error_redirect' => popurl(3). 'edit/cust_main-contacts.html?', + 'error_redirect' => popurl(3). 'edit/cust_main-contacts.html', 'agent_virt' => 1, 'skip_process' => 1, #we don't want to make any changes to cust_main 'precheck_callback' => $precheck_callback, diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi index 0a3d55036..1f96456e0 100755 --- a/httemplate/edit/process/cust_refund.cgi +++ b/httemplate/edit/process/cust_refund.cgi @@ -53,7 +53,7 @@ if ( $error ) { 'CHEK' => 'electronic check (ACH)', ); -my( $cust_payby, $payinfo, $paycvv, $month, $year, $payname ); +my( $cust_pay, $cust_payby, $payinfo, $paycvv, $month, $year, $payname ); my $paymask = ''; if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { @@ -71,6 +71,18 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { $paycvv = $cust_payby->paycvv; # pass it if we got it, running a transaction will clear it ( $month, $year ) = $cust_payby->paydate_mon_year; $payname = $cust_payby->payname; + $cgi->param(-name=>"paytype", -value=>$cust_payby->paytype) unless $cgi->param("paytype"); + +} elsif ( $cgi->param('paynum') > 0) { + + $cust_pay = qsearchs({ + 'table' => 'cust_pay', + 'hashref' => { 'paynum' => $cgi->param('paynum') }, + 'select' => 'cust_pay.*, cust_pay_batch.payname ', + 'addl_from' => "left join cust_pay_batch on cust_pay_batch.batchnum = cust_pay.batchnum and cust_pay_batch.custnum = $custnum ", + }); + $payinfo = $cust_pay->payinfo; + $payname = $cust_pay->payname; } else { @@ -192,16 +204,19 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { my $refund = "$1$2"; $cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!"; my $paynum = $1; - my $paydate = $cgi->param('exp_year'). '-'. $cgi->param('exp_month'). '-01'; - $options{'paydate'} = $paydate if $paydate =~ /^\d{2,4}-\d{1,2}-01$/; + my $paydate; + unless ($paynum) { + if ($cust_payby->paydate) { $paydate = "$year-$month-01"; } + else { $paydate = "2037-12-01"; } + } if ( $cgi->param('batch') ) { - + $paydate = "2037-12-01" unless $paydate; $error ||= $cust_main->batch_card( 'payby' => $payby, 'amount' => $refund, 'payinfo' => $payinfo, - 'paydate' => "$year-$month-01", + 'paydate' => $paydate, 'payname' => $payname, 'paycode' => 'C', map { $_ => scalar($cgi->param($_)) } @@ -209,28 +224,23 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { ); errorpage($error) if $error; -#### post refund ##### my %hash = map { $_, scalar($cgi->param($_)) } fields('cust_refund'); - $paynum = $cgi->param('paynum'); - $paynum =~ /^(\d*)$/ or die "Illegal paynum!"; - if ($paynum) { - my $cust_pay = qsearchs('cust_pay',{ 'paynum' => $paynum }); - die "Could not find paynum $paynum" unless $cust_pay; - $error = $cust_pay->refund(\%hash); - } else { - my $new = new FS::cust_refund ( \%hash ); - $error = $new->insert; - } - # if not a batch refund run realtime. + + my $new = new FS::cust_refund ( { 'paynum' => $paynum, + %hash, + } ); + $error = $new->insert; + + # if not a batch refund run realtime. } else { $error = $cust_main->realtime_refund_bop( $bop, 'amount' => $refund, 'paynum' => $paynum, 'reasonnum' => scalar($cgi->param('reasonnum')), %options ); } -} else { +} else { # run cash refund. my %hash = map { $_, scalar($cgi->param($_)) } fields('cust_refund'); diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html index 76722c960..d2b037053 100644 --- a/httemplate/edit/process/elements/process.html +++ b/httemplate/edit/process/elements/process.html @@ -80,8 +80,12 @@ Example: 'precheck_callback' => sub { my( $cgi ) = @_; }, #after the new object is created + #return an error string or empty for no error 'post_new_object_callback' => sub { my( $cgi, $object ) = @_; }, + #run right before replacing (not run for inserts) + 'edit_callback' => sub { my( $new, $old ) = @_; }, + #after everything's inserted 'noerror_callback' => sub { my( $cgi, $object ) = @_; }, @@ -89,6 +93,9 @@ Example: # for use with tables that are FS::option_Common (among other things) 'args_callback' => sub { my( $cgi, $object ) = @_; }, + # if no errors after package insert or replace will update services attached to package. + 'update_svc' => sub { my( $cgi, $object ) = @_; }, + 'debug' => 1, #turns on debugging output #agent virtualization @@ -273,7 +280,7 @@ foreach my $value ( @values ) { } if ( $opt{'post_new_object_callback'} ) { - &{ $opt{'post_new_object_callback'} }( $cgi, $new ); + $error ||= &{ $opt{'post_new_object_callback'} }( $cgi, $new ); } if ( $opt{'agent_virt'} ) { @@ -438,6 +445,12 @@ foreach my $value ( @values ) { } } + if ( !$error and $opt{'update_svc'} ) { + my @args = (); + @args = &{ $opt{'args_callback'} }( $cgi, $new ) if $opt{'args_callback'}; + $error = &{ $opt{'update_svc'} }( $cgi, $new, @args ); + } + if ( $error ) { $cgi->param('error', $error); @@ -459,6 +472,14 @@ foreach my $value ( @values ) { } +if ($class eq "FS::tower") { + foreach my $part_svc_broadband_export ( FS::tower_sector->part_export_svc_broadband ) { + if ($part_svc_broadband_export and $part_svc_broadband_export->can('export_tower_sector')) { + $error = $part_svc_broadband_export->export_tower_sector($new); + } + } +} + # set up redirect URLs my $redirect; diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index c4d150ba1..376491089 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -9,6 +9,7 @@ 'edit_ext' => 'cgi', 'precheck_callback' => $precheck_callback, 'args_callback' => $args_callback, + 'update_svc' => $update_svc, 'process_locale' => 'pkg', 'process_m2m' => \@process_m2m, 'process_o2m' => \@process_o2m, @@ -199,6 +200,38 @@ my $args_callback = sub { }; +## update services upon package change. +my $update_svc = sub { + my $cgi = shift @_; + my $new = shift @_; + my %args = @_; + my $error; + + my @svcs = $new->pkg_svc(); + +## update broadband services getting their up and down speeds from package fcc_477 options + foreach my $svc_part(@svcs) { + my @part_svc_column = qsearch('part_svc_column',{ 'svcpart' => $svc_part->{Hash}->{svcpart}, 'columnflag' => 'P' }); + + if ($svc_part->{Hash}->{svcdb} eq "svc_broadband" && (keys %{ $args{fcc_options} }) && @part_svc_column ) { + ## find provisioned services to update + my @svc_svcdb = qsearch({ + 'table' => 'svc_broadband', + 'select' => 'svc_broadband.*, cust_svc.svcpart', + 'addl_from' => 'LEFT JOIN cust_svc USING (svcnum) LEFT JOIN cust_pkg USING (pkgnum)', + 'extra_sql' => " WHERE cust_svc.svcpart = '".$svc_part->{Hash}->{svcpart}."' AND cust_pkg.pkgpart = '".$svc_part->{Hash}->{pkgpart}."'", + }); + foreach my $svc (@svc_svcdb) { + next if ($svc->{Hash}->{speed_down} == $args{fcc_options}->{broadband_downstream} * 1000 && $svc->{Hash}->{speed_up} == $args{fcc_options}->{broadband_upstream} * 1000); + $svc->{Hash}->{speed_down} = $args{fcc_options}->{broadband_downstream} * 1000; + $svc->{Hash}->{speed_up} = $args{fcc_options}->{broadband_upstream} * 1000; + $error = $svc->replace(); + } + } + } + return $error; +}; + my $redirect_callback = sub { #my( $cgi, $new ) = @_; return '' unless $custnum; diff --git a/httemplate/edit/process/saved_search.html b/httemplate/edit/process/saved_search.html index 7ae7e0d78..51e40edad 100644 --- a/httemplate/edit/process/saved_search.html +++ b/httemplate/edit/process/saved_search.html @@ -10,6 +10,8 @@ my $callback = sub { $obj->usernum( $FS::CurrentUser::CurrentUser->usernum ); # if this would change it from its existing owner, replace_check # will refuse + + ''; #no error }; </%init> diff --git a/httemplate/edit/process/tower.html b/httemplate/edit/process/tower.html index cfbb4ffa3..8f62c4bec 100644 --- a/httemplate/edit/process/tower.html +++ b/httemplate/edit/process/tower.html @@ -6,7 +6,7 @@ sectorname ip_addr height freq_mhz direction width downtilt v_width db_high db_low power line_loss antenna_gain hardware_typenum - sector_range + sector_range up_rate_limit down_rate_limit )], }, &> diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index 81c694aa5..bcf55fe11 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -100,7 +100,7 @@ END ; my @fields = ( - qw( description speed_down speed_up ), + qw( description speed_down speed_up speed_test_down speed_test_up speed_test_latency), { field=>'sectornum', type=>'select-tower_sector', }, { field=>'routernum', type=>'select-router_block_ip', include_opt_callback => sub { @@ -179,7 +179,6 @@ my $svc_field_callback = sub { my $columndef = $part_svc->part_svc_column($fieldref->{'field'}); if ($fieldref->{field} eq 'usergroup' && $columndef->columnflag eq 'F') { - $fieldref->{'formatted_value'} = [ $object->radius_groups('long_description') ]; } diff --git a/httemplate/edit/tower.html b/httemplate/edit/tower.html index 946a1405e..dfebc0031 100644 --- a/httemplate/edit/tower.html +++ b/httemplate/edit/tower.html @@ -13,6 +13,8 @@ 'altitude', 'height', 'veg_height', + 'up_rate_limit', + 'down_rate_limit', # { field => 'sectornum', # type => 'tower_sector', # o2m_table => 'tower_sector', @@ -35,6 +37,8 @@ 'height' => 'Tower height (feet)', 'veg_height' => 'Vegetation height (feet)', 'color' => 'Color', + 'up_rate_limit' => 'Up Rate Limit(Kbps)', + 'down_rate_limit' => 'Down Rate Limit(Kbps)', }, &> <%init> @@ -43,7 +47,7 @@ my $m2_error_callback = sub { # reconstruct the list my ($cgi, $object) = @_; my @fields = qw( - sectorname ip_addr height freq_mhz direction width tilt v_width db_high db_low sector_range + sectorname ip_addr height freq_mhz direction width tilt v_width db_high db_low sector_range up_rate_limit down_rate_limit ); map { diff --git a/httemplate/elements/broadband_snmp_get.html b/httemplate/elements/broadband_snmp_get.html index 213bc4460..1164504ee 100644 --- a/httemplate/elements/broadband_snmp_get.html +++ b/httemplate/elements/broadband_snmp_get.html @@ -26,7 +26,7 @@ function broadband_snmp_get (svcnum) { if (obj.error) { var row = document.createElement('tr'); var cell = document.createElement('td'); - cell.colSpan = '2'; + cell.colSpan = '3'; cell.innerHTML = obj['error']; row.appendChild(cell); table.appendChild(row); @@ -36,6 +36,9 @@ function broadband_snmp_get (svcnum) { var value = obj['values'][j]; var label = (obj['values'].length > 1) ? (value[0] + '.' + value[1]) : obj['label']; var cell = document.createElement('td'); + cell.innerHTML = obj['name']; + row.appendChild(cell); + cell = document.createElement('td'); cell.innerHTML = label; row.appendChild(cell); cell = document.createElement('td'); diff --git a/httemplate/elements/change_password.html b/httemplate/elements/change_password.html index 7d95e19dc..068d7d73c 100644 --- a/httemplate/elements/change_password.html +++ b/httemplate/elements/change_password.html @@ -11,9 +11,9 @@ % if (!$opt{'no_label_display'}) { <A ID="<%$pre%>link" HREF="javascript:void(0)" onclick="<%$pre%>toggle(true)">(<% emt( $change_title ) %>)</A> % } -<DIV ID="<%$pre%>form" CLASS="passwordbox"> +<DIV ID="<%$pre%>div" CLASS="passwordbox"> % if (!$opt{'noformtag'}) { - <FORM METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return checkPasswordValidation()"> + <FORM ID="<%$pre%>form" METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return <%$pre%>checkPasswordValidation()"> % } <% $change_id_input %> @@ -44,11 +44,9 @@ function <%$pre%>toggle(toggle, clear) { if (clear) { document.getElementById('<%$pre%>password').value = ''; document.getElementById('<%$pre%>password_result').innerHTML = ''; -% if ($opt{'contact_num'}) { - document.getElementById('<% $opt{'pre_pwd_field_label'} %>selfservice_access').value = 'Y'; -% } -} - document.getElementById('<%$pre%>form').style.display = + document.getElementById('<%$change_button_id%>').disabled = true; + } + document.getElementById('<%$pre%>div').style.display = toggle ? 'inline-block' : 'none'; % if (!$opt{'no_label_display'}) { document.getElementById('<%$pre%>link').style.display = @@ -56,7 +54,7 @@ function <%$pre%>toggle(toggle, clear) { % } } -function checkPasswordValidation() { +function <%$pre%>checkPasswordValidation(resultId) { var validationResult = document.getElementById('<%$pre%>password_result').innerHTML; if (validationResult.match(/Password valid!/)) { return true; @@ -83,8 +81,8 @@ if ($opt{'svc_acct'}) { } elsif ($opt{'contact_num'}) { $change_id_input = ' - <INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'contactnum" VALUE="' . $opt{'contact_num'} . '"> - <INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'custnum" VALUE="' . $opt{'custnum'} . '"> + <INPUT TYPE="hidden" NAME="contactnum" VALUE="' . $opt{'contact_num'} . '"> + <INPUT TYPE="hidden" NAME="custnum" VALUE="' . $opt{'custnum'} . '"> '; $pre .= $opt{'pre_pwd_field_label'}; } diff --git a/httemplate/elements/city.html b/httemplate/elements/city.html index 4e9a60940..05250fef5 100644 --- a/httemplate/elements/city.html +++ b/httemplate/elements/city.html @@ -132,14 +132,14 @@ function <% $pre %>county_changed(what, callback) {} > % unless ( $opt{'disable_empty'} ) { - <OPTION VALUE="" <% $opt{city} eq '' ? 'SELECTED' : '' %>><% $opt{empty_label} %> + <OPTION VALUE="" <% $opt{city} eq '' ? 'SELECTED' : '' %>><% $opt{empty_label} %></OPTION> % } % foreach my $city ( @cities ) { <OPTION VALUE="<% $city |h %>" <% $city eq $opt{city} ? 'SELECTED' : '' %> - ><% $city eq $opt{empty_data_value} ? $opt{empty_data_label} : $city %> + ><% $city eq $opt{empty_data_value} ? $opt{empty_data_label} : $city %></OPTION> % } diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html index 43e520155..48b5e2ce2 100644 --- a/httemplate/elements/contact.html +++ b/httemplate/elements/contact.html @@ -1,4 +1,6 @@ -% unless ( $opt{'js_only'} ) { +% if ( $opt{'js_only'} ) { +<% $js %> +% } else { <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>"> @@ -40,6 +42,8 @@ % } % } elsif ( $field eq 'emailaddress' ) { % $value = join(', ', map $_->emailaddress, $contact->contact_email); +% } elsif ( $field eq 'password' ) { +% $value = $contact->get('_password') ? '********' : ''; % } elsif ( $field eq 'selfservice_access' % or $field eq 'comment' % or $field eq 'invoice_dest' @@ -56,28 +60,25 @@ ID = "<%$id%>_<%$field%>" STYLE = "width: 140px" > - <OPTION VALUE="">Disabled + <OPTION VALUE="" <% !$value ? 'SELECTED' : '' %>>Disabled % if ( $value || $self_base_url ) { <OPTION VALUE="<% $value eq 'Y' ? 'Y' : 'E' %>" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled % if ( $value eq 'Y' && $self_base_url ) { <OPTION VALUE="R">Re-email - <OPTION VALUE="P"><% $pwd_change_label %> % } % } </SELECT> - <& /elements/change_password.html, - 'contact_num' => $curr_value, - 'custnum' => $opt{'custnum'}, - 'curr_value' => '', - 'no_label_display' => '1', - 'noformtag' => '1', - 'pre_pwd_field_label' => $id.'_', - &> - <SCRIPT TYPE="text/javascript"> - document.getElementById("<%$id%>_<%$field%>").onchange = function() { - if (this.value == "P" || this.value == "E") { changepw<%$id%>_toggle(true); } - return false - } +% #password form +% } elsif ( $field eq 'password') { + <INPUT TYPE = "text" + NAME = "<%$name%>_<%$field%>" + ID = "changepw<%$id%>_<%$field%>" + SIZE = "<% $size{$field} || 14 %>" + VALUE = "" + placeholder = "<% $value |h %>" + > + <SCRIPT> + <% $js %> </SCRIPT> % } elsif ( $field eq 'invoice_dest' || $field eq 'message_dest' ) { % my $curr_value = $cgi->param($name . '_' . $field); @@ -101,6 +102,9 @@ % } <BR> <FONT SIZE="-1"><% $label{$field} %></FONT> +% if ( $field eq 'password' ) { + <DIV ID="changepw<%$id%>_<%$field%>_result" STYLE="font-size: smaller"></DIV> +% } </TD> % } </TR> @@ -119,6 +123,7 @@ my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum'; my $id = $opt{'id'} || 'contactnum'; my $curr_value = $opt{'curr_value'} || $opt{'value'}; +my $contactnum = $curr_value ? $curr_value : '0'; my $onchange = ''; if ( $opt{'onchange'} ) { @@ -171,6 +176,7 @@ unless ($opt{'for_prospect'}) { $label{'invoice_dest'} = 'Send invoices'; $label{'message_dest'} = 'Send messages'; $label{'selfservice_access'} = 'Self-service'; + $label{'password'} = 'Password'; } my $first = 0; @@ -185,7 +191,21 @@ $label{'comment'} = 'Comment'; my @fields = $opt{'name_only'} ? qw( first last ) : keys %label; -my $pwd_change_label = 'Change Password'; -$pwd_change_label = 'Setup Password' unless $contact->_password; +my $submitid = $opt{'submit_id'} ? $opt{'submit_id'} : 'submit'; + +my $js = qq( + add_password_validation('changepw$id\_password', '$submitid', '', '$contactnum'); + + var selfService = document.getElementById("$id\_selfservice_access").value; + + if (selfService !== "Y") { document.getElementById("changepw$id\_password").disabled = 'true'; } + document.getElementById("$id\_selfservice_access").onchange = function() { + if (this.value == "P" || this.value == "E" || this.value =="Y") { + document.getElementById("changepw$id\_password").disabled = ''; + } + else { document.getElementById("changepw$id\_password").disabled = 'true'; } + return false; + } +); </%init> diff --git a/httemplate/elements/cust_payby_new.html b/httemplate/elements/cust_payby_new.html new file mode 100644 index 000000000..8b1d93d59 --- /dev/null +++ b/httemplate/elements/cust_payby_new.html @@ -0,0 +1,217 @@ +% my $auto = 0; +% if ( $payby eq 'CARD' ) { +% +% my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' ); +% my $payname = $cust_main->first. ' '. $cust_main->getfield('last'); +% my $location = $cust_main->bill_location; + <TR> + <TH ALIGN="right"><% mt('Card number') |h %></TH> + <TD COLSPAN=7> + <TABLE> + <TR> + <TD> + <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD> + <TH><% mt('Exp.') |h %></TH> + <TD> + <SELECT NAME="month"> +% for my $mm ( map{ sprintf( '%02d', $_ ) } (1..12) ) { + <OPTION value="<% $mm %>"<% $mm == $month ? ' SELECTED' : '' %>><% $mm %></OPTION> +% } + </SELECT> + </TD> + <TD> / </TD> + <TD> + <SELECT NAME="year"> +% my @a = localtime; for my $yyyy ( $a[5]+1900 .. $a[5]+1915 ) { + <OPTION value="<% $yyyy %>"<% $yyyy == $year ? ' SELECTED' : '' %>><% $yyyy %></OPTION> +% } + </SELECT> + </TD> + </TR> + </TABLE> + </TD> + </TR> + <TR> + <TH ALIGN="right"><% mt('CVV2') |h %></TH> + <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4> + (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;"><% mt('help') |h %></A>) + </TD> + </TR> + <TR> + <TH ALIGN="right"><% mt('Exact name on card') |h %></TH> + <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD> + </TR> + + <& /elements/location.html, + 'object' => $location, + 'no_asterisks' => 1, + 'address1_label' => emt('Card billing address'), + &> + +% } elsif ( $payby eq 'CHEK' ) { +% +% my( $account, $aba, $branch, $payname, $ss, $paytype, $paystate, +% $stateid, $stateid_state ) +% = ( '', '', '', '', '', '', '', '', '' ); +% +% #false laziness w/{edit,view}/cust_main/billing.html +% my $routing_label = $conf->config('echeck-country') eq 'US' +% ? 'ABA/Routing number' +% : 'Routing number'; +% my $routing_size = $conf->config('echeck-country') eq 'CA' ? 4 : 10; +% my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9; + + <INPUT TYPE="hidden" NAME="month" VALUE="12"> + <INPUT TYPE="hidden" NAME="year" VALUE="2037"> + <TR> + <TD ALIGN="right"><% mt('Account number') |h %></TD> + <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$account%>"></TD> + <TD ALIGN="right"><% mt('Type') |h %></TD> + <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } FS::cust_payby->paytypes) %></SELECT></TD> + </TR> + <TR> + <TD ALIGN="right"><% mt($routing_label) |h %></TD> + <TD> + <INPUT TYPE="text" SIZE="<% $routing_size %>" MAXLENGTH="<% $routing_maxlength %>" NAME="payinfo2" VALUE="<%$aba%>"> + (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;"><% mt('help') |h %></A>) + </TD> + </TR> +% if ( $conf->config('echeck-country') eq 'CA' ) { + <TR> + <TD ALIGN="right"><% mt('Branch number') |h %></TD> + <TD> + <INPUT TYPE="text" NAME="payinfo3" VALUE="<%$branch%>" SIZE=6 MAXLENGTH=5> + </TD> + </TR> +% } + <TR> + <TD ALIGN="right"><% mt('Bank name') |h %></TD> + <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD> + </TR> + +% if ( $conf->exists('show_bankstate') ) { + <TR> + <TD ALIGN="right"><% mt('Bank state') |h %></TD> + <TD><& /elements/select-state.html, + 'disable_empty' => 0, + 'empty_label' => emt('(choose)'), + 'state' => $paystate, + 'country' => $cust_main->country, + 'prefix' => 'pay', + &> + </TD> + </TR> +% } else { + <INPUT TYPE="hidden" NAME="paystate" VALUE="<% $paystate %>"> +% } + +% if ( $conf->exists('show_ss') ) { + <TR> + <TD ALIGN="right"> + <% mt('Account holder') |h %><BR> + <% mt('Social security or tax ID #') |h %> + </TD> + <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $ss %>"></TD> + </TR> +% } else { + <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"></TD> +% } + +% if ( $conf->exists('show_stateid') ) { + <TR> + <TD ALIGN="right"> + <% mt('Account holder') |h %><BR> + <% mt("Driver's license or state ID #") |h %> + </TD> + <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>"></TD> + <TD ALIGN="right"><% mt('State') |h %></TD> + <TD><& /elements/select-state.html, + 'disable_empty' => 0, + 'empty_label' => emt('(choose)'), + 'state' => $stateid_state, + 'country' => $cust_main->country, + 'prefix' => 'stateid_', + &> + </TD> + </TR> +% } else { + <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>"> + <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $stateid_state %>"> +% } + +% } #end CARD/CHEK-specific section + + +<TR> + <TD COLSPAN=8> + <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1"> + <% mt('Remember this information') |h %> + </TD> +</TR> + +<TR> + <TD COLSPAN=8> + <INPUT TYPE="checkbox"<% $auto ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }"> + <% mt("Charge future payments to this [_1] automatically",$type{$payby}) |h %> +% if ( @cust_payby ) { + <% mt('as') |h %> + <SELECT NAME="weight"> +% for ( 1 .. 1+scalar(grep { $_->payby =~ /^(CARD|CHEK)$/ } @cust_payby) ) { + <OPTION VALUE="<%$_%>"><% mt( $weight{$_} ) |h %></OPTION> +% } + </SELECT> +% } else { + <INPUT TYPE="hidden" NAME="weight" VALUE="1"> +% } + </TD> +</TR> + +<%once> + +my %weight = ( + 1 => 'Primary', + 2 => 'Secondary', + 3 => 'Tertiary', + 4 => 'Fourth', + 5 => 'Fifth', + 6 => 'Sixth', + 7 => 'Seventh', +); + +</%once> + +<%init> + +my %opt = @_; + +my @cust_payby = @{$opt{cust_payby}}; + +my %type = ( 'CARD' => 'credit card', + 'CHEK' => 'electronic check (ACH)', + ); + +$cgi->param('payby') =~ /^(CARD|CHEK)$/ + or die "unknown payby ". $cgi->param('payby'); +my $payby = $1; + +$cgi->param('custnum') =~ /^(\d+)$/ + or die "illegal custnum ". $cgi->param('custnum'); +my $custnum = $1; + +my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } ); +die "unknown custnum $custnum" unless $cust_main; + +my $balance = $cust_main->balance; + +my $payinfo = ''; + +my $conf = new FS::Conf; + +#false laziness w/selfservice make_payment.html shortcut for one-country +my %states = map { $_->state => 1 } + qsearch('cust_main_county', { + 'country' => $conf->config('countrydefault') || 'US' + } ); +my @states = sort { $a cmp $b } keys %states; + +</%init>
\ No newline at end of file diff --git a/httemplate/elements/header.html b/httemplate/elements/header.html index c6b10e301..6df45fb07 100644 --- a/httemplate/elements/header.html +++ b/httemplate/elements/header.html @@ -4,3 +4,4 @@ % } else { <& header-full.html, @_ &> % } +<& /misc/edge_browser_check-header.html &> diff --git a/httemplate/elements/link-replace_element_text.html b/httemplate/elements/link-replace_element_text.html new file mode 100644 index 000000000..8e611954c --- /dev/null +++ b/httemplate/elements/link-replace_element_text.html @@ -0,0 +1,45 @@ +<%doc> + +Display a link with javascript to replace text within a element. + +Usage: + +<& /elements/link-replace_element_text.html, { + target_id => 'input_id', + replace_text => 'hello', + + element_type => 'input', # Uses jquery val() method to replace text + element_type => 'div', # Uses jquery text() method to replace text + + href => ... + style => ... + class => ... + } +&> + +</%doc> +<a href="<% $param{href} %>" + style="<% $param{style} %>" +% if ($param{class}) { + class="<% $param{class} %>" +% } + onClick="$('#<% $param{target_id} %>').<% $param{jmethod} %>('<% $param{replace_text} |h %>');">◁</a> +<%init> + +die "template call requires a parameter hashref" unless ref $_[0]; + +# Defaults that can be overridden in param hashref +my %param = ( + target_id => 'SPECIFY_AN_INPUT_ELEMENT_ID', + replace_text => 'REPLACEMENT_TEXT_FOR_INPUT_ELEMENT', + element_type => 'input', + + link_text => '%#x25C1;', # ◁ + href => 'javascript:void(0)', + style => 'text-decoration:none;', + class => undef, + + %{ $_[0] }, +); +$param{jmethod} = $param{element_type} eq 'input' ? 'val' : 'text'; +</%init> diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index eb065b668..cae0cdbfb 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -418,7 +418,9 @@ if( $curuser->access_right('Financial reports') ) { $report_financial{'Customer Accounting Summary'} = [ $fsurl.'search/report_customer_accounting_summary.html', 'Customer accounting summary report' ]; - $report_financial{'Upcoming Auto-Bill Transactions'} = [ $fsurl.'search/report_future_autobill.html', 'Upcoming auto-bill transactions' ]; + if ( my $report_title = FS::cust_payby->future_autobill_report_title ) { + $report_financial{$report_title} = [ $fsurl.'search/report_future_autobill.html', "$report_title for customers with automatic payment methods (by date)" ]; + } } elsif($curuser->access_right('Receivables report')) { diff --git a/httemplate/elements/polygon.html b/httemplate/elements/polygon.html index 469ae7f13..a0d380bb8 100644 --- a/httemplate/elements/polygon.html +++ b/httemplate/elements/polygon.html @@ -5,12 +5,15 @@ my $id = $opt{'id'} || $opt{'field'}; my $div_id = "div_$id"; my $vertices_json = $opt{'curr_value'} || '[]'; + +my $apikey = FS::Conf->new->config('google_maps_api_key'); + </%init> <& hidden.html, %opt &> <div id="<% $div_id %>" style="height: 600px; width: 600px"></div> <div id="<% $div_id %>_hint" style="width: 100%; border: 2px solid black; text-align: center; box-sizing: border-box; padding: 4px"> </div> -<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing&v=3.22"></script> +<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing&v=3.22<% $apikey ? "&key=$apikey" : '' %>"></script> <script> var map; var drawingManager; diff --git a/httemplate/elements/random_pass.html b/httemplate/elements/random_pass.html index 778aa20e6..3a632b9af 100644 --- a/httemplate/elements/random_pass.html +++ b/httemplate/elements/random_pass.html @@ -19,6 +19,7 @@ function <% $id %>randomPass() { for(var j, x, i = pass.length; i; j = Math.floor(Math.random() * i), x = pass[--i], pass[i] = pass[j], pass[j] = x); pass = pass.join(''); document.getElementById('<% $id %>').value = pass; + document.getElementById('<% $id %>_result').innerHTML = '<IMG SRC="<% $p %>images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em"> <SPAN STYLE="color: green;">Password valid!</SPAN>'; % if ($submitid) { document.getElementById('<% $submitid %>').disabled = false; % } diff --git a/httemplate/elements/select-country.html b/httemplate/elements/select-country.html index c98147907..286826752 100644 --- a/httemplate/elements/select-country.html +++ b/httemplate/elements/select-country.html @@ -91,15 +91,13 @@ Example: > % unless ( $opt{'disable_empty'} ) { - <OPTION VALUE=""><% $opt{'empty_label'} || '(all)' %> + <OPTION VALUE=""><% $opt{'empty_label'} || '(all)' %></OPTION> % } % foreach my $country ( @all_countries ) { - - <OPTION VALUE="<% $country |h %>" - <% $country eq $opt{'country'} ? ' SELECTED' : '' %> - ><% FS::geocode_Mixin->code2country($country). " ($country)" %> - + <OPTION VALUE="<% $country |h %>"<% $country eq $opt{'country'} ? ' SELECTED' : '' %>> + <% FS::geocode_Mixin->code2country($country). " ($country)" |h %> + </OPTION> % } </SELECT> diff --git a/httemplate/elements/select-month_year.html b/httemplate/elements/select-month_year.html index 62c10b15f..406c13b21 100644 --- a/httemplate/elements/select-month_year.html +++ b/httemplate/elements/select-month_year.html @@ -3,16 +3,15 @@ <% $empty ? '<OPTION VALUE="">' : '' %> % foreach ( 1 .. 12 ) { - <OPTION<% $_ == $mon ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $mon[$_-1] %> + <OPTION<% $_ == $mon ? ' SELECTED' : '' %> VALUE="<% sprintf('%02d', $_) %>"><% $mon[$_-1] %></OPTION> % } - </SELECT>/<SELECT NAME="<% $prefix %>_year" SIZE="1" <% $disabled%>> <% $empty ? '<OPTION VALUE="">' : '' %> % for ( $start_year .. $end_year ) { - <OPTION<% $_ == $year ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $_ %> + <OPTION<% $_ == $year ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $_ %></OPTION> % } </SELECT> diff --git a/httemplate/elements/select-state.html b/httemplate/elements/select-state.html index 3fb559734..8db157b92 100644 --- a/httemplate/elements/select-state.html +++ b/httemplate/elements/select-state.html @@ -27,16 +27,13 @@ Example: > % unless ( $opt{'disable_empty'} ) { - <OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty_label} %> + <OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty_label} %></OPTION> % } % foreach my $state ( keys %states ) { - - <OPTION VALUE="<% $state |h %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' |h %> - + <OPTION VALUE="<% $state |h %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' |h %></OPTION> % } - </SELECT> <%init> diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index a52fdfaaa..d86b7ee43 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -83,11 +83,11 @@ Example: % || ( $value eq $pre_opt ); <OPTION VALUE="<% $pre_opt %>" <% $selected ? 'SELECTED' : '' %> - ><% $pre_label %> + ><% $pre_label %></OPTION> % } % unless ( $opt{'multiple'} || $opt{'disable_empty'} ) { - <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %> + <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %></OPTION> % } % foreach my $record ( @@ -118,7 +118,7 @@ Example: ? &{ $opt{'label_callback'} }( $record ) : $record->$name_col() |h - %> + %></OPTION> % } % while ( @post_options ) { @@ -128,7 +128,7 @@ Example: % || ( $value eq $post_opt ); <OPTION VALUE="<% $post_opt %>" <% $selected ? 'SELECTED' : '' %> - ><% $post_label %> + ><% $post_label %></OPTION> % } </SELECT> diff --git a/httemplate/elements/tr-amount_fee.html b/httemplate/elements/tr-amount_fee.html index 9c13f5952..a84fef6ec 100644 --- a/httemplate/elements/tr-amount_fee.html +++ b/httemplate/elements/tr-amount_fee.html @@ -1,6 +1,6 @@ - <TR ID="payment_amount_row" <% $opt{'row_style'} %>> + <TR ID="payment_amount_row"> <TH ALIGN="right"><% mt('Payment amount') |h %></TH> - <TD COLSPAN=7> + <TD> <TABLE><TR><TD BGCOLOR="#ffffff"> <% $money_char %><INPUT NAME = "amount" ID = "amount" @@ -8,7 +8,7 @@ VALUE = "<% $amount %>" SIZE = 8 STYLE = "text-align:right;" -% if ( $fee ) { +% if ( $fee || $surcharge_percentage || $surcharge_flatfee ) { onChange = "amount_changed(this)" onKeyDown = "amount_changed(this)" onKeyUp = "amount_changed(this)" @@ -28,17 +28,23 @@ <FONT SIZE="+1"><% length($amount) ? $money_char. sprintf('%.2f', ($fee_display eq 'add') ? $amount + $fee : $amount - $fee ) : '' %> <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %></FONT> % } +% if ( $surcharge_percentage || $surcharge_flatfee ) { + <INPUT TYPE="hidden" NAME="surcharge_percentage" ID="surcharge_percentage" VALUE="<% $surcharge_percentage %>"> + <INPUT TYPE="hidden" NAME="surcharge_flatfee" ID="surcharge_flatfee" VALUE="<% $surcharge_flatfee %>"> + </TD><TD ID="ajax_surcharge_cell" BGCOLOR="#dddddd" STYLE="border:1px solid blue"> + <FONT SIZE="+1">A credit card surcharge of <% $money_char. sprintf('%.2f', $surcharge) %> is included in this payment</FONT> +% } </TD></TR></TABLE> </TD> </TR> -% if ( $fee ) { +% if ($fee || $surcharge_percentage || $surcharge_flatfee ) { <SCRIPT TYPE="text/javascript"> function amount_changed(what) { - +% if ( $fee ) { var total = ''; if ( what.value.length ) { total = parseFloat(what.value) <% $fee_op %> <% $fee %>; @@ -48,6 +54,13 @@ var total_cell = document.getElementById('ajax_total_cell'); total_cell.innerHTML = '<FONT SIZE="+1">' + total + ' <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %></FONT>'; +% } + +% if ( $surcharge_percentage || $surcharge_flatfee ) { + var surcharge_cell = document.getElementById('ajax_surcharge_cell'); + var surcharge = ((what.value - <% $surcharge_flatfee %>) * <% $surcharge_percentage %>) + <% $surcharge_flatfee %>; + surcharge_cell.innerHTML = '<FONT SIZE="+1">A credit card surcharge of ' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; +% } } @@ -66,6 +79,9 @@ my $fee = ''; my $fee_pkg = ''; my $fee_display = ''; my $fee_op = ''; +my $surcharge = ''; +my $surcharge_percentage = 0; +my $surcharge_flatfee = 0; if ( $opt{'process-pkgpart'} and ! $opt{'process-skip_first'} || $opt{'num_payments'} @@ -86,13 +102,21 @@ if ( $opt{'process-pkgpart'} } my $amount = $opt{'amount'}; -if ( $amount > 0 ) { +if ( $amount ) { + # probably should not happen, but will prevent surcharge being applied to negative due amounts + unless ($amount > 0) { $amount = 0; } + $amount += $fee if $fee && $fee_display eq 'subtract'; #&{ $opt{post_fee_callback} }( \$amount ) if $opt{post_fee_callback}; - $amount += $amount * $opt{'surcharge_percentage'}/100 - if $opt{'surcharge_percentage'} > 0; + + $surcharge_percentage = $opt{'surcharge_percentage'}/100 if $opt{'surcharge_percentage'} > 0; + $surcharge_flatfee = $opt{'surcharge_flatfee'} if $opt{'surcharge_flatfee'} > 0; + $surcharge = $amount * $surcharge_percentage if $surcharge_percentage > 0; + $surcharge += $surcharge_flatfee if ( $surcharge_flatfee > 0 && $amount > 0 ); + + $amount += $surcharge; $amount = sprintf("%.2f", $amount); } diff --git a/httemplate/elements/tr-select-cust_payby.html b/httemplate/elements/tr-select-cust_payby.html index e2b2e09d1..e5ace4d39 100644 --- a/httemplate/elements/tr-select-cust_payby.html +++ b/httemplate/elements/tr-select-cust_payby.html @@ -1,4 +1,4 @@ -% if ( scalar(@{ $opt{'cust_payby'} }) == 0 ) { +% if ( scalar(@{ $opt{'cust_payby'} }) == 0 ) { <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'custpaybynum' %>" VALUE=""> diff --git a/httemplate/elements/tr-select-invoice.html b/httemplate/elements/tr-select-invoice.html index 3728d348d..d35813fc5 100644 --- a/httemplate/elements/tr-select-invoice.html +++ b/httemplate/elements/tr-select-invoice.html @@ -5,7 +5,11 @@ Example: include( '/elements/tr-select-invoice.html', #opt - most get used in /elements/tr-amount-fee - 'custnum' => 4, # customer number, + 'cust_main' => $cust_main, # cust_main, + 'status' => 'open' # type of invoices to show. Possible values are: + # open - shows only open invoices + # void - shows only voided invoices + # all - shows all invoices, this is default if no status is set. 'prefix' => 'pre', # prefix to fields and row ID's ) @@ -13,31 +17,35 @@ Example: <TR ID="invoice_row" STYLE="display:none;"> <TH ALIGN="right"><% mt('Open invoices') |h %></TH> - <TD COLSPAN=7> + <TD> <SELECT ID = "<% $opt{prefix} %>invoice" NAME = "<% $opt{prefix} %>invoice" onChange = "<% $opt{prefix} %>invoice_select_changed(this)" > <OPTION VALUE="select">Select an invoice to pay</OPTION> -% foreach my $record (@records) { +% foreach my $record (@invoices) { % my $read_date = time2str("%b %o, %Y", $record->_date); - <OPTION VALUE="<% $record->charged %>"><% $record->invnum %> (<% $read_date %>) - <% $record->charged %></OPTION> +% $hidden .= '<INPUT TYPE="hidden" ID="inv'.$record->invnum.'" NAME="inv'.$record->invnum.'" VALUE="'.$record->owed.'">'; + <OPTION VALUE="<% $record->invnum %>"><% $record->invnum %> (<% $read_date %>) - <% $record->owed %></OPTION> % } - </SELECT> + </SELECT> + + <% $hidden %> + </TD> </TR> <%init> my %opt = @_; +my $status = $opt{'status'} ? $opt{'status'} : 'all'; +my $hidden; -my @records = qsearch( { - 'select' => '*', - 'table' => 'cust_bill', - 'hashref' => { 'custnum' => $opt{custnum} }, - 'order_by' => 'ORDER BY _date', -}); +my @invoices; +if ($status eq "all") { @invoices = $opt{'cust_main'}->cust_bill; } +elsif ($status eq "open") { @invoices = $opt{'cust_main'}->open_cust_bill; } +elsif ($status eq "void") { @invoices = $opt{'cust_main'}->cust_bill_void; } </%init> diff --git a/httemplate/elements/tr-select-payment_options.html b/httemplate/elements/tr-select-payment_options.html index 2304c22d0..f86f3edfd 100644 --- a/httemplate/elements/tr-select-payment_options.html +++ b/httemplate/elements/tr-select-payment_options.html @@ -5,9 +5,9 @@ Example: include( '/elements/tr-select-payment_options.html', #opt - most get used in /elements/tr-amount-fee - 'custnum' => 4, # customer number needed for selecting invoices + 'cust_main' => $cust_main, # custmain needed for selecting invoices 'prefix' => 'pre', # prefix to fields and row ID's - 'amount' => 1, # payment amount + 'amount' => 1, # payment amount optional, if no amount will grab balance due from cust_main 'process-pkgpart' => scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)), 'process-display' => scalar($conf->config('manual_process-display')), 'process-skip_first' => $conf->exists('manual_process-skip_first'), @@ -17,70 +17,139 @@ Example: ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum)) : 0 ), + 'surcharge_flatfee' => + ( $payby eq 'CARD' + ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum)) + : 0 + ), ) </%doc> - <TR STYLE="display:block"> - <TH ALIGN="right"><% mt('Payment options') |h %></TH> - <TD COLSPAN=7> + <TR ID="payment_option_row"> + <TH ALIGN="right"><% mt('What would you like to pay') |h %></TH> + <TD> <SELECT ID = "<% $opt{prefix} %>payment_option" NAME = "<% $opt{prefix} %>payment_option" onChange = "<% $opt{prefix} %>payment_option_changed(this)" <% $opt{disabled} %> - > - <OPTION VALUE="select">Select payment option</OPTION> - <OPTION VALUE="<% $opt{amount} %>">Pay full balance</OPTION> - <OPTION VALUE="invoice">Pay specific invoice</OPTION> - <OPTION VALUE="">Pay specific amount</OPTION> - </SELECT> + > + <OPTION VALUE="select">Select the amount you would like to pay</OPTION> + <% ($amount > 0) ? '<OPTION VALUE="'.$amount.'">Pay full balance</OPTION>' : '' %> + <% (@open_invoices) ? '<OPTION VALUE="invoice">Pay specific invoice</OPTION>' : '' %> + <OPTION VALUE="specific">Pay specific amount</OPTION> + </SELECT> </TD> </TR> <& /elements/tr-select-invoice.html, - 'custnum' => $opt{custnum}, - 'prefix' => $opt{prefix}, + 'cust_main' => $cust_main, + 'status' => 'open', + 'prefix' => $opt{prefix}, &> <& /elements/tr-amount_fee.html, - 'row_style' => 'STYLE="display:none;"', + 'amount' => $amount, + 'custnum' => $custnum, %opt &> <SCRIPT TYPE="text/javascript"> + $('#payment_option_row').<% $payment_option_row %>(); + $('#payment_amount_row').<% $payment_amount_row %>(); + + if($('#payment_amount_row').is(':visible')) { + var surcharge; + var amount = document.getElementById('amount').value; + + if ((document.getElementById('surcharge_percentage') || document.getElementById('surcharge_flatfee')) && amount > 0) { + surcharge = (+amount * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value; + } + else { surcharge = 0; } + if (document.getElementById('ajax_surcharge_cell')) { + document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; + } + } + function <% $opt{prefix} %>payment_option_changed(what) { + var surcharge; + if (document.getElementById('surcharge_percentage') || document.getElementById('surcharge_flatfee')) { + surcharge = (+what.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value; + } + else { surcharge = 0; } + var amount = +what.value + +surcharge; + document.getElementById('amount').disabled = true; + if ( what.value == 'select' ) { - document.getElementById('payment_amount_row').style.display = 'none'; - document.getElementById('invoice_row').style.display = 'none'; - document.getElementById('<% $opt{prefix} %>invoice').value = 'select'; - document.getElementById('amount').value = ''; + $('#payment_amount_row').hide(); + $('#invoice_row').hide(); + $("#<% $opt{prefix} %>invoice").val('select'); + $('#amount').val(''); } else if ( what.value == 'invoice' ) { - document.getElementById('payment_amount_row').style.display = 'none'; - document.getElementById('invoice_row').style.display = 'block'; - document.getElementById('amount').value = ''; + $('#payment_amount_row').hide(); + $('#invoice_row').show(); + $('#apply_box_row').hide(); + $('#apply_box').val('yes'); + $("#<% $opt{prefix} %>payment_option option[value='select']").remove(); + var selectExists = ($("#<% $opt{prefix} %>invoice option[value='select']").length > 0); + if(!selectExists) { + $("#<% $opt{prefix} %>invoice").prepend("<option value='select'>Select an invoice to pay</option>"); + $("#<% $opt{prefix} %>invoice").val($('option:first', "#<% $opt{prefix} %>invoice").val()); + } + $('#amount').val(''); + } + else if ( what.value == 'specific' ) { + $('#payment_amount_row').show(); + $('#invoice_row').hide(); + $('#apply_box_row').show(); + $("#<% $opt{prefix} %>payment_option option[value='select']").remove(); + $('#amount').val('0.00'); + document.getElementById('amount').disabled = false; + if (document.getElementById('ajax_surcharge_cell')) { + document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>0.00 is included in this payment</FONT>'; + } } else { - document.getElementById('payment_amount_row').style.display = 'block'; - document.getElementById('invoice_row').style.display = 'none'; - document.getElementById('<% $opt{prefix} %>invoice').value = 'select'; - document.getElementById('amount').value = what.value; + $('#payment_amount_row').show(); + $('#invoice_row').hide(); + $('#apply_box_row').hide(); + $('#apply_box').val('yes'); + $("#<% $opt{prefix} %>payment_option option[value='select']").remove(); + $('#amount').val(amount.toFixed(2)); + document.getElementById('amount').disabled = true; + if (document.getElementById('ajax_surcharge_cell')) { + document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; + } } } function <% $opt{prefix} %>invoice_select_changed(what) { + var surcharge; + var invdue = document.getElementById("<% $opt{prefix} %>inv" + what.value); + if (document.getElementById('surcharge_percentage') || document.getElementById('surcharge_flatfee')) { + surcharge = (+invdue.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value; + } + else { surcharge = 0; } + var amount = +invdue.value + +surcharge; + if ( what.value == 'select' ) { - document.getElementById('payment_amount_row').style.display = 'none'; - document.getElementById('amount').value = ''; + $('#payment_amount_row').hide(); + $('#amount').val(''); } else { - document.getElementById('payment_amount_row').style.display = 'block'; - document.getElementById('amount').value = what.value; + $('#payment_amount_row').show(); + $("#<% $opt{prefix} %>invoice option[value='select']").remove(); + $('#amount').val(amount.toFixed(2)); + document.getElementById('amount').disabled = true; + if (document.getElementById('ajax_surcharge_cell')) { + document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; + } } } @@ -91,4 +160,21 @@ Example: my %opt = @_; +my $cust_main = $opt{'cust_main'}; +my $amount = $opt{'amount'} ? $opt{'amount'} : $cust_main->balance; +my $custnum = $cust_main->custnum; + +my @open_invoices = $cust_main->open_cust_bill; + +my $payment_option_row = "show"; +my $payment_amount_row = "hide"; + +unless ($amount > 0 && @open_invoices) { + $payment_option_row = "hide"; + $payment_amount_row = "show"; +} + +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; + </%init>
\ No newline at end of file diff --git a/httemplate/elements/tr-select-router_block_ip.html b/httemplate/elements/tr-select-router_block_ip.html index 2aa715e29..72640d3d5 100644 --- a/httemplate/elements/tr-select-router_block_ip.html +++ b/httemplate/elements/tr-select-router_block_ip.html @@ -2,34 +2,110 @@ var manual_addr_routernum = <% encode_json(\%manual_addr_routernum) %>; var ip_addr_curr_value = <% $opt{'ip_addr'} |js_string %>; var blocknum_curr_value = <% $opt{'blocknum'} |js_string %>; -function update_ip_addr(obj, i) { - var routernum = document.getElementById('router_select_0').value; - var select_blocknum = document.getElementById('router_select_1'); - var blocknum = select_blocknum.value; - var input_ip_addr = document.getElementById('input_ip_addr'); + +function update_ip_addr() { + var routernum = $('#router_select_0').val() || ""; + var blocknum = $('#router_select_1').val() || ""; + var e_input_ip_addr = $('#input_ip_addr'); + var e_router_select_1 = $('#router_select_1'); + + <% # Is block is automatically selected for this router? %> if ( manual_addr_routernum[routernum] == 'Y' ) { -%# hide block selection and default ip address to its previous value - select_blocknum.style.display = 'none'; - input_ip_addr.value = ip_addr_curr_value; - } - else { -%# the reverse - select_blocknum.style.display = ''; -%# default ip address to null, unless the router/block are set to the -%# previous value, in which case default it to current value + show_ip_input(); + hide_ip_select(); + e_router_select_1.hide(); + e_input_ip_addr.val( ip_addr_curr_value ); + } else { + e_router_select_1.show(); + e_input_ip_addr.attr('placeholder', <% mt('(automatic)') | js_string %> ); if ( routernum == router_curr_values[0] && - blocknum == router_curr_values[1] ) { - input_ip_addr.value = ip_addr_curr_value; + blocknum == router_curr_values[1] ) { + e_input_ip_addr.val( ip_addr_curr_value ); } else { - input_ip_addr.value = <% mt('(automatic)') |js_string %>; + e_input_ip_addr.val(''); } } + show_or_hide_toggle_ip(); + populate_ip_select(); +} + +function toggle_ip_input() { + if ( $('#input_ip_addr').is(':hidden') ) { + show_ip_input(); + } else { + show_ip_select(); + } +} + +function show_ip_input() { + $('#input_ip_addr').show(); + $('#select_ip_addr').hide(); + depopulate_ip_select(); +} + +function show_ip_select() { + var e_input_ip_addr = $('#input_ip_addr'); + var e_select_ip_addr = $('#select_ip_addr'); + + e_select_ip_addr.width( e_input_ip_addr.width() ); + e_input_ip_addr.hide(); + e_select_ip_addr.show(); + populate_ip_select(); +} + +function populate_ip_select() { + depopulate_ip_select(); + var e = $('#select_ip_addr'); + var blocknum = $('#router_select_1').val(); + + var opts = [ '<option value="">loading...</option>' ]; + e.html(opts.join('')); + +% if ( $opt{ip_addr} ) { + opts = [ + '<option value="<% $opt{ip_addr} |h %>"><% $opt{ip_addr} |h %></option>', + '<option value="">-----------</option>' + ]; +% } else { + opts = [ '<option value=""><% mt('(automatic)') |h %></option>' ]; +% } + if ( blocknum && $.isNumeric(blocknum) && ! e.is(':hidden')) { + $.getJSON( + '<% $p %>misc/xmlhttp-free_addresses_in_block.json.html', + {blocknum: blocknum}, + function(ip_json) { + $.each( ip_json, function(idx, val) { + opts.push( + '<option' + (val == ip_addr_curr_value ? 'selected' : '') + '>' + + val + + '</option>' + ); + }); + e.html(opts.join('')); + } + ); + } } -function clearhint_ip_addr (what) { - if ( what.value == <% mt('(automatic)') |js_string %> ) - what.value = ''; + +function depopulate_ip_select() { + $('#select_ip_addr').children().remove(); } + +function propogate_ip_select() { + $('#input_ip_addr').val( $('#select_ip_addr').val() ); +} + +function show_or_hide_toggle_ip() { + if ( $('#router_select_1').val() ) { + $('#toggle_ip').show(); + } else { + show_ip_input(); + $('#toggle_ip').hide(); + } +} + </script> + <& /elements/tr-td-label.html, label => ($opt{'label'} || 'Router'), required => $opt{'required'} &> <td> <& /elements/select-tiered.html, prefix => 'router_', tiers => [ @@ -58,14 +134,20 @@ function clearhint_ip_addr (what) { </td></tr> <& /elements/tr-td-label.html, label => ($opt{'ip_addr_label'} || 'IP address'), required => $opt{'ip_addr_required'} &> <td> -% #warn Dumper \%fixed; % if ( exists $fixed{$ip_field} ) { <input type="hidden" id="input_ip_addr" name="<% $ip_field %>" value="<% $opt{'ip_addr'} |h%>"><% $opt{'ip_addr'} || '' %> % } % else { - <input type="text" id="input_ip_addr" name="<% $ip_field %>" - value="<% $opt{'ip_addr'} |h%>" onfocus="clearhint_ip_addr(this)"> + <input type="text" + id="input_ip_addr" + name="<% $ip_field %>" + value="<% $opt{'ip_addr'} | h %>" + onfocus="clearhint_ip_addr(this)"> + <select id="select_ip_addr" style="display: none;" onChange='javascript:propogate_ip_select();'> + <option><% mt('loading') |h %>...</option> + </select> + <button type="button" onClick='javascript:toggle_ip_input();' id="toggle_ip" style="display: none;">▼</button> % } </td> </tr> <script type="text/javascript"> diff --git a/httemplate/elements/tr-tower_sectors.html b/httemplate/elements/tr-tower_sectors.html index 106fc76f6..8acedb84b 100644 --- a/httemplate/elements/tr-tower_sectors.html +++ b/httemplate/elements/tr-tower_sectors.html @@ -17,7 +17,7 @@ my $tabcounter = 0; my @fields = qw( sectorname ip_addr height freq_mhz direction width downtilt v_width db_high db_low sector_range - power line_loss antenna_gain hardware_typenum + power line_loss antenna_gain hardware_typenum up_rate_limit down_rate_limit ); my @sectors; @@ -291,6 +291,20 @@ $(function() { value="<% $sector->db_low |h %>"> <% emt('dB (low quality)') %> </div> + <p> + <label><% emt('Up Rate (Kbps)') %></label> + <input style="text-align: left" + id="<% $id %>_up_rate_limit" + name="<% $id %>_up_rate_limit" + value="<% $sector->up_rate_limit |h %>"> + </p> + <p> + <label><% emt('Down Rate (Kbps)') %></label> + <input style="text-align: left" + id="<% $id %>_down_rate_limit" + name="<% $id %>_down_rate_limit" + value="<% $sector->down_rate_limit |h %>"> + </p> </div> </%def> diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html index 4057f5d3f..6aada2fee 100644 --- a/httemplate/elements/validate_password.html +++ b/httemplate/elements/validate_password.html @@ -14,58 +14,10 @@ should be the input id plus '_result'. </%doc> -<& '/elements/xmlhttp.html', - 'url' => $p.'misc/xmlhttp-validate_password.html', - 'subs' => [ 'validate_password' ], - 'method' => 'POST', # important not to put passwords in url -&> -<SCRIPT> -function add_password_validation (fieldid, submitid) { - var inputfield = document.getElementById(fieldid); - inputfield.onkeydown = function(e) { - var key; - if (window.event) { key = window.event.keyCode; } - else { key = e.which; } // for ff browsers - // some browsers allow the enter key to submit a form even if the submit button is disabled - // below prevents enter key from submiting form if password has not been validated. - if (key == '13') { - var check = checkPasswordValidation(); - return check; - } - } - inputfield.onkeyup = function () { - var fieldid = this.id+'_result'; - var resultfield = document.getElementById(fieldid); - if (this.value) { - resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>'; - validate_password('fieldid',fieldid,'svcnum','<% $opt{'svcnum'} %>','contactnum','<% $opt{'contactnum'} %>','password',this.value, - function (result) { - result = JSON.parse(result); - var resultfield = document.getElementById(result.fieldid); - if (resultfield) { - var errorimg = '<IMG SRC="<% $p %>images/error.png" style="width: 1em; display: inline-block; padding-right: .5em">'; - var validimg = '<IMG SRC="<% $p %>images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em">'; - if (result.valid) { - resultfield.innerHTML = validimg+'<SPAN STYLE="color: green;">Password valid!</SPAN>'; - if (submitid){ document.getElementById(submitid).disabled = false; } - } else if (result.error) { - resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.error+'</SPAN>'; - if (submitid){ document.getElementById(submitid).disabled = true; } - } else { - result.syserror = result.syserror || 'Server error'; - resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.syserror+'</SPAN>'; - if (submitid){ document.getElementById(submitid).disabled = true; } - } - } - } - ); - } else { - resultfield.innerHTML = ''; - } - }; -} +<& '/elements/validate_password_js.html', %opt &> -add_password_validation('<% $opt{'fieldid'} %>', '<% $opt{'submitid'} %>'); +<SCRIPT> + add_password_validation('<% $opt{'fieldid'} %>', '<% $opt{'submitid'} %>', '<% $opt{'svcnum'} %>', '<% $opt{'contactnum'} %>'); </SCRIPT> <%init> diff --git a/httemplate/elements/validate_password_js.html b/httemplate/elements/validate_password_js.html new file mode 100644 index 000000000..64db0a97b --- /dev/null +++ b/httemplate/elements/validate_password_js.html @@ -0,0 +1,71 @@ +<%doc> + +JavaScript to perform password validation + + <& '/elements/validate_password_js.html', + contactnum => $contactnum, + svcnum => $svcnum + &> + +The ID of the input field can be anything; the ID of the DIV in which to display results +should be the input id plus '_result'. + +</%doc> + +<& '/elements/xmlhttp.html', + 'url' => $p.'misc/xmlhttp-validate_password.html', + 'subs' => [ 'validate_password' ], + 'method' => 'POST', # important not to put passwords in url +&> +<SCRIPT> +function add_password_validation (fieldid, submitid, svcnum, contactnum) { + var inputfield = document.getElementById(fieldid); + inputfield.onkeydown = function(e) { + var key; + if (window.event) { key = window.event.keyCode; } + else { key = e.which; } // for ff browsers + // some browsers allow the enter key to submit a form even if the submit button is disabled + // below prevents enter key from submiting form if password has not been validated. + if (key == '13') { + var check = checkPasswordValidation(fieldid); + return check; + } + } + inputfield.onkeyup = function () { + var fieldid = this.id+'_result'; + var resultfield = document.getElementById(fieldid); + if (this.value) { + resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>'; + validate_password('fieldid',fieldid,'svcnum','<% $opt{'svcnum'} %>','contactnum', contactnum,'password',this.value, + function (result) { + result = JSON.parse(result); + var resultfield = document.getElementById(result.fieldid); + if (resultfield) { + var errorimg = '<IMG SRC="<% $p %>images/error.png" style="width: 1em; display: inline-block; padding-right: .5em">'; + var validimg = '<IMG SRC="<% $p %>images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em">'; + if (result.valid) { + resultfield.innerHTML = validimg+'<SPAN STYLE="color: green;">Password valid!</SPAN>'; + if (submitid){ document.getElementById(submitid).disabled = false; } + } else if (result.error) { + resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.error+'</SPAN>'; + if (submitid){ document.getElementById(submitid).disabled = true; } + } else { + result.syserror = result.syserror || 'Server error'; + resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.syserror+'</SPAN>'; + if (submitid){ document.getElementById(submitid).disabled = true; } + } + } + } + ); + } else { + resultfield.innerHTML = ''; + if (submitid){ document.getElementById(submitid).disabled = false; } + } + }; +} + +</SCRIPT> + +<%init> +my %opt = @_; +</%init>
\ No newline at end of file diff --git a/httemplate/graph/cust_bill_pkg_discount.html b/httemplate/graph/cust_bill_pkg_discount.html index 5074aa35c..22327e05b 100644 --- a/httemplate/graph/cust_bill_pkg_discount.html +++ b/httemplate/graph/cust_bill_pkg_discount.html @@ -20,7 +20,10 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); +my $include_waived_setup = $cgi->param('include_waived_setup') || 0; + my $link = "${p}search/cust_bill_pkg_discount.html?"; +$link .= "include_waived_setup=Y&" if $include_waived_setup; my $bottom_link = $link; #XXX or virtual @@ -35,7 +38,8 @@ my $title = $sel_agent ? $sel_agent->agent.' ' : ''; $title .= 'Discount Overview'; -my $hue = 0; +#my $hue = 0; # Start with illegible yellow-on-white +my $hue = 255; # Start with red-on-white #my $hue_increment = 170; #my $hue_increment = 145; my $hue_increment = 125; @@ -56,7 +60,10 @@ foreach my $agent ( $sel_agent || qsearch('agent', { 'disabled' => '' } ) ) { #foreach my $pkg_class ( @pkg_class ) { - push @items, 'cust_bill_pkg_discount'; + push @items, + $include_waived_setup + ? 'cust_bill_pkg_discount_or_waived' + : 'cust_bill_pkg_discount'; push @labels, ( $sel_agent ? '' : $agent->agent.' ' ); diff --git a/httemplate/graph/report_cust_bill_pkg_discount.html b/httemplate/graph/report_cust_bill_pkg_discount.html index 36ad78252..094c652c7 100644 --- a/httemplate/graph/report_cust_bill_pkg_discount.html +++ b/httemplate/graph/report_cust_bill_pkg_discount.html @@ -19,6 +19,12 @@ 'disable_empty' => 0, &> + <& /elements/tr-checkbox.html, + label => 'Include waived setup fees:', + field => 'include_waived_setup', + value => 'Y', + &> + % # anything about line items, discounts or packages really % # otaker? % # package class? diff --git a/httemplate/misc/cust_pkg-import.html b/httemplate/misc/cust_pkg-import.html index 3b200e5f3..da242a28f 100644 --- a/httemplate/misc/cust_pkg-import.html +++ b/httemplate/misc/cust_pkg-import.html @@ -36,6 +36,7 @@ Import a file containing customer packages. <OPTION VALUE="svc_acct">Account service <OPTION VALUE="svc_acct-agent_custid">Account service with agent_custid <OPTION VALUE="svc_acct-locationnum">Account service with existing location + <OPTION VALUE="svc_broadband">Broadband service <OPTION VALUE="svc_phone">Phone service <OPTION VALUE="svc_phone-agent_custid">Phone service with agent_custid <OPTION VALUE="svc_phone-locationnum">Phone service with existing location @@ -105,6 +106,9 @@ Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets. <b>Account service with existing location</b> format has the following field order: <i>custnum<%$req%>, locationnum, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, username, _password, domsvc</i> <BR><BR> +<b>Broadband service</b> format has the following field order: <i>custnum<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, ip_addr<%$req%>, description, routernum, blocknum, sectornum, speed_up, speed_down</i> +<BR><BR> + <b>Phone service</b> format has the following field order: <i>custnum<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, countrycode, phonenum, sip_password, pin</i> <BR><BR> @@ -215,9 +219,9 @@ Field information: <li><i>quantity</i> - <li><i>setup_fee</i>: Including this fee implements per-customer custom pricing for this package, overriding package definition pricing + <li><i>setup_fee</i>: Including this implements per-customer custom pricing for this package, overriding package definition pricing - <li><i>recur_fee</i>: Including this fee implements per-customer custom pricing for this package, overriding package definition pricing + <li><i>recur_fee</i>: Including this implements per-customer custom pricing for this package, overriding package definition pricing <li><i>invoice_details</i>: Package invoice details (optionally, can include multiple lines of details separated by a vertical bar) diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi index c4bc37e93..c6a0b68c3 100644 --- a/httemplate/misc/download-batch.cgi +++ b/httemplate/misc/download-batch.cgi @@ -20,9 +20,18 @@ elsif ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) { $opt{'format'} = $1; } -my $pay_batch = qsearchs('pay_batch', { batchnum => $batchnum } ); +my $credit_transactions = "EXISTS (SELECT 1 FROM cust_pay_batch WHERE batchnum = $batchnum AND paycode = 'C') AS arecredits"; +my $pay_batch = qsearchs({ 'select' => "*, $credit_transactions", + 'table' => 'pay_batch', + 'hashref' => { batchnum => $batchnum }, + }); die "Batch not found: '$batchnum'" if !$pay_batch; +if ($pay_batch->{Hash}->{arecredits}) { + my $export_format = "FS::pay_batch::".$opt{'format'}; + die "This format can not handle refunds." unless $export_format->can('can_handle_credits'); +} + my $exporttext = $pay_batch->export_batch(%opt); unless ($exporttext) { http_header('Content-Type' => 'text/html' ); diff --git a/httemplate/misc/edge_browser_check-fail_notice.html b/httemplate/misc/edge_browser_check-fail_notice.html new file mode 100644 index 000000000..fb42ffe8e --- /dev/null +++ b/httemplate/misc/edge_browser_check-fail_notice.html @@ -0,0 +1,25 @@ +<& /elements/header.html, "Edge browser bug" &> + +<div id="edgebug" style="border: solid 1px #888; border-radius: 4px; margin: 5em; max-width: 400px; text-align: left; padding: 0 1em; background-color: #ffe; box-shadow: 2px 2px 4px"> + <div style="text-align: center; font-size: 3em; color: #933; text-shadow: 1px 1px 2px black;"> + ⚠ + </div> + <h4 style="border-bottom: solid 1px #888; margin: 1em 0; text-align: center;"> + Edge Browser Bug + </h4> + <p> + Your copy of Microsoft Edge has a data corrupting bug. + </p> + <p> + Microsoft fixed this bug with the <b>July RS4 Windows 10 Update</b>. + Please update your copy of Windows. + </p> + <p> + Alternatively, you may choose to use + <a href="https://mozilla.org/en-US/firefox/new/">Mozilla Firefox</a> + or <a href="https://chrome.google.com">Google Chrome</a>. They + are not affected by this bug. + </p> +</div> + +<& /elements/footer.html &>
\ No newline at end of file diff --git a/httemplate/misc/edge_browser_check-header.html b/httemplate/misc/edge_browser_check-header.html new file mode 100644 index 000000000..a88962be9 --- /dev/null +++ b/httemplate/misc/edge_browser_check-header.html @@ -0,0 +1,36 @@ +% if ( $force_redirect ) { + <script type="text/javascript"> + if ( <% $DEBUG %> || /Edge\/17\.17134/.test( navigator.userAgent )) { + if ( window.location.href.indexOf("fail_notice") == -1 ) { + window.location.href = "<% $fsurl %>misc/edge_browser_check-fail_notice.html"; + } + } + </script> +% } elsif ( $do_check ) { + <iframe id="edge_browser_check_iframe" style="display:none;"></iframe> + <script type="text/javascript"> + if ( <% $DEBUG %> || /Edge\/17\.17134/.test( navigator.userAgent )) { + $("#edge_browser_check_iframe").attr( + 'src', + '<% $fsurl %>misc/edge_browser_check-iframe.html?edge_browser_check=1' + ); + } + </script> +% } +<%init> +my $curuser = $FS::CurrentUser::CurrentUser; +my $session = $FS::CurrentUser::CurrentSession; +my $sessionkey = $session->sessionkey if $session; + +my $cgi = FS::UID::cgi(); +my $DEBUG = 0; + +my $do_check = 0; +$do_check = 1 + if $curuser + && !$cgi->param('edge_browser_check') + && $sessionkey + && $curuser->get_pref('edge_bug_vulnerable') ne $sessionkey; + +my $force_redirect = $curuser->get_pref('edge_bug_vulnerable') eq 'Y' ? 1 : 0; +</%init> diff --git a/httemplate/misc/edge_browser_check-iframe.html b/httemplate/misc/edge_browser_check-iframe.html new file mode 100644 index 000000000..61ae9a0bd --- /dev/null +++ b/httemplate/misc/edge_browser_check-iframe.html @@ -0,0 +1,34 @@ +<form id="canary-form" action="<% $fsurl %>misc/edge_browser_check-iframe.html" method="POST"> +<input type="text" id="canary-result" value="<% scalar $cgi->param('edge_browser_canary') %>"> +<select name="edge_browser_canary"> + <option>test + <option>test +</select> +<input id="canary-submit" type="submit"> +</form> + +<script type="text/javascript" src="<% $fsurl %>elements/jquery.js"></script> +<script type="text/javascript"> + $( function() { + if ( ! $("#canary-result").val() ) { + $("#canary-form").submit(); + } + }); +</script> + +<%init> +my $cgi = FS::UID::cgi(); +my $curuser = $FS::CurrentUser::CurrentUser; +my $session = $FS::CurrentUser::CurrentSession; +my $sessionkey = $session->sessionkey if $session; + +if ( $curuser ) { + my $canary = $cgi->param('edge_browser_canary'); + $curuser->set_pref( + 'edge_bug_vulnerable', + + $canary eq 'test' ? $sessionkey : 'Y', + ); +} + +</%init>
\ No newline at end of file diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index 5bfa29d70..77f5acd6a 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -13,8 +13,7 @@ <TABLE class="fsinnerbox"> <& /elements/tr-select-payment_options.html, - 'custnum' => $cust_main->custnum, - 'amount' => $balance, + 'cust_main' => $cust_main, 'process-pkgpart' => scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)), 'process-display' => scalar($conf->config('manual_process-display')), @@ -25,6 +24,11 @@ ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum)) : 0 ), + 'surcharge_flatfee' => + ( $payby eq 'CARD' + ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum)) + : 0 + ), &> % if ( $conf->exists('part_pkg-term_discounts') ) { @@ -97,6 +101,11 @@ function change_batch_checkbox () { $('#cust_payby').slideUp(); } } + + function enableAmountField() { + document.getElementById('amount').disabled = false; + } + </SCRIPT> % #can't quite handle CARD/CHEK on the same page yet, but very close @@ -130,186 +139,58 @@ function change_batch_checkbox () { > <TABLE class="fsinnerbox"> -% my $auto = 0; -% if ( $payby eq 'CARD' ) { -% -% my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' ); -% my $payname = $cust_main->first. ' '. $cust_main->getfield('last'); -% my $location = $cust_main->bill_location; - - <TR> - <TH ALIGN="right"><% mt('Card number') |h %></TH> - <TD COLSPAN=7> - <TABLE> - <TR> - <TD> - <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD> - <TH><% mt('Exp.') |h %></TH> - <TD> - <SELECT NAME="month"> -% for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) { - - <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %> -% } - - </SELECT> - </TD> - <TD> / </TD> - <TD> - <SELECT NAME="year"> -% my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) { - - <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %> -% } - - </SELECT> - </TD> - </TR> - </TABLE> - </TD> - </TR> - <TR> - <TH ALIGN="right"><% mt('CVV2') |h %></TH> - <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4> - (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;"><% mt('help') |h %></A>) - </TD> - </TR> - <TR> - <TH ALIGN="right"><% mt('Exact name on card') |h %></TH> - <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD> - </TR> - - <& /elements/location.html, - 'object' => $location, - 'no_asterisks' => 1, - 'address1_label' => emt('Card billing address'), - &> - -% } elsif ( $payby eq 'CHEK' ) { -% -% my( $account, $aba, $branch, $payname, $ss, $paytype, $paystate, -% $stateid, $stateid_state ) -% = ( '', '', '', '', '', '', '', '', '' ); -% -% #false laziness w/{edit,view}/cust_main/billing.html -% my $routing_label = $conf->config('echeck-country') eq 'US' -% ? 'ABA/Routing number' -% : 'Routing number'; -% my $routing_size = $conf->config('echeck-country') eq 'CA' ? 4 : 10; -% my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9; - - <INPUT TYPE="hidden" NAME="month" VALUE="12"> - <INPUT TYPE="hidden" NAME="year" VALUE="2037"> - <TR> - <TD ALIGN="right"><% mt('Account number') |h %></TD> - <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$account%>"></TD> - <TD ALIGN="right"><% mt('Type') |h %></TD> - <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } FS::cust_payby->paytypes) %></SELECT></TD> - </TR> - <TR> - <TD ALIGN="right"><% mt($routing_label) |h %></TD> - <TD> - <INPUT TYPE="text" SIZE="<% $routing_size %>" MAXLENGTH="<% $routing_maxlength %>" NAME="payinfo2" VALUE="<%$aba%>"> - (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;"><% mt('help') |h %></A>) - </TD> - </TR> -% if ( $conf->config('echeck-country') eq 'CA' ) { - <TR> - <TD ALIGN="right"><% mt('Branch number') |h %></TD> - <TD> - <INPUT TYPE="text" NAME="payinfo3" VALUE="<%$branch%>" SIZE=6 MAXLENGTH=5> - </TD> - </TR> -% } - <TR> - <TD ALIGN="right"><% mt('Bank name') |h %></TD> - <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD> - </TR> - -% if ( $conf->exists('show_bankstate') ) { - <TR> - <TD ALIGN="right"><% mt('Bank state') |h %></TD> - <TD><& /elements/select-state.html, - 'disable_empty' => 0, - 'empty_label' => emt('(choose)'), - 'state' => $paystate, - 'country' => $cust_main->country, - 'prefix' => 'pay', - &> - </TD> - </TR> -% } else { - <INPUT TYPE="hidden" NAME="paystate" VALUE="<% $paystate %>"> -% } - -% if ( $conf->exists('show_ss') ) { - <TR> - <TD ALIGN="right"> - <% mt('Account holder') |h %><BR> - <% mt('Social security or tax ID #') |h %> - </TD> - <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $ss %>"></TD> - </TR> -% } else { - <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"></TD> -% } - -% if ( $conf->exists('show_stateid') ) { - <TR> - <TD ALIGN="right"> - <% mt('Account holder') |h %><BR> - <% mt("Driver's license or state ID #") |h %> - </TD> - <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>"></TD> - <TD ALIGN="right"><% mt('State') |h %></TD> - <TD><& /elements/select-state.html, - 'disable_empty' => 0, - 'empty_label' => emt('(choose)'), - 'state' => $stateid_state, - 'country' => $cust_main->country, - 'prefix' => 'stateid_', - &> - </TD> - </TR> -% } else { - <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>"> - <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $stateid_state %>"> -% } - -% } #end CARD/CHEK-specific section - - -<TR> - <TD COLSPAN=8> - <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1"> - <% mt('Remember this information') |h %> - </TD> -</TR> - -<TR> - <TD COLSPAN=8> - <INPUT TYPE="checkbox"<% $auto ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }"> - <% mt("Charge future payments to this [_1] automatically",$type{$payby}) |h %> -% if ( @cust_payby ) { - <% mt('as') |h %> - <SELECT NAME="weight"> -% for ( 1 .. 1+scalar(grep { $_->payby =~ /^(CARD|CHEK)$/ } @cust_payby) ) { - <OPTION VALUE="<%$_%>"><% mt( $weight{$_} ) |h %> -% } - </SELECT> -% } else { - <INPUT TYPE="hidden" NAME="weight" VALUE="1"> -% } - </TD> -</TR> +<& /elements/cust_payby_new.html, + 'cust_payby' => \@cust_payby, + 'curr_value' => $custpaybynum, +&> </TABLE> </DIV> <BR> -<INPUT TYPE="submit" NAME="process" VALUE="<% mt('Process payment') |h %>"> +<INPUT TYPE="submit" NAME="process" ID="process" VALUE="<% mt('Process payment') |h %>" disabled="disabled" onclick="enableAmountField()"> </FORM> +<SCRIPT TYPE="text/javascript"> + +$(document).ready(function (){ + validate(); + $('<% $validate_select_fields %>').change(validate); + $('<% $validate_input_fields %>').keyup(validate); +}); + +function validate(){ + if ( + $('#amount').val() > 0 && ( + ( $('#custpaybynum').val() > 0 ) || +% if ($payby eq "CHEK") { + ( $('input[name=payinfo1]').val().length > 0 && + $('input[name=payinfo2]').val().length > 0 && + $('input[name=payname]').val().length > 0 && + $('select[name=paytype]').val().length > 0 + ) +% } +% elsif ($payby eq "CARD") { + ( $('input[name=payinfo]').val().length > 0 && + $('input[name=paycvv]').val().length > 0 && + $('input[name=payname]').val().length > 0 && + $('#city').val().length > 0 && + $('#city').val().length > 0 && + $('#state').val().length > 0 && + $('#country').val().length > 0 + ) +% } + ) + ) { + $("#process").prop("disabled", false); + } + else { + $("#process").prop("disabled", true); + } +} + +</SCRIPT> + <& /elements/footer-cust_main.html &> <%once> @@ -337,6 +218,17 @@ $cgi->param('payby') =~ /^(CARD|CHEK)$/ or die "unknown payby ". $cgi->param('payby'); my $payby = $1; +my $validate_select_fields = "#payment_option, #invoice, #custpaybynum, "; +my $validate_input_fields = "#amount, input[name=payname], "; +if ($payby eq "CHEK") { + $validate_input_fields .= "input[name=payinfo1], input[name=payinfo2]"; + $validate_select_fields .= "select[name=paytype] "; +} +elsif ($payby eq "CARD") { + $validate_input_fields .= "input[name=payinfo], input[name=paycvv], input[name=address1], #city, #zip"; + $validate_select_fields .= "#state, #country "; +} + $cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum ". $cgi->param('custnum'); my $custnum = $1; @@ -350,13 +242,6 @@ my $payinfo = ''; my $conf = new FS::Conf; -#false laziness w/selfservice make_payment.html shortcut for one-country -my %states = map { $_->state => 1 } - qsearch('cust_main_county', { - 'country' => $conf->config('countrydefault') || 'US' - } ); -my @states = sort { $a cmp $b } keys %states; - my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32; </%init> diff --git a/httemplate/misc/process/change-password.html b/httemplate/misc/process/change-password.html index a3e060168..1c746a4e0 100644 --- a/httemplate/misc/process/change-password.html +++ b/httemplate/misc/process/change-password.html @@ -18,7 +18,15 @@ <% $cgi->redirect($fsurl.'view/svc_acct.cgi?'.$cgi->query_string) %> % } % elsif ($contactnum) { - <% $cgi->redirect($fsurl.'edit/cust_main-contacts.html?'.$cgi->param('custnum')) %> +% my $freeside_status = "Contact ".$contact->{'Hash'}->{'first'}." ".$contact->{'Hash'}->{'last'}." password updated."; + <% $cgi->redirect( -uri => popurl(3). "view/cust_main.cgi?". $cgi->param('custnum'), + -cookie => CGI::Cookie->new( + -name => 'freeside_status', + -value => mt($freeside_status), + -expires => '+5m', + ), + ) +%> % } % } @@ -30,10 +38,15 @@ <%init> my $curuser = $FS::CurrentUser::CurrentUser; +my $contact; $cgi->param('svcnum') =~ /^(\d+)$/ or die "illegal svcnum" if $cgi->param('svcnum'); my $svcnum = $1; +foreach my $prefix (grep /^(.*)(password)$/, $cgi->param) { + $cgi->param('password' => $cgi->param($prefix)); +} + $cgi->param('contactnum') =~ /^(\d+)$/ or die "illegal contactnum" if $cgi->param('contactnum'); my $contactnum = $1; @@ -61,7 +74,7 @@ if ($svcnum) { $cgi->delete('password'); } elsif ($contactnum) { - my $contact = qsearchs('contact', { 'contactnum' => $contactnum } ) + $contact = qsearchs('contact', { 'contactnum' => $contactnum } ) or return { 'error' => "Contact not found" . $contactnum }; $error = $contact->is_password_allowed($newpass) diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index 717d57c85..7747bcbea 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -39,6 +39,8 @@ my $cust_main = qsearchs({ 'extra_sql' => ' AND '. $curuser->agentnums_sql, }) or die "unknown custnum $custnum"; +my $invoice = ($cgi->param('invoice') =~ /^(\d+)$/) ? $cgi->param('invoice') : ''; + $cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/ or errorpage("illegal amount ". $cgi->param('amount')); my $amount = $1; @@ -90,6 +92,7 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { $paycvv = $cust_payby->paycvv; # pass it if we got it, running a transaction will clear it ( $month, $year ) = $cust_payby->paydate_mon_year; $payname = $cust_payby->payname; + $cgi->param(-name=>"paytype", -value=>$cust_payby->paytype) unless $cgi->param("paytype"); } else { @@ -97,11 +100,11 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { # use new info ## - $cgi->param('year') =~ /^(\d+)$/ + $cgi->param('year') =~ /^(\d{4})/ or errorpage("illegal year ". $cgi->param('year')); $year = $1; - $cgi->param('month') =~ /^(\d+)$/ + $cgi->param('month') =~ /^(\d{2})/ or errorpage("illegal month ". $cgi->param('month')); $month = $1; @@ -208,17 +211,28 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { my $error = ''; my $paynum = ''; + if ( $cgi->param('batch') ) { $error = 'Prepayment discounts not supported with batched payments' if $discount_term; + # Invalid payment expire dates are replaced with 2037-12-01 (why?) + my $paydate = "${year}-${month}-01"; + { + use DateTime; + local $@; + eval { DateTime->new({ year => $year, month => $month, day => 1 }) }; + $paydate = '2037-12-01' if $@; + } + $error ||= $cust_main->batch_card( 'payby' => $payby, 'amount' => $amount, 'payinfo' => $payinfo, - 'paydate' => "$year-$month-01", + 'paydate' => $paydate, 'payname' => $payname, + 'invnum' => $invoice, map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}} ); @@ -241,6 +255,7 @@ if ( $cgi->param('batch') ) { 'discount_term' => $discount_term, 'no_auto_apply' => ($cgi->param('apply') eq 'never') ? 'Y' : '', 'no_invnum' => 1, + 'invnum' => $invoice, map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}} ); errorpage($error) if $error; diff --git a/httemplate/misc/timeworked.html b/httemplate/misc/timeworked.html index a0cf74371..24a0f5d40 100755 --- a/httemplate/misc/timeworked.html +++ b/httemplate/misc/timeworked.html @@ -113,12 +113,15 @@ foreach my $id ( map { /^transactionid(\d+)$/; $1; } $ticket->Load($ticketmap{$id}); $ticket{$ticketmap{$id}} = $ticket->Subject; $customers{$ticketmap{$id}} = - [ map { $_->Resolver->AsString } - grep { $_->Resolver->{'fstable'} eq 'cust_main' } - grep { $_->Scheme eq 'freeside' } - map { $_->TargetURI } - @{ $ticket->_Links('Base')->ItemsArrayRef } - ]; + [ map { $_->Resolver->AsString } + grep { $_->Resolver->{'fstable'} eq 'cust_main' } + grep { $_->Scheme eq 'freeside' } + map { $_->TargetURI } + grep { $_->BaseURI->Scheme eq 'fsck.com-rt' + && $_->BaseURI->Resolver->ObjectType eq 'ticket' + } + @{ $ticket->_Links('Base')->ItemsArrayRef } + ]; } } diff --git a/httemplate/misc/xmlhttp-free_addresses_in_block.json.html b/httemplate/misc/xmlhttp-free_addresses_in_block.json.html new file mode 100644 index 000000000..801718d35 --- /dev/null +++ b/httemplate/misc/xmlhttp-free_addresses_in_block.json.html @@ -0,0 +1,18 @@ +<%doc> + Return a json array containing all free ip addresses within a given block + Unless block is larger than /24 - Does somebody really want to populate + 65k addresses into a HTML selectbox? +</%doc> +<% encode_json($json) %>\ +<%init> + +my $json = []; + +my $blocknum = $cgi->param('blocknum'); + +my $addr_block = qsearchs( addr_block => { blocknum => $blocknum }); + +$json = $addr_block->free_addrs + if ref $addr_block && $addr_block->ip_netmask >= 24; + +</%init> diff --git a/httemplate/misc/xmlhttp-validate_password.html b/httemplate/misc/xmlhttp-validate_password.html index 4d9716bb9..c53abe883 100644 --- a/httemplate/misc/xmlhttp-validate_password.html +++ b/httemplate/misc/xmlhttp-validate_password.html @@ -28,14 +28,14 @@ my $validate_password = sub { $result{'syserror'} = 'Invoked without password' unless $password; return \%result if $result{'syserror'}; - if ($arg{'contactnum'}) { + if ($arg{'contactnum'} =~ /^\d+$/) { my $contactnum = $arg{'contactnum'}; $result{'syserror'} = 'Invalid contactnum' unless $contactnum =~ /^\d*$/; return \%result if $result{'syserror'}; my $contact = $contactnum ? qsearchs('contact',{'contactnum' => $contactnum}) - : ''; + : (new FS::contact {}); $result{'error'} = $contact->is_password_allowed($password); } diff --git a/httemplate/search/cust_bill_pkg_discount.html b/httemplate/search/cust_bill_pkg_discount.html index f4fbd561b..eb39dea8f 100644 --- a/httemplate/search/cust_bill_pkg_discount.html +++ b/httemplate/search/cust_bill_pkg_discount.html @@ -38,7 +38,7 @@ Parameters: if ( $_[0]->pkgdiscountnum ) { # Standard discount, not a waived setup fee my $discount = qsearchs('discount',{ - pkgdiscountnum => $_[0]->pkgdiscountnum + discountnum => $_[0]->discountnum }); return $discount->description; } else { @@ -228,7 +228,11 @@ if ( $cgi->param('usernum') =~ /^(\d+)$/ ) { } # Filter: Include waived setup fees -if ( !$cgi->param('include_waived_setup') ) { +if ( $cgi->param('include_waived_setup') ) { + # Filter a hidden fee attached to a package with a waived setup fee from + # causing the waived-fee for that package to be double-counted + push @where, 'cust_bill_pkg.pkgpart_override IS NULL'; +} else { push @where, "cust_bill_pkg_discount.pkgdiscountnum IS NOT NULL"; } diff --git a/httemplate/search/cust_event.html b/httemplate/search/cust_event.html index b1ba9090e..1766c1905 100644 --- a/httemplate/search/cust_event.html +++ b/httemplate/search/cust_event.html @@ -134,6 +134,12 @@ my $trigger_link = sub { my $pkgnum = $cust_event->tablenum; my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment [ "${p}view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#cust_pkg", 'tablenum' ]; + } elsif ( $eventtable eq 'cust_pay' ) { + [ "${p}view/$eventtable.html?paynum=", 'tablenum' ]; + } elsif ( $eventtable eq 'cust_statement' ) { + [ "${p}view/$eventtable.html?", 'tablenum' ]; + } elsif ( $eventtable eq 'cust_pay_batch' ) { + [ "${p}search/cust_pay_batch.cgi?batchnum=", 'cust_pay_batch_batchnum' ]; } else { [ "${p}view/$eventtable.cgi?", 'tablenum' ]; } @@ -199,6 +205,7 @@ my $sql_query = { 'part_event.*', #'cust_bill.custnum', #'cust_bill._date AS cust_bill_date', + 'cust_pay_batch.batchnum AS cust_pay_batch_batchnum', 'cust_main.custnum AS cust_main_custnum', FS::UI::Web::cust_sql_fields(), ), diff --git a/httemplate/search/cust_pay_batch.cgi b/httemplate/search/cust_pay_batch.cgi index cc958b96d..6b175adb7 100755 --- a/httemplate/search/cust_pay_batch.cgi +++ b/httemplate/search/cust_pay_batch.cgi @@ -114,7 +114,7 @@ $count_query = 'SELECT COUNT(*) FROM cust_pay_batch ' . $sql_query = { 'table' => 'cust_pay_batch', - 'select' => 'cust_pay_batch.*, cust_main.*, cust_pay.paynum', + 'select' => 'cust_pay_batch.*, cust_pay.paynum', 'hashref' => {}, 'addl_from' => 'LEFT JOIN pay_batch USING ( batchnum ) '. 'LEFT JOIN cust_main USING ( custnum ) '. diff --git a/httemplate/search/cust_timespan.html b/httemplate/search/cust_timespan.html index a380b78ab..9c9a8261c 100644 --- a/httemplate/search/cust_timespan.html +++ b/httemplate/search/cust_timespan.html @@ -11,6 +11,7 @@ 'header' => \@header, 'fields' => \@fields, 'links' => \@links, + 'disable_maxselect' => '1', &> <%init> @@ -84,11 +85,16 @@ my $active_pkg_sql = 'select pkgnum from cust_pkg where cust_pkg.custnum = cust_ ## sql to get the first active date, last cancel date, and last reason. my $active_date = 'select min(setup) from cust_pkg left join part_pkg using (pkgpart) where cust_pkg.custnum = cust_main.custnum and part_pkg.freq > \'0\''; -my $cancel_date = 'select max(cancel) from cust_pkg where cust_pkg.custnum = cust_main.custnum'; + +## set cancel date range here +my($beginning_date, $ending_date) = FS::UI::Web::parse_beginning_ending($cgi, ''); +my $max_cancel_sql = "select max(cancel) from cust_pkg left join part_pkg using (pkgpart) where cust_pkg.custnum = cust_main.custnum and part_pkg.freq > \'0\'"; +my $cancel_date = $max_cancel_sql.' and (('.$max_cancel_sql.') >= '.$beginning_date.' and ('.$max_cancel_sql.') <= '.$ending_date.')'; + my $cancel_reason = 'select reason.reason from cust_pkg left join cust_pkg_reason on (cust_pkg.pkgnum = cust_pkg_reason.pkgnum) left join reason on (cust_pkg_reason.reasonnum = reason.reasonnum) - where cust_pkg.custnum = cust_main.custnum and cust_pkg_reason.date = ('.$cancel_date.') + where cust_pkg.custnum = cust_main.custnum and cust_pkg_reason.date = ('.$cancel_date.') limit 1 '; my @header = ( '#', 'Name', 'Address', 'Phone', 'Email', 'Active Date', 'Cancelled Date', 'Reason', 'Active Days' ); @@ -96,8 +102,6 @@ my @fields = ( 'custnum', 'custname', $location_sub, 'daytime', $email_sub, 'act my @links = ( $customer_link, $customer_link, '', '', '', '', '', '', '' ); my @select = ( 'cust_main.*', - 'cust_location.*', - 'part_pkg.*', "(select to_char((select to_timestamp((".$active_date."))), 'Mon DD YYYY')) AS active_date", "(select to_char((select to_timestamp((".$cancel_date."))), 'Mon DD YYYY')) AS cancel_date", "($cancel_reason) AS cancel_reason", diff --git a/httemplate/search/e911.html b/httemplate/search/e911.html index 75dbef7d5..6d387d563 100644 --- a/httemplate/search/e911.html +++ b/httemplate/search/e911.html @@ -1,6 +1,23 @@ +<%doc> + + E911 Fee Report + + Finds billing totals for a given pkgpart where the bill item matches + cust_pkg.pkgpart or cust_bill_pkg.pkgpart_override columns. + + Given date range, filter by when the invoice was paid. + + * E911 access lines - SUM(cust_bill_pkg.quantity) + * Total fees charged - SUM(cust_bill_pay_pkg.amount) + * Fee payments collected - SUM(cust_bill_pkg.setup) + SUM(cust_bill_pkg.recur) + + * Administrative fee (1%) - 1% of Fee Payments Collected + * Amount due - 99% of Fee Payments Collected + +</%doc> % if ( $row ) { -%# pretty minimal report <& /elements/header.html, 'E911 Fee Report' &> + <& /elements/table-grid.html &> <STYLE TYPE="text/css"> table.grid TD:first-child { font-weight: normal } @@ -8,27 +25,27 @@ table.grid TD { font-weight: bold; text-align: right; padding: 1px 2px } </STYLE> + <TR><TH COLSPAN=2><% $legend %></TH></TR> <TR> - <TD>E911 access lines:</TD> - <TD><% $row->{quantity} || 0 %></TD> + <TD><% mt('E911 access lines') %>:</TD> + <TD><% $report{e911_access_lines} %></TD> </TR> <TR> - <TD>Total fees charged: </TD> - <TD><% $money_char.sprintf('%.2f', $row->{charged_amount}) %></TD> + <TD><% mt('Total fees charged') %>: </TD> + <TD><% $money_char.$report{fees_charged} %></TD> </TD> <TR> - <TD>Fee payments collected: </TD> - <TD><% $money_char.sprintf('%.2f', $row->{paid_amount}) %></TD> + <TD><% mt('Fee payments collected') %>: </TD> + <TD><% $money_char.$report{fees_collected} %></TD> </TR> <TR> - <TD>Administrative fee (1%): </TD> - <TD><% $money_char.sprintf('%.2f', $row->{paid_amount} * $admin_fee) %></TD> + <TD><% mt('Administrative fee') %> (1%): </TD> + <TD><% $money_char.$report{admin_fee} %></TD> </TR> <TR> - <TD>Amount due: </TD> - <TD><% $money_char.sprintf('%.2f', $row->{paid_amount} * (1-$admin_fee) ) %> - </TD> + <TD><% mt('Amount due') %>: </TD> + <TD><% $money_char.$report{e911_amount_due} %></TD> </TR> </TABLE> <& /elements/footer.html &> @@ -38,6 +55,8 @@ table.grid TD { font-weight: bold; % } <%init> +our $DEBUG; + die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); @@ -56,56 +75,89 @@ my $agentnum = $1; # package classes, etc.), do NOT simply loop through this and do a # bazillion scalar_sql queries. Use a properly grouped aggregate query. -my $select = 'SELECT cust_bill_pkg.billpkgnum, cust_bill_pkg.quantity, '. -'cust_bill_pkg.setup, SUM(cust_bill_pay_pkg.amount) AS paid_amount'; - -my $from = 'FROM cust_pkg - JOIN cust_bill_pkg USING (pkgnum) - JOIN cust_bill USING (invnum) - LEFT JOIN cust_bill_pay_pkg USING (billpkgnum) - LEFT JOIN cust_bill_pay USING (billpaynum) -'; -# going by payment application date here, which should be -# max(invoice date, payment date) -my $where = "WHERE cust_pkg.pkgpart = $pkgpart -AND ( (cust_bill_pay._date >= $begin AND cust_bill_pay._date < $end) - OR cust_bill_pay.paynum IS NULL )"; +my $sql_statement = " + SELECT + sum(cust_bill_pkg.quantity) as quantity, + sum(cust_bill_pay_pkg.amount) as amount, + sum(cust_bill_pkg.setup) as setup, + sum(cust_bill_pkg.recur) as recur + FROM cust_pkg + LEFT JOIN cust_bill_pkg USING (pkgnum) + LEFT JOIN cust_bill_pay_pkg USING (billpkgnum) + LEFT JOIN cust_bill_pay USING (billpaynum) +"; if ( $agentnum ) { - $from .= ' JOIN cust_main ON (cust_pkg.custnum = cust_main.custnum)'; - $where .= "\n AND cust_main.agentnum = $agentnum"; + $sql_statement .= " + LEFT JOIN cust_main USING (custnum) + WHERE + cust_main.agentnum = ? + AND "; +} else { + $sql_statement .= " + WHERE + " } +$sql_statement .= " + ( cust_bill_pkg.pkgpart_override = ? OR cust_pkg.pkgpart = ? ) + AND ( + ( cust_bill_pay._date >= ? AND cust_bill_pay._date < ? ) + OR cust_bill_pay.paynum IS NULL + ); +"; + +# Preserving this oddball, unexplained epoch substitution +$end = '' if $end == 4294967295; -my $subquery = "$select $from $where -GROUP BY cust_bill_pkg.billpkgnum, cust_bill_pkg.quantity"; -# This has one row for each E911 line item that has any payments applied. -# Fields are the billpkgnum of the item (currently unused), the number of -# E911 charges, and the total amount paid (always > 0). +my @bind_values = ( + $agentnum ? $agentnum : (), + $pkgpart, + $pkgpart, + $begin || 0, + $end || time(), +); -# now sum those rows. -my $sql = "SELECT SUM(quantity) AS quantity, SUM(setup) AS charged_amount, -SUM(paid_amount) AS paid_amount FROM ($subquery) AS paid_fees"; # no grouping +if ( $DEBUG ) { + warn "\$sql_statement: $sql_statement\n"; + warn "\@bind_values: ".join(', ',@bind_values)."\n"; +} -my $sth = dbh->prepare($sql); -$sth->execute; +my $sth = dbh->prepare( $sql_statement ); +$sth->execute( @bind_values ) || die $sth->errstr; my $row = $sth->fetchrow_hashref; -my $admin_fee = 0.01; # 1% admin fee, allowed in Texas +my %report = ( + e911_access_lines => $row->{quantity} || 0, -$end = '' if $end == 4294967295; -my $legend = ''; -if ( $agentnum ) { - $legend = FS::agent->by_key($agentnum)->agent . ', '; -} -if ( $begin and $end ) { - $legend .= time2str('%h %o %Y', $begin) . '—' . - time2str('%h %o %Y', $end); + fees_charged => sprintf( + "%.2f", + ( $row->{setup} + $row->{recur} ) || 0, + ), + + fees_collected => sprintf( + "%.2f", + ( $row->{amount} || 0 ), + ), +); + +# Does everybody use this 1% admin fee? Should this be configurable? +$report{admin_fee} = sprintf( "%.2f", $report{fees_collected} * 0.01 ); +$report{e911_amount_due} = $report{fees_collected} - $report{admin_fee}; + +my $begin_text = + $begin + ? DateTime->from_epoch(epoch => $begin)->mdy('/') + : mt('Anytime'); + +my $end_text = DateTime->from_epoch(epoch => ( $end || time ))->mdy('/'); + +my $legend = FS::agent->by_key($agentnum)->agent . ', ' if $agentnum; +if ( $begin && $end ) { + $legend .= "$begin_text ↔ $end_text"; } elsif ( $begin ) { - $legend .= time2str('after %h %o %Y', $begin); -} elsif ( $end ) { - $legend .= time2str('before %h %o %Y', $end); + $legend .= mt('After')." $begin_text"; } else { - $legend .= 'any time'; + $legend .= mt('Through')." $end_text" } -$legend = ucfirst($legend); + </%init> diff --git a/httemplate/search/elements/checkbox-foot.html b/httemplate/search/elements/checkbox-foot.html index ae8b79470..f33a87467 100644 --- a/httemplate/search/elements/checkbox-foot.html +++ b/httemplate/search/elements/checkbox-foot.html @@ -4,7 +4,7 @@ html_foot => include('elements/checkbox-foot.html', actions => [ { label => 'Edit selected packages', - action => 'popup_package_edit()', + onclick => 'popup_package_edit()', }, { submit => 'Delete selected packages', confirm => 'Really delete these packages?' @@ -50,7 +50,7 @@ false. <BR> % foreach my $action (@$actions) { % if ( $action->{onclick} ) { -<INPUT TYPE="button" <% $action->{name} %> onclick="<% $opt{onclick} %>"\ +<INPUT TYPE="button" <% $action->{name} %> onclick="<% $action->{onclick} %>"\ VALUE="<% $action->{label} |h%>"> % } elsif ( $action->{submit} ) { <INPUT TYPE="submit" <% $action->{name} %> <% $action->{confirm} %>\ diff --git a/httemplate/search/elements/grid-report.html b/httemplate/search/elements/grid-report.html index b1e543012..efc009725 100644 --- a/httemplate/search/elements/grid-report.html +++ b/httemplate/search/elements/grid-report.html @@ -141,13 +141,17 @@ Usage: $m->print($output); </%perl> % } else { +% unless ( $suppress_header ) { <& /elements/header.html, $title &> +% } <% $head %> % my $myself = $cgi->self_url; +% unless ( $suppress_header ) { <P ALIGN="right" CLASS="noprint"> Download full reports<BR> as <A HREF="<% "$myself;_type=xls" %>">Excel spreadsheet</A><BR> </P> +% } <style type="text/css"> .report * { background-color: #f8f8f8; @@ -169,8 +173,10 @@ as <A HREF="<% "$myself;_type=xls" %>">Excel spreadsheet</A><BR> % next if !ref($cell); # placeholders % my $td = $cell->{header} ? 'th' : 'td'; % my $style = ''; -% $style .= " rowspan=".$cell->{rowspan} if $cell->{rowspan} > 1; -% $style .= " colspan=".$cell->{colspan} if $cell->{colspan} > 1; +% $style .= " rowspan=".$cell->{rowspan} +% if exists $cell->{rowspan} && $cell->{rowspan} > 1; +% $style .= " colspan=".$cell->{colspan} +% if exists $cell->{colspan} && $cell->{colspan} > 1; % $style .= ' class="' . $cell->{class} . '"' if $cell->{class}; % if ($cell->{bypass_filter}) { <<%$td%><%$style%>><% $cell->{value} %></<%$td%>> @@ -182,8 +188,10 @@ as <A HREF="<% "$myself;_type=xls" %>">Excel spreadsheet</A><BR> % } </table> <% $foot %> +% unless ( $suppress_footer ) { <& /elements/footer.html &> % } +% } <%args> $title @rows @@ -192,4 +200,6 @@ $head => '' $foot => '' $table_width => "100%" $table_class => "report" +$suppress_header => undef +$suppress_footer => undef </%args> diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 0e8c69a51..730a51aa3 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -389,14 +389,15 @@ unless ( $type =~ /^(csv|xml|\w*.xls)$/) { #setup some pagination things if we're in html mode my $conf = new FS::Conf; - $confmax = $conf->config('maxsearchrecordsperpage') || 100; - if ( $cgi->param('maxrecords') =~ /^(\d+)$/ ) { - $maxrecords = $1; - } else { - $maxrecords ||= $confmax; - } - $opt{'disable_maxselect'} ||= $conf->exists('disable_maxselect'); + unless ($opt{'disable_maxselect'}) { + $confmax = $conf->config('maxsearchrecordsperpage') || 100; + if ( $cgi->param('maxrecords') =~ /^(\d+)$/ ) { + $maxrecords = $1; + } else { + $maxrecords ||= $confmax; + } + } $limit = $maxrecords ? "LIMIT $maxrecords" : ''; diff --git a/httemplate/search/future_autobill.html b/httemplate/search/future_autobill.html index 711a25f82..2e723ec79 100644 --- a/httemplate/search/future_autobill.html +++ b/httemplate/search/future_autobill.html @@ -2,20 +2,23 @@ Report listing upcoming auto-bill transactions -Spec requested the ability to run this report with a longer date range, -and see which charges will process on which day. Checkbox multiple_billing_dates -enables this functionality. +For every customer with a valid auto-bill payment method, +report runs bill_and_collect() for each customer, for each +day, from today through the report target date. After +recording the results, all operations are rolled back. -Performance: -This is a dynamically generated report. The time this report takes to run -will depends on the number of customers. Installations with a high number -of auto-bill customers may find themselves unable to run this report -because of browser timeout. Report could be implemented as a queued job if -necessary, to solve the performance problem. +This report relies on the ability to safely run bill_and_collect(), +with all exports and messaging disabled, and then to roll back the +results. + +This report takes time. If 200 customers have automatic +payment methods, and requester is looking one week ahead, +there will be 1,400 billing and payment cycles simulated </%doc> +<h4><% $report_subtitle %></h4> <& elements/grid-report.html, - title => 'Upcoming auto-bill transactions', + title => $report_title, rows => \@rows, cells => \@cells, table_width => "", @@ -29,14 +32,57 @@ necessary, to solve the performance problem. td.gridreport { margin: 0 .2em; padding: 0 .4em; } </style> ', + suppress_header => $job ? 1 : 0, + suppress_footer => $job ? 1 : 0, &> +% if ( %pmt_type_subtotal ) { + <table class="gridreport" style="margin-left: 2em;"> + <tr> + <th class="gridreport" colspan="2"> + Summary + </th> + </tr> +% for my $pmt_type ( sort keys %pmt_type_subtotal ) { + <tr class="gridreport"> + <td class="gridreport" style="text-align: right; margin-right: 1em;"> + <% sprintf '$%.2f', $pmt_type_subtotal{ $pmt_type } %> + </td> + <td class="gridreport"> + <% $pmt_type |h %> + </td> + </tr> +% } +% if ( keys %pmt_type_subtotal > 1 ) { +% $pmt_type_subtotal{Total} += $_ for values %pmt_type_subtotal; + <tr class="gridreport" style="border-top: solid 1px #999;"> + <td class="gridreport" style="text-align: right; margin-right: 1em; border-top: solid 1px #666;"> + <% sprintf( '$%.2f', $pmt_type_subtotal{Total} ) %> + </td> + <td class="gridreport" style="border-top: solid 1px #666;"> + Total + </td> + </tr> + </table> +% } +% } <%init> + use DateTime; + use FS::Misc::Savepoint; + use FS::Report::Queued::FutureAutobill; + use FS::UID qw( dbh ); + + die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); + + my $job = $FS::Report::Queued::FutureAutobill::job; -use FS::UID qw( dbh myconnect ); + $job->update_statustext('0,Finding customers') if $job; -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); + my $DEBUG = $cgi->param('DEBUG') || 0; + + my $agentnum = $cgi->param('agentnum') + if $cgi->param('agentnum') =~ /^\d+/; my $target_dt; my @target_dates; @@ -45,45 +91,49 @@ die "access denied" my %noon = ( hour => 12, minute => 0, - second => 0 + second => 0, ); - my $now_dt = DateTime->now; $now_dt = DateTime->new( - month => $now_dt->month, - day => $now_dt->day, - year => $now_dt->year, + month => $now_dt->month, + day => $now_dt->day, + year => $now_dt->year, %noon, ); # Get target date from form if ($cgi->param('target_date')) { + # DateTime::Format::DateParse would be better my ($mm, $dd, $yy) = split /[\-\/]/,$cgi->param('target_date'); + ( $yy, $mm, $dd ) = ( $mm, $dd, $yy ) if $mm > 1900; + $target_dt = DateTime->new( - month => $mm, - day => $dd, - year => $yy, + month => $mm, + day => $dd, + year => $yy, %noon, - ) if $mm && $dd & $yy; + ) if $mm && $dd && $yy; # Catch a date from the past: time only travels in one direction - $target_dt = undef if $target_dt->epoch < $now_dt->epoch; + $target_dt = undef + unless $target_dt && $now_dt && $now_dt <= $target_dt; } # without a target date, default to tomorrow unless ($target_dt) { - $target_dt = DateTime->from_epoch( epoch => time() + 86400) ; - $target_dt = DateTime->new( - month => $target_dt->month, - day => $target_dt->day, - year => $target_dt->year, - %noon - ); + $target_dt = $now_dt->clone->add( days => 1 ); } - # If multiple_billing_dates checkbox selected, create a range of dates - # from today until the given report date. Otherwise, use target date only. - if ($cgi->param('multiple_billing_dates')) { + my $report_title = FS::cust_payby->future_autobill_report_title; + my $report_subtitle = sprintf( + '(%s through %s)', + $now_dt->mdy('/'), + $target_dt->mdy('/'), + ); + + # Create a range of dates from today until the given report date + # (leaving the probably useless 'quick-report' mode, but disabled) + if ( 1 || $cgi->param('multiple_billing_dates')) { my $walking_dt = DateTime->from_epoch(epoch => $now_dt->epoch); until ($walking_dt->epoch > $target_dt->epoch) { push @target_dates, $walking_dt->epoch; @@ -93,80 +143,149 @@ die "access denied" push @target_dates, $target_dt->epoch; } - # List all customers with an auto-bill method - # - # my %cust_payby = map {$_->custnum => $_} qsearch({ - # table => 'cust_payby', - # hashref => { - # weight => { op => '>', value => '0' }, - # paydate => { op => '>', value => $target_dt->ymd }, - # }, - # order_by => " ORDER BY weight DESC ", - # }); - # List all customers with an auto-bill method that's not expired my %cust_payby = map {$_->custnum => $_} qsearch({ - table => 'cust_payby', - hashref => { - weight => { op => '>', value => '0' }, - }, - order_by => " ORDER BY weight DESC ", - extra_sql => " AND ( payby = 'CHEK' OR ( paydate > '".$target_dt->ymd."')) ", + table => 'cust_payby', + addl_from => 'JOIN cust_main USING (custnum)', + hashref => { weight => { op => '>', value => '0' }}, + order_by => " ORDER BY weight DESC ", + extra_sql => + "AND ( + cust_payby.payby IN ('CHEK','DCHK','DCHEK') + OR ( cust_payby.paydate > '".$target_dt->ymd."') + ) + AND " . $FS::CurrentUser::CurrentUser->agentnums_sql + . ($agentnum ? "AND cust_main.agentnum = $agentnum" : ''), }); + my $completion_target = scalar(keys %cust_payby) * scalar( @target_dates ); + my $completion_progress = 0; + + my $fakebill_time = time(); my %abreport; my @rows; + my %pmt_type_subtotal; local $@; local $SIG{__DIE__}; - my $temp_dbh = myconnect(); - eval { # Creating sandbox dbh where all connections are to be rolled back - local $FS::UID::dbh = $temp_dbh; + + eval { # Sandbox + + # Supress COMMIT statements + my $oldAutoCommit = $FS::UID::AutoCommit; local $FS::UID::AutoCommit = 0; + local $FS::UID::ForceObeyAutoCommit = 1; + + # Suppress notices generated by billing events + local $FS::Misc::DISABLE_ALL_NOTICES = 1; + + # Bypass payment processing, recording a fake payment + local $FS::cust_main::Billing_Realtime::BOP_TESTING = 1; + local $FS::cust_main::Billing_Realtime::BOP_TESTING_SUCCESS = 1; - # Generate report data into @rows + my $savepoint_label = 'future_autobill'; + savepoint_create( $savepoint_label ); + + warn sprintf "Report involves %s customers", scalar keys %cust_payby + if $DEBUG; + + # Run bill_and_collect(), for each customer with an autobill payment method, + # for each day represented in the report for my $custnum (keys %cust_payby) { my $cust_main = qsearchs('cust_main', {custnum => $custnum}); + warn "-- Processing custnum $custnum\n" + if $DEBUG; + # walk forward through billing dates for my $query_epoch (@target_dates) { + $FS::cust_main::Billing_Realtime::BOP_TESTING_TIMESTAMP = $query_epoch; my $return_bill = []; - eval { # Don't let an error on one customer crash the report - my $error = $cust_main->bill( - time => $query_epoch, - return_bill => $return_bill, - no_usage_reset => 1, - ); - die "$error (simulating future billing)" if $error; - }; - warn ("$@: (future_autobill custnum:$custnum)"); - - if (@{$return_bill}) { - my $inv = $return_bill->[0]; - push @rows,{ - name => $cust_main->name, - _date => $inv->_date, - cells => [ - { class => 'gridreport', value => $custnum }, - { class => 'gridreport', - value => '<a href="/view/cust_main.cgi?"'.$custnum.'">'.$cust_main->name.'</a>', - bypass_filter => 1, - }, - { class => 'gridreport', value => $inv->charged, format => 'money' }, - { class => 'gridreport', value => DateTime->from_epoch(epoch=>$inv->_date)->ymd }, - { class => 'gridreport', value => ($cust_payby{$custnum}->payby || $cust_payby{$custnum}->paytype) }, - { class => 'gridreport', value => $cust_payby{$custnum}->paymask }, - ] - }; - } + warn "---- Set billtime to ". + DateTime->from_epoch( epoch => $query_epoch )."\n" + if $DEBUG; + + my $error = $cust_main->bill_and_collect( + time => $query_epoch, + return_bill => $return_bill, + no_usage_reset => 1, + fake => 1, + ); + + warn "!!! $error (simulating future billing)\n" if $error; + + my $statustext = sprintf( + '%s,Simulating upcoming invoices and payments', + int( ( ++$completion_progress / $completion_target ) * 100 ) + ); + $job->update_statustext( $statustext ) if $job; + warn "[ $completion_progress / $completion_target ] $statustext\n" + if $DEBUG; } - $temp_dbh->rollback; - } # /foreach $custnum + + # Generate report rows from recorded payments in cust_pay + for my $cust_pay ( + qsearch( cust_pay => { + custnum => $custnum, + _date => { op => '>=', value => $fakebill_time }, + }) + ) { + push @rows,{ + name => $cust_main->name, + _date => $cust_pay->_date, + cells => [ + + # Customer number + { class => 'gridreport', value => $custnum }, + + # Customer name / customer link + { class => 'gridreport', + value => qq{<a href="${fsurl}view/cust_main.cgi?${custnum}">} . encode_entities( $cust_main->name ). '</a>', + bypass_filter => 1 + }, + + # Amount + { class => 'gridreport', + value => $cust_pay->paid, + format => 'money' + }, + + # Transaction Date + { class => 'gridreport', + value => DateTime->from_epoch( epoch => $cust_pay->_date )->ymd + }, + + # Payment Method + { class => 'gridreport', + value => encode_entities( $cust_pay->paycardtype || $cust_pay->payby ), + }, + + # Masked Payment Instrument + { class => 'gridreport', + value => encode_entities( $cust_pay->paymask ), + }, + ] + }; + + $pmt_type_subtotal{ $cust_pay->paycardtype || $cust_pay-> payby } + += $cust_pay->paid; + + } # /foreach payment + + # Roll back database at the end of each customer + # Makes the report slighly slower, but ensures only one customer row + # locked at a time + + warn "-- custnum $custnum -- rollback()\n" if $DEBUG; + savepoint_rollback( $savepoint_label ); + dbh->rollback if $oldAutoCommit; + + } # /foreach $custnum }; # /eval - warn("$@") if $@; + warn("future_autobill.html report generated error $@") if $@; # Sort output by date, and format for output to grid-report.html my @cells = [ diff --git a/httemplate/search/prospect_main.html b/httemplate/search/prospect_main.html index d65d4d19d..0eb45f338 100644 --- a/httemplate/search/prospect_main.html +++ b/httemplate/search/prospect_main.html @@ -17,7 +17,6 @@ } $pm->prospect_contact ]; - '' }, sub { my $pr = shift->part_referral; diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html index ef5447838..4c16f74c0 100644 --- a/httemplate/search/report_cdr.html +++ b/httemplate/search/report_cdr.html @@ -189,8 +189,16 @@ die "access denied" my @fields = fields('cdr'); push @fields, 'ratename'; +push @fields, map "cdr_termination.$_", qw( rated_price rated_seconds rated_minutes rated_granularity status svcnum ); + my $labels = FS::cdr->table_info->{'fields'}; $labels->{ratename} = 'Rate plan'; +$labels->{'cdr_termination.rated_price'} = 'Termination rated price'; +$labels->{'cdr_termination.rated_seconds'} = 'Termination rated seconds'; +$labels->{'cdr_termination.rated_minutes'} = 'Termination rated minutes'; +$labels->{'cdr_termination.rated_granularity'} = 'Termination rated granularity'; +$labels->{'cdr_termination.status'} = 'Termination status'; +$labels->{'cdr_termination.svcnum'} = 'Termination service'; my $conf = new FS::Conf; my $default_phone_countrycode = diff --git a/httemplate/search/report_cust_event.html b/httemplate/search/report_cust_event.html index 7aa4ff9d7..84eb45f96 100644 --- a/httemplate/search/report_cust_event.html +++ b/httemplate/search/report_cust_event.html @@ -5,11 +5,9 @@ %> <FORM ACTION="cust_event.html" METHOD="GET"> - <TABLE BGCOLOR="#cccccc" CELLSPACING=0> - <TR> - <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Search options</FONT></TH> - </TR> + <FONT CLASS="fsinnerbox-title"><% emt('Search options') %></FONT> + <TABLE CLASS="fsinnerbox"> <% include( '/elements/tr-select-agent.html', 'disable_empty'=>0 ) %> @@ -44,7 +42,7 @@ 'field' => 'event_status', 'multiple' => 1, 'all_selected' => 1, - 'size' => 5, + 'size' => 6, 'options' => [ qw( done_Y done_S done_N failed new locked ) ], 'option_labels' => { done_Y => 'Completed normally', done_S => 'Completed, with an error', diff --git a/httemplate/search/report_cust_timespan.html b/httemplate/search/report_cust_timespan.html index 4ff3bb892..27dd94006 100644 --- a/httemplate/search/report_cust_timespan.html +++ b/httemplate/search/report_cust_timespan.html @@ -20,6 +20,8 @@ 'curr_value' => scalar( $cgi->param('cust_status') ), &> + <& /elements/tr-input-beginning_ending.html &> + </FORM> </TABLE> diff --git a/httemplate/search/report_future_autobill-queued_job.html b/httemplate/search/report_future_autobill-queued_job.html new file mode 100644 index 000000000..d23efb5b1 --- /dev/null +++ b/httemplate/search/report_future_autobill-queued_job.html @@ -0,0 +1,11 @@ +<% $server->process %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); + +my $server = new FS::UI::Web::JSRPC + 'FS::Report::Queued::FutureAutobill::make_report', + $cgi; + +</%init> diff --git a/httemplate/search/report_future_autobill.html b/httemplate/search/report_future_autobill.html index 1a0c9f48a..28f589ee7 100644 --- a/httemplate/search/report_future_autobill.html +++ b/httemplate/search/report_future_autobill.html @@ -1,42 +1,73 @@ <%doc> -Display date selector for the future_autobill.html report +Display pre-report page for the Future Auto Bill Transactions report + +Report runs in the queue. Once the report is generated, user is +redirected to the report results. </%doc> -<% include('/elements/header.html', 'Future Auto-Bill Transactions' ) %> +<% include('/elements/header.html', $report_title ) %> + + +% if ( FS::TaxEngine->new->info->{batch} ) { + <div style="font-color: red"> + NOTE: This report is disabled due to tax engine configuration + </div> -<FORM ACTION="future_autobill.html" METHOD="GET"> -<TABLE> -<& /elements/tr-input-date-field.html, - { - name => 'target_date', - value => $target_date, - label => emt('Target billing date').': ', - required => 1 - } -&> +% } else { -<& /elements/tr-checkbox.html, - 'label' => emt('Multiple billing dates (slow)').': ', - 'field' => 'multiple_billing_dates', - 'value' => '1', -&> + <FORM NAME="future_autobill" ID="future_autobill"> + <TABLE> + <& /elements/tr-input-date-field.html, + { + name => 'target_date', + value => $target_date, + label => emt('Target billing date').': ', + required => 1 + } + &> -</TABLE> + <% include('/elements/tr-select-agent.html', + 'label' => 'For agent: ', + 'disable_empty' => 0, + ) + %> + </TABLE> + <BR> -<BR> -<INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>"> + <INPUT ID="future_autobill_submit" TYPE="submit" VALUE="<% mt('Get Report') |h %>"> + </FORM> -</FORM> + <% include( '/elements/progress-init.html', + 'future_autobill', + [ qw( agentnum target_date ) ], + 'report_future_autobill-queued_job.html', + ) + %> + + <script type="text/javascript"> + $('#future_autobill').submit( function( event ) { + $('#future_autobill').prop( 'disabled', true ); + $('#future_autobill_submit').prop( 'disabled', true ); + event.preventDefault(); + process(); + }); + </script> + +% } <% include('/elements/footer.html') %> <%init> +use FS::cust_payby; +use FS::CurrentUser; die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); -my $target_date = DateTime->from_epoch(epoch=>(time()+86400))->mdy('/'); +my $target_date = DateTime->now->add(days => 1)->mdy('/'); +my $report_title = FS::cust_payby->future_autobill_report_title; </%init> + diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html index 1660c1c22..efcf48ecc 100644 --- a/httemplate/view/cust_main/contacts.html +++ b/httemplate/view/cust_main/contacts.html @@ -29,9 +29,21 @@ <TD COLSPAN=5><% $cust_main->contact |h %></TD> % if ( $conf->exists('show_ss') ) { <TH ALIGN="right"><% mt('SS#') |h %></TH> - <TD><% $conf->exists('unmask_ss') - ? $cust_main->ss - : $cust_main->masked('ss') || ' ' %></TD> + <TD> + <span id="ss_span" style="white-space:nowrap;"> + <% $cust_main->masked('ss') || ' ' %> +% if ( +% $cust_main->ss +% && $FS::CurrentUser::CurrentUser->access_right('Unmask customer SSN') +% ) { + <& /elements/link-replace_element_text.html, { + target_id => 'ss_span', + replace_text => $cust_main->ss, + element_type => 'span' + } &> +% } + </span> + </TD> % } </TR> % if ( $conf->exists('cust_main-enable_spouse') and @@ -172,7 +184,21 @@ <TR> <TH ALIGN="right"><% $stateid_label %></TH> - <TD><% $cust_main->masked('stateid') || ' ' %></TD> + <TD> + <span id="stateid_span" style="white-space:nowrap;"> + <% $cust_main->masked('stateid') || ' ' %> +% if ( +% $cust_main->stateid +% && $FS::CurrentUser::CurrentUser->access_right('Unmask customer DL') +% ) { + <& /elements/link-replace_element_text.html, { + target_id => 'stateid_span', + replace_text => $cust_main->stateid, + element_type => 'span' + } &> +% } + </span> + </TD> <TH ALIGN="right"><% $stateid_state_label %></TH> <TD><% $cust_main->stateid_state || ' ' %></TD> </TR> diff --git a/httemplate/view/cust_main/contacts_new.html b/httemplate/view/cust_main/contacts_new.html index fe412cc00..9252b2197 100644 --- a/httemplate/view/cust_main/contacts_new.html +++ b/httemplate/view/cust_main/contacts_new.html @@ -22,6 +22,7 @@ % my $bgcolor1 = '#ffffff'; % my $bgcolor2 = '#eeeeee'; % my $bgcolor = $bgcolor2; +% my $count = 0; % foreach my $cust_contact ( @cust_contacts ) { % my $contact = $cust_contact->contact; % my $td = qq(<TD CLASS="grid" BGCOLOR="$bgcolor">); @@ -39,6 +40,16 @@ Enabled %# <FONT SIZE="-1"><A HREF="XXX">disable</A> %# <A HREF="XXX">re-email</A></FONT> + <FONT SIZE="-1"> + <& /elements/change_password.html, + 'contact_num' => $cust_contact->contactnum, + 'custnum' => $cust_contact->custnum, + 'no_label_display' => '', + 'label' => 'change password', + 'curr_value' => '', + 'pre_pwd_field_label' => 'contact'.$count.'_', + &> + </FONT> % } else { Disabled %# <FONT SIZE="-1"><A HREF="XXX">enable</A></FONT> @@ -63,6 +74,7 @@ % } else { % $bgcolor = $bgcolor1; % } +% $count++; % } </TABLE> %} @@ -80,6 +92,6 @@ my @cust_contacts = $cust_main->cust_contact; # residential customers have a default "invisible" contact, but if they # somehow get more than one contact, show them -my $display = scalar(@cust_contacts) > 1; +my $display = scalar(@cust_contacts) > 0; </%init> diff --git a/httemplate/view/cust_main/menu.html b/httemplate/view/cust_main/menu.html index f3aca21e8..7ec4d07db 100644 --- a/httemplate/view/cust_main/menu.html +++ b/httemplate/view/cust_main/menu.html @@ -460,7 +460,7 @@ my @menu = ( ## condition => sub { $payby{MCHK} }, #}, { - label => 'Batch Electronic check refund', + label => 'Enter electronic check refund', popup => "edit/cust_refund.cgi?popup=1;payby=CHEK;custnum=$custnum", actionlabel => 'Enter electronic check refund', width => 440, diff --git a/httemplate/view/prospect_main.html b/httemplate/view/prospect_main.html index f4dd4146f..504a5a8ec 100644 --- a/httemplate/view/prospect_main.html +++ b/httemplate/view/prospect_main.html @@ -24,8 +24,21 @@ % foreach my $prospect_contact ( $prospect_main->prospect_contact ) { % my $contact = $prospect_contact->contact; <TR> - <TH ALIGN="right"><% $prospect_contact->contact_classname %> Contact</TD> - <TD BGCOLOR="#FFFFFF"><% $contact->line %></TD> + <TH ALIGN="right" VALIGN="top"><% $prospect_contact->contact_classname %> Contact</TH> + <TD BGCOLOR="#FFFFFF"> + <% $contact->line %><br> + <table> +% for my $row ( $contact->contact_email ) { + <tr><th>E-Mail:</th><td><% $row->emailaddress %></td></tr> +% } +% for my $row ( $contact->contact_phone ) { + <tr><th><% $row->phone_type->typename %>:</th><td><% $row->phonenum_pretty %></td></tr> +% } +% if ( $prospect_contact->comment ) { + <tr><th>Comment:</th><td><% $prospect_contact->comment %></td></tr> +% } + </table> + </TD> </TR> %} diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi index 0517c307a..189fe5e6f 100644 --- a/httemplate/view/svc_broadband.cgi +++ b/httemplate/view/svc_broadband.cgi @@ -33,6 +33,9 @@ my @fields = ( { field => 'routernum', value_callback => \&router }, 'speed_down', 'speed_up', + 'speed_test_down', + 'speed_test_up', + 'speed_test_latency', { field => 'ip_addr', value_callback => \&ip_addr }, { field => 'sectornum', value_callback => \§ornum }, { field => 'mac_addr', type=>'mac_addr', value_callback => \&mac_addr }, diff --git a/httemplate/view/svc_export/run_script.cgi b/httemplate/view/svc_export/run_script.cgi new file mode 100644 index 000000000..ba58bbdd7 --- /dev/null +++ b/httemplate/view/svc_export/run_script.cgi @@ -0,0 +1,31 @@ +<% $server->process %> +<%init> + +my @args = $cgi->param('arg'); +my %param = (); + while ( @args ) { + my( $field, $value ) = splice(@args, 0, 2); + unless ( exists( $param{$field} ) ) { + $param{$field} = $value; + } elsif ( ! ref($param{$field}) ) { + $param{$field} = [ $param{$field}, $value ]; + } else { + push @{$param{$field}}, $value; + } + } + +my $exportnum; +my $method; +for (grep /^*_script$/, keys %param) { + $exportnum = $param{$param{$_}.'_exportnum'}; + $method = $param{$param{$_}.'_script'}; +} + +my $part_export = qsearchs('part_export', { 'exportnum'=> $exportnum, } ) + or die "unknown exportnum $exportnum"; + +my $class = 'FS::part_export::'.$part_export->{Hash}->{exporttype}.'::'.$method; + +my $server = new FS::UI::Web::JSRPC $class, $cgi; + +</%init>
\ No newline at end of file |