diff options
Diffstat (limited to 'httemplate/misc')
| -rw-r--r-- | httemplate/misc/bulk_suspend_pkg.cgi | 94 | ||||
| -rw-r--r-- | httemplate/misc/bulk_unsuspend_pkg.cgi | 66 | ||||
| -rw-r--r-- | httemplate/misc/download-batch.cgi | 11 | ||||
| -rw-r--r-- | httemplate/misc/email-customers.html | 80 | ||||
| -rw-r--r-- | httemplate/misc/process/bulk_suspend_pkg.cgi | 106 | ||||
| -rw-r--r-- | httemplate/misc/process/bulk_unsuspend_pkg.cgi | 91 | ||||
| -rw-r--r-- | httemplate/misc/process/contact-import.cgi | 2 |
7 files changed, 440 insertions, 10 deletions
diff --git a/httemplate/misc/bulk_suspend_pkg.cgi b/httemplate/misc/bulk_suspend_pkg.cgi new file mode 100644 index 000000000..e41ea2b1a --- /dev/null +++ b/httemplate/misc/bulk_suspend_pkg.cgi @@ -0,0 +1,94 @@ +<% include('/elements/header-popup.html', "Suspend Packages") %> + +% if ( $cgi->param('error') ) { + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> + <BR><BR> +% } + +<FORM ACTION="<% $p %>misc/process/bulk_suspend_pkg.cgi" METHOD=POST> + +%# some false laziness w/search/cust_pkg.cgi + +<INPUT TYPE="hidden" NAME="query" VALUE="<% $cgi->keywords |h %>"> +% for my $param ( +% qw( +% agentnum cust_status cust_main_salesnum salesnum custnum magic status +% custom pkgbatch zip reasonnum +% 477part 477rownum date +% report_option +% ), +% grep { /^location_\w+$/ || /^report_option_any/ } $cgi->param +% ) { + <INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $cgi->param($param) |h %>"> +% } +% +% for my $param (qw( censustract censustract2 ) ) { +% next unless grep { $_ eq $param } $cgi->param; + <INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $cgi->param($param) |h %>"> +% } +% +% for my $param (qw( pkgpart classnum refnum towernum )) { +% foreach my $value ($cgi->param($param)) { + <INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $value |h %>"> +% } +% } +% +% foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) { +% + <INPUT TYPE="hidden" NAME="<% $field %>_null" VALUE="<% $cgi->param("${field}_null") |h %>"> + <INPUT TYPE="hidden" NAME="<% $field %>_begin" VALUE="<% $cgi->param("${field}_begin") |h %>"> + <INPUT TYPE="hidden" NAME="<% $field %>_beginning" VALUE="<% $cgi->param("${field}_beginning") |h %>"> + <INPUT TYPE="hidden" NAME="<% $field %>_end" VALUE="<% $cgi->param("${field}_end") |h %>"> + <INPUT TYPE="hidden" NAME="<% $field %>_ending" VALUE="<% $cgi->param("${field}_ending") |h %>"> +% } + +<% ntable('#cccccc') %> + +% my $date_init = 0; + <& /elements/tr-input-date-field.html, { + 'name' => 'suspend_date', + 'value' => $date, + 'label' => mt("Suspend package on"), + 'format' => $date_format, + } &> +% $date_init = 1; + + <& /elements/tr-select-reason.html, + field => 'suspend_reasonnum', + reason_class => 'S', + &> + +% if ( $FS::CurrentUser::CurrentUser->access_right('Unsuspend customer package')) { + + <& /elements/tr-input-date-field.html, { + 'name' => 'suspend_resume_date', + 'value' => '', + 'label' => mt('Unsuspend on'), + 'format' => $date_format, + 'noinit' => $date_init, + } &> +% } + +</TABLE> + +<BR> +<INPUT TYPE="submit" VALUE="Suspend Packages"> + +</FORM> +</BODY> +</HTML> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages'); + +#use Date::Parse qw(str2time); +#<table style="background-color: #cccccc; border-spacing: 2; width: 100%"> + +my $conf = new FS::Conf; +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; + +my $date = time; + +</%init>
\ No newline at end of file diff --git a/httemplate/misc/bulk_unsuspend_pkg.cgi b/httemplate/misc/bulk_unsuspend_pkg.cgi new file mode 100644 index 000000000..8fbc41841 --- /dev/null +++ b/httemplate/misc/bulk_unsuspend_pkg.cgi @@ -0,0 +1,66 @@ +<% include('/elements/header-popup.html', "Unsuspend Packages") %> + +% if ( $cgi->param('error') ) { + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> + <BR><BR> +% } + +<FORM ACTION="<% $p %>misc/process/bulk_unsuspend_pkg.cgi" METHOD=POST> + +%# some false laziness w/search/cust_pkg.cgi + +<INPUT TYPE="hidden" NAME="query" VALUE="<% $cgi->keywords |h %>"> +% for my $param ( +% qw( +% agentnum cust_status cust_main_salesnum salesnum custnum magic status +% custom pkgbatch zip reasonnum +% 477part 477rownum date +% report_option +% ), +% grep { /^location_\w+$/ || /^report_option_any/ } $cgi->param +% ) { + <INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $cgi->param($param) |h %>"> +% } +% +% for my $param (qw( censustract censustract2 ) ) { +% next unless grep { $_ eq $param } $cgi->param; + <INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $cgi->param($param) |h %>"> +% } +% +% for my $param (qw( pkgpart classnum refnum towernum )) { +% foreach my $value ($cgi->param($param)) { + <INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $value |h %>"> +% } +% } +% +% foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) { +% + <INPUT TYPE="hidden" NAME="<% $field %>_null" VALUE="<% $cgi->param("${field}_null") |h %>"> + <INPUT TYPE="hidden" NAME="<% $field %>_begin" VALUE="<% $cgi->param("${field}_begin") |h %>"> + <INPUT TYPE="hidden" NAME="<% $field %>_beginning" VALUE="<% $cgi->param("${field}_beginning") |h %>"> + <INPUT TYPE="hidden" NAME="<% $field %>_end" VALUE="<% $cgi->param("${field}_end") |h %>"> + <INPUT TYPE="hidden" NAME="<% $field %>_ending" VALUE="<% $cgi->param("${field}_ending") |h %>"> +% } + +<% ntable('#cccccc') %> + + <TR> + <TD><INPUT TYPE="checkbox" NAME="confirm"></TD> + <TD>Confirm Unsuspend Packages</TD> + </TR> + +</TABLE> + +<BR> +<INPUT TYPE="submit" VALUE="Unsuspend Packages"> + +</FORM> +</BODY> +</HTML> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages'); + +</%init> diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi index f3a31eb3b..7b56f2aa1 100644 --- a/httemplate/misc/download-batch.cgi +++ b/httemplate/misc/download-batch.cgi @@ -20,7 +20,16 @@ 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'); +} + </%init> diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index b8ba99705..1c22f8ffd 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -46,6 +46,7 @@ should be used to set msgnum or from/subject/html_body cgi params <INPUT TYPE="hidden" NAME="search" VALUE="<% encode_base64(nfreeze(\%search)) %>"> <INPUT TYPE="hidden" NAME="popup" VALUE="<% $popup %>"> <INPUT TYPE="hidden" NAME="url" VALUE="<% $url | h %>"> +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% scalar($cgi->param('custnum')) |h %>"> % if ( $cgi->param('action') eq 'send' ) { @@ -55,13 +56,12 @@ should be used to set msgnum or from/subject/html_body cgi params <& /elements/progress-init.html, 'OneTrueForm', [ qw( search table from subject html_body text_body - msgnum to_contact_classnum ) ], + msgnum to_contact_classnum emailtovoice_contact custnum ) ], $process_url, $pdest, &> % } elsif ( $cgi->param('action') eq 'preview' ) { - <INPUT TYPE="hidden" NAME="to_contact_classnum" VALUE="<% join(',', @contact_classnum) %>"> <FONT SIZE="+2">Preview notice</FONT> @@ -71,6 +71,7 @@ should be used to set msgnum or from/subject/html_body cgi params <TABLE BGCOLOR="#cccccc" CELLSPACING=0> <INPUT TYPE="hidden" NAME="msgnum" VALUE="<% scalar($cgi->param('msgnum')) %>"> + <INPUT TYPE="hidden" NAME="emailtovoice_contact" VALUE="<% scalar $cgi->param('emailtovoice_contact') |h %>"> % if ( $msg_template ) { <% include('/elements/tr-fixed.html', 'label' => 'Template:', @@ -151,7 +152,11 @@ Template: &> <BR> % # select destination contact classes -Send to contacts: +<TABLE CELLSPACING=0 id="send_to_contacts_table"> +<TR> + <TD>Send to contacts:</TD> + <TD> + <div id="contactclassesdiv"> <& /elements/checkboxes.html, 'style' => 'display: inline; vertical-align: top', 'disable_links' => 1, @@ -162,6 +167,24 @@ Send to contacts: $name eq 'invoice' #others default to unchecked }, &> + </div> +% if ($send_to_domain) { + <div> + <INPUT TYPE="checkbox" NAME="emailtovoice" ID="emailtovoice" VALUE="ON" onclick="toggleDiv(this)">Email to voice + </div> + <div id="emailtovoicediv" style="display:none"> + + <& /elements/select-cust_phone.html, + 'cust_num' => $cgi->param('custnum'), + 'field_name' => 'emailtovoice_contact', + 'format' => 'xxxxxxxxxx', + 'phone_types' => [ 'daytime', 'night', 'fax', 'mobile' ], + &>@<% $send_to_domain |h %> + </div> +% } + </TD> +</TR> +</TABLE> <BR> % # if sending a one-off message, show a form to edit it <TABLE BGCOLOR="#cccccc" CELLSPACING=0 WIDTH="100%" id="table_no_template"> @@ -199,6 +222,7 @@ Send to contacts: %#Substitution vars: <INPUT TYPE="hidden" NAME="action" VALUE="preview"> + <INPUT TYPE="hidden" NAME="custnum" VALUE="<% scalar($cgi->param('custnum')) |h %>"> <INPUT TYPE="submit" VALUE="Preview notice"> % } #end not action or alternate form @@ -211,6 +235,18 @@ Send to contacts: </SCRIPT> % } +<SCRIPT TYPE="text/javascript"> +function toggleDiv(obj) { + var box_contactclasses = document.getElementById('contactclassesdiv'); + var box_emailtovoice = document.getElementById('emailtovoicediv'); + + box_emailtovoice.style.display = (box_emailtovoice.style.display == 'none') ? 'block' : 'none'; + document.getElementById('emailtovoice_contact').options[0].selected=true; + + box_contactclasses.style.display = (box_contactclasses.style.display == 'none') ? 'block' : 'none'; +} +</SCRIPT> + <& /elements/footer.html &> <%init> @@ -219,12 +255,16 @@ my %opt = @_; $opt{'acl'} ||= 'Bulk send customer notices'; +my $email_to; + die "access denied" unless $FS::CurrentUser::CurrentUser->access_right($opt{'acl'}); my $conf = FS::Conf->new; my @no_search_fields = qw( action table from subject html_body text_body popup url ); +my $send_to_domain = $conf->config('email-to-voice_domain'); + my $form_action = $opt{'form_action'} || 'email-customers.html'; my $process_url = $opt{'process_url'} || 'process/email-customers.html'; my $title = $opt{'title'} || 'Send customer notices'; @@ -237,6 +277,7 @@ my $agent_virt_agentnum = $cgi->param('agent_virt_agentnum') || ''; my $popup = $cgi->param('popup'); my $url = $cgi->param('url'); +if (!$url && $cgi->param('custnum')) { $url = $fsurl."view/cust_main.cgi?".$cgi->param('custnum'); } my $pdest = { 'message' => "Notice sent" }; $pdest->{'url'} = $cgi->param('url') if $url; @@ -307,19 +348,40 @@ if ( $cgi->param('action') eq 'preview' ) { my %message = $msg_template->prepare(%msgopts); ($from, $subject, $html_body) = @message{'from', 'subject', 'html_body'}; } +} + +if ($cgi->param('action')) { # contact_class_X params in preview - foreach my $param ( $cgi->param ) { - if ( $param =~ /^contact_class_(\w+)$/ ) { - push @contact_classnum, $1; - if ( $1 eq 'invoice' ) { + if ($cgi->param('emailtovoice_contact')) { + $email_to = $cgi->param('emailtovoice_contact') . '@' . $send_to_domain; + push @contact_classnum, 'emailtovoice'; + push @contact_classname, $email_to; + } + elsif ($cgi->param('to_contact_classnum')) { + foreach my $c (split(/,/, $cgi->param('to_contact_classnum'))) { + push @contact_classnum, $c; + if ( $c eq 'invoice' ) { push @contact_classname, 'Invoice recipients'; } else { - my $contact_class = FS::contact_class->by_key($1); + my $contact_class = FS::contact_class->by_key($c); push @contact_classname, encode_entities($contact_class->classname); } } } + else { + foreach my $param ( $cgi->param ) { + if ( $param =~ /^contact_class_(\w+)$/ ) { + push @contact_classnum, $1; + if ( $1 eq 'invoice' ) { + push @contact_classname, 'Invoice recipients'; + } else { + my $contact_class = FS::contact_class->by_key($1); + push @contact_classname, encode_entities($contact_class->classname); + } + } + } + } } @@ -327,10 +389,12 @@ if ( $cgi->param('action') eq 'preview' ) { my @contact_checkboxes = ( [ 'invoice' => { label => 'Invoice recipients' } ] ); + foreach my $class (qsearch('contact_class', { disabled => '' })) { push @contact_checkboxes, [ $class->classnum, { label => $class->classname } ]; } + </%init> diff --git a/httemplate/misc/process/bulk_suspend_pkg.cgi b/httemplate/misc/process/bulk_suspend_pkg.cgi new file mode 100644 index 000000000..2ac9c212f --- /dev/null +++ b/httemplate/misc/process/bulk_suspend_pkg.cgi @@ -0,0 +1,106 @@ +% if ($error) { +<% $cgi->redirect(popurl(2)."bulk_suspend_pkg.cgi?".$cgi->query_string ) %> +% } +<% include('/elements/popup-topreload.html', "Packages Suspended") %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages'); + +my $error; + +if (!$error) { + + my %search_hash = (); + + $search_hash{'query'} = $cgi->param('query'); + + #scalars + for (qw( agentnum cust_status cust_main_salesnum salesnum custnum magic status + custom cust_fields pkgbatch zip reasonnum + 477part 477rownum date + )) + { + $search_hash{$_} = $cgi->param($_) if length($cgi->param($_)); + } + + #arrays + for my $param (qw( pkgpart classnum refnum towernum )) { + $search_hash{$param} = [ $cgi->param($param) ] + if grep { $_ eq $param } $cgi->param; + } + + #scalars that need to be passed if empty + for my $param (qw( censustract censustract2 )) { + $search_hash{$param} = $cgi->param($param) || '' + if grep { $_ eq $param } $cgi->param; + } + + #location flags (checkboxes) + my @loc = grep /^\w+$/, $cgi->param('loc'); + $search_hash{"location_$_"} = 1 foreach @loc; + + my $report_option = $cgi->param('report_option'); + $search_hash{report_option} = $report_option if $report_option; + + for my $param (grep /^report_option_any/, $cgi->param) { + $search_hash{$param} = $cgi->param($param); + } + + ### + # parse dates + ### + + #false laziness w/report_cust_pkg.html and bulk_pkg_increment_bill.cgi + my %disable = ( + 'all' => {}, + 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, }, + 'active' => { 'susp'=>1, 'cancel'=>1 }, + 'suspended' => { 'cancel' => 1 }, + 'cancelled' => {}, + '' => {}, + ); + + foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) { + + $search_hash{$field.'_null'} = scalar( $cgi->param($field.'_null') ); + + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field); + + next if $beginning == 0 && $ending == 4294967295 + or $disable{$cgi->param('status')}->{$field}; + + $search_hash{$field} = [ $beginning, $ending ]; + + } + + my $sql_query = FS::cust_pkg->search(\%search_hash); + $sql_query->{'select'} = 'cust_pkg.pkgnum'; + + ## set suspend info + $cgi->param('suspend_reasonnum') =~ /^(\d+)$/ or die "Illegal Reason"; + my $suspend_reasonnum = $1; + + my $suspend_date = time; + parse_datetime($cgi->param('suspend_date')) =~ /^(\d+)$/ or die "Illegal date"; + $suspend_date = $1; + + my $suspend_resume_date = ''; + (parse_datetime($cgi->param('suspend_resume_date')) =~ /^(\d+)$/ or die "Illegal resume date") if $cgi->param('suspend_resume_date'); + $suspend_resume_date = $1; + + foreach my $pkgnum (map { $_->pkgnum } qsearch($sql_query)) { + my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); + + $error = $cust_pkg->suspend('reason' => $suspend_reasonnum, + 'date' => $suspend_date, + 'resume_date' => $suspend_resume_date, + ); + } + +} + +$cgi->param("error", substr($error, 0, 512)); # arbitrary length believed + # suited for all supported + # browsers +</%init>
\ No newline at end of file diff --git a/httemplate/misc/process/bulk_unsuspend_pkg.cgi b/httemplate/misc/process/bulk_unsuspend_pkg.cgi new file mode 100644 index 000000000..13389f43a --- /dev/null +++ b/httemplate/misc/process/bulk_unsuspend_pkg.cgi @@ -0,0 +1,91 @@ +% if ($error) { +<% $cgi->redirect(popurl(2)."bulk_unsuspend_pkg.cgi?".$cgi->query_string ) %> +% } +<% include('/elements/popup-topreload.html', "Packages Unsuspended") %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages'); + +my $error; +$error = 'Unsuspend packages not confirmed' if !$cgi->param('confirm'); + +if (!$error) { + + my %search_hash = (); + + $search_hash{'query'} = $cgi->param('query'); + + #scalars + for (qw( agentnum cust_status cust_main_salesnum salesnum custnum magic status + custom cust_fields pkgbatch zip reasonnum + 477part 477rownum date + )) + { + $search_hash{$_} = $cgi->param($_) if length($cgi->param($_)); + } + + #arrays + for my $param (qw( pkgpart classnum refnum towernum )) { + $search_hash{$param} = [ $cgi->param($param) ] + if grep { $_ eq $param } $cgi->param; + } + + #scalars that need to be passed if empty + for my $param (qw( censustract censustract2 )) { + $search_hash{$param} = $cgi->param($param) || '' + if grep { $_ eq $param } $cgi->param; + } + + #location flags (checkboxes) + my @loc = grep /^\w+$/, $cgi->param('loc'); + $search_hash{"location_$_"} = 1 foreach @loc; + + my $report_option = $cgi->param('report_option'); + $search_hash{report_option} = $report_option if $report_option; + + for my $param (grep /^report_option_any/, $cgi->param) { + $search_hash{$param} = $cgi->param($param); + } + + ### + # parse dates + ### + + #false laziness w/report_cust_pkg.html and bulk_pkg_increment_bill.cgi + my %disable = ( + 'all' => {}, + 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, }, + 'active' => { 'susp'=>1, 'cancel'=>1 }, + 'suspended' => { 'cancel' => 1 }, + 'cancelled' => {}, + '' => {}, + ); + + foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) { + + $search_hash{$field.'_null'} = scalar( $cgi->param($field.'_null') ); + + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field); + + next if $beginning == 0 && $ending == 4294967295 + or $disable{$cgi->param('status')}->{$field}; + + $search_hash{$field} = [ $beginning, $ending ]; + + } + + my $sql_query = FS::cust_pkg->search(\%search_hash); + $sql_query->{'select'} = 'cust_pkg.pkgnum'; + + foreach my $pkgnum (map { $_->pkgnum } qsearch($sql_query)) { + my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); + $error = $cust_pkg->unsuspend; + } + +} + +$cgi->param("error", substr($error, 0, 512)); # arbitrary length believed + # suited for all supported + # browsers +</%init>
\ No newline at end of file diff --git a/httemplate/misc/process/contact-import.cgi b/httemplate/misc/process/contact-import.cgi index cbdcad455..108ee93e9 100644 --- a/httemplate/misc/process/contact-import.cgi +++ b/httemplate/misc/process/contact-import.cgi @@ -5,6 +5,6 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Import'); my $server = - new FS::UI::Web::JSRPC 'FS::contact_import::process_batch_import', $cgi; + new FS::UI::Web::JSRPC 'FS::contact::Import::process_batch_import', $cgi; </%init> |
