diff options
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-x | httemplate/misc/change_pkg.cgi | 29 | ||||
-rw-r--r-- | httemplate/misc/change_pkg_now.cgi | 22 | ||||
-rw-r--r-- | httemplate/misc/cust-part_pkg.cgi | 13 | ||||
-rw-r--r-- | httemplate/misc/do_not_change_pkg.cgi | 20 | ||||
-rw-r--r-- | httemplate/misc/order_pkg.html | 10 |
5 files changed, 83 insertions, 11 deletions
diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi index 03e336cba..7425fbfaf 100755 --- a/httemplate/misc/change_pkg.cgi +++ b/httemplate/misc/change_pkg.cgi @@ -1,7 +1,6 @@ -<& /elements/header-popup.html, mt("Change Package") &> +<& /elements/header-popup.html, mt($title) &> <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT> - <& /elements/error.html &> <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/change-cust_pkg.html" METHOD=POST> @@ -30,6 +29,21 @@ </TABLE> +<TABLE> + <TR> + <TD> Apply this change: </TD> + <TD> <INPUT TYPE="radio" NAME="delay" VALUE="0" \ + <% !$cgi->param('delay') ? 'CHECKED' : '' %>> now </TD> + <TD> <INPUT TYPE="radio" NAME="delay" VALUE="1" \ + <% $cgi->param('delay') ? 'CHECKED' : '' %>> in the future + <& /elements/input-date-field.html, { + 'name' => 'start_date', + 'value' => ($cgi->param('start_date') || $cust_main->next_bill_date), + } &> + </TD> + </TR> +</TABLE> + <& /elements/standardize_locations.html, 'form' => "OrderPkgForm", 'callback' => 'document.OrderPkgForm.submit();', @@ -74,4 +88,15 @@ my $cust_main = $cust_pkg->cust_main my $part_pkg = $cust_pkg->part_pkg; +my $title = "Change Package"; + +# if there's already a package change ordered, preload it +if ( $cust_pkg->change_to_pkgnum ) { + my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum); + $cgi->param('delay', 1); + foreach(qw( start_date pkgpart locationnum )) { + $cgi->param($_, $change_to->get($_)); + } + $title = "Edit Scheduled Package Change"; +} </%init> diff --git a/httemplate/misc/change_pkg_now.cgi b/httemplate/misc/change_pkg_now.cgi new file mode 100644 index 000000000..73ee74020 --- /dev/null +++ b/httemplate/misc/change_pkg_now.cgi @@ -0,0 +1,22 @@ +%if ( $error ) { +% errorpage($error); +%} else { +<% $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')) %> +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Change customer package'); + +#untaint pkgnum +my ($query) = $cgi->keywords; +$query =~ /^(\d+)$/ || die "Illegal pkgnum"; +my $pkgnum = $1; + +my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum); + +my $err_or_pkg = $cust_pkg->change({ 'cust_pkg' => $change_to }); +my $error = $err_or_pkg unless ref($err_or_pkg); + +</%init> diff --git a/httemplate/misc/cust-part_pkg.cgi b/httemplate/misc/cust-part_pkg.cgi index 43b92297e..7aebda40c 100644 --- a/httemplate/misc/cust-part_pkg.cgi +++ b/httemplate/misc/cust-part_pkg.cgi @@ -5,8 +5,9 @@ my( $custnum, $prospectnum, $classnum ) = $cgi->param('arg'); my $agent; +my $cust_main; if ( $custnum ) { - my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) or die 'unknown custnum'; $agent = $cust_main->agent; } else { @@ -31,12 +32,18 @@ my @part_pkg = qsearch({ 'order_by' => 'ORDER BY pkg', }); -my @return = map { warn $_->can_start_date; +my $date_format = FS::Conf->new->config('date_format') || '%m/%d/%Y'; + +my @return = map { + my $start_date = $_->default_start_date($cust_main); + $start_date = time2str($date_format, $start_date) + if $start_date; ( $_->pkgpart, $_->pkg_comment, $_->can_discount, $_->can_start_date, - ); + $start_date, + ) } #sort { $a->pkg_comment cmp $b->pkg_comment } @part_pkg; diff --git a/httemplate/misc/do_not_change_pkg.cgi b/httemplate/misc/do_not_change_pkg.cgi new file mode 100644 index 000000000..c164c5c15 --- /dev/null +++ b/httemplate/misc/do_not_change_pkg.cgi @@ -0,0 +1,20 @@ +%if ( $error ) { +% errorpage($error); +%} else { +<% $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')) %> +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Change customer package'); + +#untaint pkgnum +my ($query) = $cgi->keywords; +$query =~ /^(\d+)$/ || die "Illegal pkgnum"; +my $pkgnum = $1; + +my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); + +my $error = $cust_pkg->abort_change; + +</%init> diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html index 39734427e..a257e53e3 100644 --- a/httemplate/misc/order_pkg.html +++ b/httemplate/misc/order_pkg.html @@ -54,9 +54,12 @@ <& /elements/input-date-field.html,{ 'name' => 'start_date', 'format' => $date_format, - 'value' => $start_date, + 'value' => '', 'noinit' => 1, } &> + <IMG SRC = "<%$fsurl%>images/calendar-disabled.png" + ID = "start_date_button_disabled" + STYLE = "display:none"> <FONT SIZE=-1>(<% mt('leave blank to start immediately') |h %>)</FONT> </TD> </TR> @@ -213,11 +216,6 @@ if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) { } my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi? -my $start_date = ''; -if( ! $conf->exists('order_pkg-no_start_date') && $cust_main ) { - $start_date = $cust_main->next_bill_date; - $start_date = $start_date ? time2str($format, $start_date) : ''; -} my $svcpart = scalar($cgi->param('svcpart')); |