summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-07-06 17:30:47 -0700
committerMark Wells <mark@freeside.biz>2013-07-06 17:30:47 -0700
commit8240403713de07e6b9c1d8a645838791e80823b7 (patch)
treecc9e0f177e9a764b9dc231f1a1458cdb7104ce9e /httemplate
parent5e4d3c3f6b9b1aa27ff66f4c772f8f8a8c7ade54 (diff)
delayed package start option, #20686
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/part_pkg.cgi11
-rw-r--r--httemplate/elements/order_pkg.js25
-rw-r--r--httemplate/elements/select-part_pkg.html1
-rw-r--r--httemplate/elements/tr-select-cust-part_pkg.html13
-rw-r--r--httemplate/misc/cust-part_pkg.cgi13
-rw-r--r--httemplate/misc/order_pkg.html10
6 files changed, 52 insertions, 21 deletions
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index 89f16158f..c13caf588 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -65,6 +65,7 @@
'report_option' => 'Report classes',
'fcc_ds0s' => 'Voice-grade equivalents',
'fcc_voip_class' => 'Category',
+ 'delay_start' => 'Default delay (days)',
},
'fields' => [
@@ -199,6 +200,16 @@
{ field=>'setup_cost', type=>'money', },
{ field=>'recur_cost', type=>'money', },
+ ( $conf->exists('part_pkg-delay_start')
+ ? ( { type => 'tablebreak-tr-title',
+ value => 'Delayed start',
+ },
+ { field => 'delay_start',
+ type => 'text', size => 6 },
+ )
+ : ()
+ ),
+
{ type => 'columnnext' },
{ field => 'agent_type',
diff --git a/httemplate/elements/order_pkg.js b/httemplate/elements/order_pkg.js
index 1069a0ee4..762b2ddde 100644
--- a/httemplate/elements/order_pkg.js
+++ b/httemplate/elements/order_pkg.js
@@ -4,9 +4,15 @@ function pkg_changed () {
if ( form.pkgpart.selectedIndex > 0 ) {
+ var opt = form.pkgpart.options[form.pkgpart.selectedIndex];
+ var date_button = document.getElementById('start_date_button');
+ var date_button_disabled = document.getElementById('start_date_button_disabled');
+ var date_text = document.getElementById('start_date_text');
+
+
form.submitButton.disabled = false;
if ( discountnum ) {
- if ( form.pkgpart.options[form.pkgpart.selectedIndex].getAttribute('data-can_discount') == 1 ) {
+ if ( opt.getAttribute('data-can_discount') == 1 ) {
form.discountnum.disabled = false;
discountnum_changed(form.discountnum);
} else {
@@ -15,14 +21,17 @@ function pkg_changed () {
}
}
- if ( form.pkgpart.options[form.pkgpart.selectedIndex].getAttribute('data-can_start_date') == 1 ) {
- form.start_date_text.disabled = false;
- form.start_date.style.backgroundColor = '#ffffff';
- form.start_date_button.style.display = '';
+ form.start_date_text.value = opt.getAttribute('data-start_date');
+ if ( opt.getAttribute('data-can_start_date') == 1 ) {
+ date_text.style.backgroundColor = '#ffffff';
+ date_text.disabled = false;
+ date_button.style.display = '';
+ date_button_disabled.style.display = 'none';
} else {
- form.start_date_text.disabled = true;
- form.start_date.style.backgroundColor = '#dddddd';
- form.start_date_button.style.display = 'none';
+ date_text.style.backgroundColor = '#dddddd';
+ date_text.disabled = true;
+ date_button.style.display = 'none';
+ date_button_disabled.style.display = '';
}
} else {
diff --git a/httemplate/elements/select-part_pkg.html b/httemplate/elements/select-part_pkg.html
index 439c4b53e..9d41b07dc 100644
--- a/httemplate/elements/select-part_pkg.html
+++ b/httemplate/elements/select-part_pkg.html
@@ -23,7 +23,6 @@ Example:
'empty_label' => 'Select package', #should this be the default?
'label_callback' => sub { shift->pkg_comment },
'hashref' => \%hash,
- 'extra_option_attributes' => [ 'can_discount', 'can_start_date' ],
%opt,
)
%>
diff --git a/httemplate/elements/tr-select-cust-part_pkg.html b/httemplate/elements/tr-select-cust-part_pkg.html
index 848ab0a4b..b9dc5a75a 100644
--- a/httemplate/elements/tr-select-cust-part_pkg.html
+++ b/httemplate/elements/tr-select-cust-part_pkg.html
@@ -7,10 +7,11 @@
<SCRIPT TYPE="text/javascript">
- function part_pkg_opt(what, value, text, can_discount, can_start_date) {
+ function part_pkg_opt(what, value, text, can_discount, can_start_date, start_date) {
var optionName = new Option(text, value, false, false);
optionName.setAttribute('data-can_discount', can_discount);
optionName.setAttribute('data-can_start_date', can_start_date);
+ optionName.setAttribute('data-start_date', start_date);
var length = what.length;
what.options[length] = optionName;
}
@@ -38,12 +39,14 @@
// add the new packages
opt(what.form.pkgpart, '', 'Select package');
var packagesArray = eval('(' + part_pkg + ')' );
- for ( var s = 0; s < packagesArray.length; s=s+4 ) {
+ for ( var s = 0; s < packagesArray.length; s=s+5 ) {
+ //surely this should be some kind of JSON structure
var packagesLabel = packagesArray[s+1];
var can_discount = packagesArray[s+2];
var can_start_date = packagesArray[s+3];
+ var start_date = packagesArray[s+4];
part_pkg_opt(
- what.form.pkgpart, packagesArray[s], packagesLabel, can_discount, can_start_date
+ what.form.pkgpart, packagesArray[s], packagesLabel, can_discount, can_start_date, start_date
);
}
@@ -58,6 +61,10 @@
);
}
+ window.onload = function() {
+ classnum_changed(document.getElementById('classnum'));
+ }
+
</SCRIPT>
<TR>
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/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'));