sub paid_sql {
my ($class, $start, $end, %opt) = @_;
- my $s = $start ? "AND cust_bill_pay._date <= $start" : '';
- my $e = $end ? "AND cust_bill_pay._date > $end" : '';
+ my $s = $start ? "AND cust_pay._date <= $start" : '';
+ my $e = $end ? "AND cust_pay._date > $end" : '';
my $setuprecur =
$opt{setuprecur} =~ /^s/ ? 'setup' :
$opt{setuprecur} =~ /^r/ ? 'recur' :
my $paid = "( SELECT COALESCE(SUM(cust_bill_pay_pkg.amount),0)
FROM cust_bill_pay_pkg JOIN cust_bill_pay USING (billpaynum)
+ JOIN cust_pay USING (paynum)
WHERE cust_bill_pay_pkg.billpkgnum = cust_bill_pkg.billpkgnum
$s $e $setuprecur )";
sub credited_sql {
my ($class, $start, $end, %opt) = @_;
- my $s = $start ? "AND cust_credit_bill._date <= $start" : '';
- my $e = $end ? "AND cust_credit_bill._date > $end" : '';
+ my $s = $start ? "AND cust_credit._date <= $start" : '';
+ my $e = $end ? "AND cust_credit._date > $end" : '';
my $setuprecur =
$opt{setuprecur} =~ /^s/ ? 'setup' :
$opt{setuprecur} =~ /^r/ ? 'recur' :
my $credited = "( SELECT COALESCE(SUM(cust_credit_bill_pkg.amount),0)
FROM cust_credit_bill_pkg JOIN cust_credit_bill USING (creditbillnum)
+ JOIN cust_credit USING (crednum)
WHERE cust_credit_bill_pkg.billpkgnum = cust_bill_pkg.billpkgnum
$s $e $setuprecur )";
New refnum (see L<FS::part_referral>).
+=item quantity
+
+New quantity; if unspecified, the new package will have the same quantity
+as the old.
+
=item cust_pkg
"New" (existing) FS::cust_pkg object. The package's services and other
my $self = shift;
my $opt = ref($_[0]) ? shift : { @_ };
-# my ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg, $refnum) = @_;
-#
-
my $conf = new FS::Conf;
# Transactionize this whole mess
my $time = time;
- #$hash{$_} = $self->$_() foreach qw( last_bill bill );
-
- #$hash{$_} = $self->$_() foreach qw( setup );
-
$hash{'setup'} = $time if $self->setup;
$hash{'change_date'} = $time;
}
$hash{'contactnum'} = $opt->{'contactnum'} if $opt->{'contactnum'};
+ $hash{'quantity'} = $opt->{'quantity'} || $self->quantity;
my $cust_pkg;
if ( $opt->{'cust_pkg'} ) {
=item locationnum
-The pkgpart and locationnum of the new package, with the same
+=item quantity
+
+The pkgpart. locationnum, and quantity of the new package, with the same
meaning as in C<change>.
=back
if $opt->{'pkgpart'} and $opt->{'pkgpart'} != $change_to->pkgpart;
my $new_locationnum = $opt->{'locationnum'}
if $opt->{'locationnum'} and $opt->{'locationnum'} != $change_to->locationnum;
- if ( $new_pkgpart or $new_locationnum ) {
+ my $new_quantity = $opt->{'quantity'}
+ if $opt->{'quantity'} and $opt->{'quantity'} != $change_to->quantity;
+ if ( $new_pkgpart or $new_locationnum or $new_quantity ) {
# it hasn't been billed yet, so in principle we could just edit
# it in place (w/o a package change), but that's bad form.
# So change the package according to the new options...
if $opt->{'pkgpart'} and $opt->{'pkgpart'} != $self->pkgpart;
my $new_locationnum = $opt->{'locationnum'}
if $opt->{'locationnum'} and $opt->{'locationnum'} != $self->locationnum;
- return '' unless $new_pkgpart or $new_locationnum; # wouldn't do anything
+ my $new_quantity = $opt->{'quantity'}
+ if $opt->{'quantity'} and $opt->{'quantity'} != $self->quantity;
+
+ return '' unless $new_pkgpart or $new_locationnum or $new_quantity; # wouldn't do anything
my %hash = (
'custnum' => $self->custnum,
'pkgpart' => ($opt->{'pkgpart'} || $self->pkgpart),
'locationnum' => ($opt->{'locationnum'} || $self->locationnum),
+ 'quantity' => ($opt->{'quantity'} || $self->quantity),
'start_date' => $date,
);
my $new = FS::cust_pkg->new(\%hash);
die 'unknown pkgnum' unless $cust_pkg;
my %change = map { $_ => scalar($cgi->param($_)) }
- qw( locationnum pkgpart );
+ qw( locationnum pkgpart quantity );
$change{'keep_dates'} = 1;
%# Placeholders
<INPUT TYPE="hidden" NAME="<%$pre%>cachenum" VALUE="">
<INPUT TYPE="hidden" NAME="<%$pre%>addr_clean" VALUE="">
+
+<SCRIPT TYPE="text/javascript">
+// the strictly correct way to append something to window.onload
+window.addEventListener('load', function() {
+ var clear_coords_ids = [
+ '<%$pre%>latitude',
+ '<%$pre%>longitude',
+ 'enter_censustract',
+ '<%$pre%>district'
+ ];
+ function clear_coords() {
+ for (var i=0; i < clear_coords_ids.length; i++) {
+ var el = document.getElementById(clear_coords_ids[i]);
+ if ( el ) {
+ el.value = '';
+ }
+ }
+ }
+ var clear_coords_on_change = [
+ '<%$pre%>address1',
+ '<%$pre%>address2',
+ '<%$pre%>city',
+ '<%$pre%>state',
+ '<%$pre%>zip',
+ '<%$pre%>country',
+ ];
+ for (var i=0; i < clear_coords_on_change.length; i++) {
+ var el = document.getElementById(clear_coords_on_change[i]);
+ if ( el ) {
+ // because some of these already have onchange triggers
+ el.addEventListener('change', clear_coords);
+ }
+ }
+});
+</SCRIPT>
+
<%init>
my %opt = @_;
--- /dev/null
+% if ( FS::Conf->new->exists('invoice-unitprice') or $curr_value > 1 ) {
+ <TR>
+ <TH ALIGN="right"><% mt('Quantity') |h %>
+ </TH>
+ <TD>
+ <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $curr_value |h %>">
+ </TD>
+ </TR>
+% } else {
+ <INPUT TYPE="hidden" NAME="quantity" VALUE="1">
+% }
+<%init>
+my %opt = @_;
+my $curr_value = $cgi->param('quantity') || $opt{'curr_value'} || 1;
+</%init>
'cust_main' => $cust_main,
&>
+ <& /elements/tr-input-pkg-quantity.html,
+ 'curr_value' => $cust_pkg->quantity
+ &>
+
<& /elements/tr-select-cust_location.html,
'cgi' => $cgi,
'cust_main' => $cust_main,
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 )) {
+ foreach(qw( start_date pkgpart locationnum quantity )) {
$cgi->param($_, $change_to->get($_));
}
$title = "Edit Scheduled Package Change";
&>
% }
-% if ( $conf->exists('invoice-unitprice') ) {
- <TR>
- <TH ALIGN="right"><% mt('Quantity') |h %> </TD>
- <TD>
- <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>">
- </TD>
- </TR>
-% } else {
- <INPUT TYPE="hidden" NAME="quantity" VALUE="1">
-% }
+<& /elements/tr-input-pkg-quantity.html, curr_value => $quantity &>
<TR>
<TH ALIGN="right"><% mt('Start date') |h %> </TD>
STYLE="margin-left:auto; margin-right:auto">
<& /elements/tr-select-reason.html,
'field' => 'reasonnum',
- 'reason_class' => 'C',
+ 'reason_class' => 'S',
'cgi' => $cgi,
'control_button' => "document.getElementById('confirm_suspend_cust_button')",
&>
'Type',
'First Download',
'Last Upload',
- '', # requests
- '', # req amt
- '', # payments
- '', # pay amt
+ { label => 'Requested', colspan => 2 },
+ '',
+ { label => 'Paid', colspan => 2 },
+ '',
'Status',
],
+ 'header2' => [ '',
+ '',
+ '',
+ '',
+ '',
+ 'Items',
+ 'Amount',
+ 'Items',
+ 'Amount',
+ '',
+ ],
'align' => 'rcllrrrrc',
'fields' => [ 'batchnum',
sub {
},
sub {
my $c = FS::cust_pay_batch->count('batchnum = '.$_[0]->batchnum);
- $c ? "$c requested" : ''
+ $c || ''
},
sub {
my $st = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=" . shift->batchnum;
},
sub {
my $c = FS::cust_pay->count('batchnum = '.$_[0]->batchnum);
- $c ? "$c paid" : ''
+ $c || '';
},
sub {
my $st = "SELECT SUM(paid) from cust_pay WHERE batchnum=" . shift->batchnum;
my @where = ( $agentnums_sql );
+if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
+ push @where, "cust_main.agentnum = $1";
+}
+
my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
if ( $cgi->param('status') =~ /^([a-z]+)$/ ) {
# last payment/credit date
my %t = (pay => 'cust_bill_pay', credit => 'cust_credit_bill');
foreach my $x (qw(pay credit)) {
- my $table = $t{$x};
- my $link = $table.'_pkg';
- my $pkey = dbdef->table($table)->primary_key;
- my $last_date_sql = "SELECT MAX(_date)
- FROM $table JOIN $link USING ($pkey)
- WHERE $link.billpkgnum = cust_bill_pkg.billpkgnum
+ my $table = "cust_$x";
+ my $link_bill = $t{$x};
+ my $link_pkg = $link_bill.'_pkg';
+ my %pkey = map { $_ => dbdef->table($_)->primary_key }
+ ( $table, $link_bill );
+
+ my $last_date_sql = "SELECT MAX($table._date)
+ FROM $table JOIN $link_bill USING ($pkey{$table})
+ JOIN $link_pkg USING ($pkey{$link_bill})
+ WHERE $link_pkg.billpkgnum = cust_bill_pkg.billpkgnum
AND $table._date <= $unearned";
push @select, "($last_date_sql) AS last_$x";
}
'label' => emt('Change location'),
'actionlabel' => emt('Change'),
'cust_pkg' => $cust_pkg,
- 'width' => 763,
- 'height' => 380,
+ 'width' => 960,
+ 'height' => 490,
);
}
'label' => emt('Change package'),
'actionlabel' => emt('Change'),
'cust_pkg' => $cust_pkg,
- 'width' => 763,
- 'height' => 480,
+ 'width' => 960,
+ 'height' => 490,
);
}
'label' => emt('Change location'),
'actionlabel' => emt('Change'),
'cust_pkg' => $cust_pkg,
- 'width' => 763,
- 'height' => 380,
+ 'width' => 960,
+ 'height' => 490,
);
}
'label' => emt('Reschedule'),
'actionlabel' => emt('Edit scheduled change for'),
'cust_pkg' => $cust_pkg,
- 'width' => 763,
- 'height' => 480,
+ 'width' => 960,
+ 'height' => 490,
)
}
Starts
Started
Due
+ WillResolve
);
#Run through each field in this list. update the value if apropriate
TimeLeft
Type
Queue
+ WillResolve
);
+ # the UI for editing WillResolve through Ticket Basics should allow
+ # setting it to null
+ my $to_date = delete($ARGSRef->{'WillResolve_Date'});
+ my $DateObj = RT::Date->new($session{'CurrentUser'});
+ if ( $to_date ) {
+ $DateObj->Set(Format => 'unknown', Value => $to_date);
+ } else {
+ $DateObj->Set(Value => 0);
+ }
+ $ARGSRef->{'WillResolve'} = $DateObj->ISO;
+
if ( $ARGSRef->{'Queue'} and ( $ARGSRef->{'Queue'} !~ /^(\d+)$/ ) ) {
my $tempqueue = RT::Queue->new($RT::SystemUser);
$tempqueue->Load( $ARGSRef->{'Queue'} );
%defaults => ()
</%ARGS>
<%INIT>
+my $WillResolveObj = $TicketObj->WillResolveObj if defined $TicketObj;
unless ( @fields ) {
@fields = (
{ name => 'Subject',
comp => '/Elements/SelectDate',
args => {
menu_prefix => 'WillResolve',
- Default => $ARGS{'WillResolve'} || $TicketObj->WillResolveObj->Date,
+ Default => $ARGS{'WillResolve'} ||
+ (defined($WillResolveObj)
+ and $WillResolveObj->Unix > 0 ?
+ $WillResolveObj->Date : ''),
current => 0,
ShowTime => 0,
},