diff options
Diffstat (limited to 'httemplate')
| -rw-r--r-- | httemplate/elements/input-date-field.html | 48 | ||||
| -rw-r--r-- | httemplate/misc/cancel_cust.html | 42 | ||||
| -rwxr-xr-x | httemplate/misc/cust_main-cancel.cgi | 31 | ||||
| -rwxr-xr-x | httemplate/view/cust_main.cgi | 1 | 
4 files changed, 109 insertions, 13 deletions
| diff --git a/httemplate/elements/input-date-field.html b/httemplate/elements/input-date-field.html new file mode 100644 index 000000000..0ea4be70a --- /dev/null +++ b/httemplate/elements/input-date-field.html @@ -0,0 +1,48 @@ + +<LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2"> +<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar_stripped.js"></SCRIPT> +<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-en.js"></SCRIPT> +<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-setup.js"></SCRIPT> + +<INPUT TYPE="text" NAME="<% $name %>" ID="<% $name %>_text" VALUE="<% $value %>"> +<IMG SRC="<%$fsurl%>images/calendar.png" ID="<% $name  %>_button" STYLE="cursor: pointer" TITLE="Select date"> + +<SCRIPT TYPE="text/javascript"> +  Calendar.setup({ +    inputField: "<% $name %>_text", +    ifFormat:   "<% $format %>", +    button:     "<% $name %>_button", +    align:      "BR" +  }); +</SCRIPT> + +<%init> + +my($name, $value, $format, $usedatetime); +if ( ref($_[0]) ) { +  my $opt = shift; +  $name        = $opt->{'name'}; +  $value       = $opt->{'value'}; +  $format      = $opt->{'format'}; +  $usedatetime = $opt->{'usedatetime'}; +} else { +  ($name, $value, $format, $usedatetime) = @_; +} + +my $conf = new FS::Conf; + +$format ||= $conf->config('date_format') || '%m/%d/%Y'; + +if ( $value =~ /\S/ ) { +  if ( $usedatetime ) { +    my $dt = DateTime->from_epoch(epoch => $value, time_zone => 'floating'); +    $value = $dt->strftime($format); +  } elsif ( $value =~ /^\d+$/ ) { +    $value = time2str($format, $value); +  } +} else { +  $value = ''; +} + +</%init> + diff --git a/httemplate/misc/cancel_cust.html b/httemplate/misc/cancel_cust.html index 12c37ebe2..b7ecccd7e 100644 --- a/httemplate/misc/cancel_cust.html +++ b/httemplate/misc/cancel_cust.html @@ -2,18 +2,46 @@  <% include('/elements/error.html') %> +  <FORM NAME="cust_cancel_popup" ACTION="<% popurl(1) %>cust_main-cancel.cgi" METHOD=POST>  <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">   <P ALIGN="center"><B>Permanently delete all services and cancel this customer?</B> - <% $ban %> -  -<BR><BR> - -<% ntable("#cccccc", 2) %> +<TABLE BORDER="0" CELLSPACING="2" +STYLE="margin-left:auto; margin-right:auto"> +<TR> +  <TD ALIGN="right"> +    <INPUT TYPE="radio" NAME="now_or_later" VALUE="0" onclick="toggle(false)" CHECKED /> +  </TD> +  <TD ALIGN="left">Cancel now</TD> +</TR> +<TR> +  <TD ALIGN="right"> +    <INPUT TYPE="radio" NAME="now_or_later" VALUE="1" onclick="toggle(true)" /> +  </TD> +  <TD ALIGN="left">Cancel on date:  +  <% include('/elements/input-date-field.html', { +              'name'    => 'expire', +              'value'   => time, +    } ) %> +  </TD> +</TR> +</TABLE> +<SCRIPT type="text/javascript"> +function toggle(val) { +  document.getElementById("expire_text").disabled = !val; +  document.getElementById("ban").disabled = val; +  document.getElementById("expire_button").style.visibility =  +    val ? 'visible' : 'hidden'; +} +toggle(false); +</SCRIPT>  +<% $ban %> +<TABLE BGCOLOR="#cccccc", BORDER="0" CELLSPACING="2" +STYLE="margin-left:auto; margin-right:auto">  <% include('/elements/tr-select-reason.html',               'field'          => 'reasonnum',               'reason_class'   => 'C', @@ -50,8 +78,8 @@ die "No customer # $custnum" unless $cust_main;  my $ban = '';  if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) { -  $ban = '<BR><P ALIGN="center">'. -         '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\'s '; +  $ban = '<P ALIGN="center">'. +         '<INPUT TYPE="checkbox" NAME="ban" ID="ban" VALUE="1"> Ban this customer\'s ';    if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {      $ban .= 'credit card';    } elsif (  $cust_main->payby =~ /^(CHEK|DCHK)$/ ) { diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 009a7d41b..44be20c8a 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -1,4 +1,4 @@ -<% header("Customer cancelled") %> +<% include('/elements/header.html', "Customer cancelled") %>    <SCRIPT TYPE="text/javascript">      window.top.location.reload();    </SCRIPT> @@ -11,9 +11,11 @@ die "access denied"  my $custnum;  my $ban = ''; +my $expire = '';  if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {    $custnum = $1;    $ban = $cgi->param('ban'); +  $expire = $cgi->param('expire');  } else {    my($query) = $cgi->keywords;    $query =~ /^(\d+)$/ || die "Illegal custnum"; @@ -42,11 +44,28 @@ my $cust_main = qsearchs( {    'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,  } ); -warn "cancelling $cust_main"; -my @errors = $cust_main->cancel( -  'ban'    => $ban, -  'reason' => $reasonnum, -); +my @errors; +if($cgi->param('now_or_later')) { +  $expire = parse_datetime($expire); +  if($expire) { +    #warn "setting expire dates on custnum#$custnum\n"; +    my @pkgs = $cust_main->ncancelled_pkgs; +    @errors = grep {$_} map { $_->cancel( +      'reason'  => $reasonnum, +      'date'    => $expire, +    ) } @pkgs; +  } +  else { +    @errors = ("error parsing expire date: ".$cgi->param('expire')); +  } +} +else { +  warn "cancelling $cust_main"; +  @errors = $cust_main->cancel( +    'ban'    => $ban, +    'reason' => $reasonnum, +  ); +}  my $error = join(' / ', @errors) if scalar(@errors);  if ( $error ) { diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index cb325e21d..b4a6170c5 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -57,6 +57,7 @@ function areyousure(href, message) {                  'color'       => '#ff0000',                  'cust_main'   => $cust_main,                  'width'       => 616, #make room for reasons +                'height'      => 366,                }              )    %> |  | 
