diff options
author | mark <mark> | 2011-12-08 21:13:17 +0000 |
---|---|---|
committer | mark <mark> | 2011-12-08 21:13:17 +0000 |
commit | ce1b61e7d65317a74f680afb4cb8d8306e14fa5f (patch) | |
tree | 5adb1b9b7b6afc37ebc03bc29aa32fabb8cb373e /httemplate | |
parent | d8d63a28503d40743425dceda7e0b744739eeb2a (diff) |
promised payment date for invoices, #13554
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/misc/cust_bill-promised_date.html | 19 | ||||
-rw-r--r-- | httemplate/misc/process/cust_bill-promised_date.html | 19 | ||||
-rwxr-xr-x | httemplate/search/cust_bill.html | 21 | ||||
-rw-r--r-- | httemplate/search/report_cust_bill.html | 19 | ||||
-rwxr-xr-x | httemplate/view/cust_bill.cgi | 21 | ||||
-rw-r--r-- | httemplate/view/cust_main/payment_history.html | 2 | ||||
-rw-r--r-- | httemplate/view/cust_main/payment_history/invoice.html | 23 |
7 files changed, 115 insertions, 9 deletions
diff --git a/httemplate/misc/cust_bill-promised_date.html b/httemplate/misc/cust_bill-promised_date.html new file mode 100644 index 000000000..7b7b9601d --- /dev/null +++ b/httemplate/misc/cust_bill-promised_date.html @@ -0,0 +1,19 @@ +<& /elements/header-popup.html, 'Edit promised date' &> +<FORM method="POST" action="process/cust_bill-promised_date.html"> +<B><% emt('Invoice #[_1]', $invnum) %></B><BR> +<% ntable('cccccc',2) %> +<INPUT TYPE="hidden" NAME="invnum" VALUE="<%$invnum%>"> +<& /elements/tr-input-date-field.html, + 'promised_date', + $cust_bill->promised_date, + emt('Promised date'), +&> +</TABLE> +<INPUT TYPE="submit" NAME="submit" VALUE="<% emt('Set date') %>"> +</FORM> +<& /elements/footer.html &> +<%init> +my ($invnum) = $cgi->keywords; +$invnum =~ /^\d+$/ or die "Illegal invnum"; +my $cust_bill = qsearchs('cust_bill', { invnum => $invnum }); +</%init> diff --git a/httemplate/misc/process/cust_bill-promised_date.html b/httemplate/misc/process/cust_bill-promised_date.html new file mode 100644 index 000000000..298b13007 --- /dev/null +++ b/httemplate/misc/process/cust_bill-promised_date.html @@ -0,0 +1,19 @@ +<SCRIPT TYPE="text/javascript">window.top.location.reload()</SCRIPT> +<%init> +# XXX ACL? + +$cgi->param('invnum') =~ /^(\d+)$/ + or die "Illegal invnum"; +my $invnum = $1; + +my $promised_date = ''; +if ( length($cgi->param('promised_date')) ) { + $promised_date = parse_datetime($cgi->param('promised_date')) + or die "Illegal promised_date"; +} + +my $cust_bill = qsearchs('cust_bill', { invnum => $invnum }); +$cust_bill->promised_date($promised_date); +my $error = $cust_bill->replace; +die $error if $error; # nothing fancy here +</%init> diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 4117112f5..813f9b843 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -128,7 +128,26 @@ if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) { $search{'newest_percust'} = 1; $count_query = "SELECT COUNT(DISTINCT cust_bill.custnum), 'N/A', 'N/A'"; } - + + # promised date + my $start_of_day = timelocal(0, 0, 0, (localtime(time))[3,4,5]); + foreach ( $cgi->param('promised_date') ) { + # only if at least one box is checked + $search{promised_date} ||= [ $start_of_day, $start_of_day, 0 ]; + if ($_ eq 'past') { + # accept everything before today + $search{promised_date}[0] = 0; + } + elsif ( $_ eq 'future' ) { + # accept everything after today + $search{promised_date}[1] = 4294967295; + } + elsif ( $_ eq 'null' ) { + # accept nulls + $search{promised_date}[2] = 1; + } + } + my $payby_sql = ''; $payby_sql = ' AND (' . join(' OR ', map { "cust_main.payby = '$_'" } $cgi->param('payby') ) . diff --git a/httemplate/search/report_cust_bill.html b/httemplate/search/report_cust_bill.html index 0f0d91b14..51618fb24 100644 --- a/httemplate/search/report_cust_bill.html +++ b/httemplate/search/report_cust_bill.html @@ -37,7 +37,23 @@ &> % } +% if ( $conf->exists('cust_bill-enable_promised_date') ) { <TR> + + <TD ALIGN="right" STYLE="vertical-align:text-top"> + <% emt('Promised payment date:') %></TD> + <TD> + <INPUT TYPE="checkbox" NAME="promised_date" CHECKED VALUE="null"> + <% emt('None') %> <BR> + <INPUT TYPE="checkbox" NAME="promised_date" CHECKED VALUE="past"> + <% emt('In the past') %><BR> + <INPUT TYPE="checkbox" NAME="promised_date" CHECKED VALUE="future"> + <% emt('In the future') %><BR> + </TD> + </TR> +% } + +<TR> <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="open" VALUE="1" CHECKED></TD> <TD><% mt('Show only open invoices') |h %></TD> </TR> @@ -49,6 +65,7 @@ </TR> % } + </TABLE> <BR> @@ -62,6 +79,8 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('List invoices'); +my $conf = new FS::Conf; + my $title = 'Invoice Report'; #false laziness w/report_cust_pkg.html my @title_arg = (); diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 2ce294e9a..a8b4ac15c 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -58,6 +58,27 @@ % } +% if ( $conf->exists('cust_bill-enable_promised_date') ) { +% my $onclick = include('/elements/popup_link_onclick.html', +% 'action' => $p.'misc/cust_bill-promised_date.html?'.$invnum, +% 'actionlabel' => emt('Set promised payment date'), +% 'width' => 320, +% 'height' => 240, +% ); +% $onclick = '<A HREF="#" onclick="'.$onclick.'">'; +% if ( $cust_bill->promised_date ) { +% my $date_format = $conf->config('date_format') || '%b %o, %Y'; + <% mt('Payment promised by [_1]', + time2str($date_format, $cust_bill->promised_date) ) %> + ( <% $onclick %><% mt('change') |h %></A> ) + <BR><BR> +% } +% elsif ( $cust_bill->owed > 0 ) { + <% $onclick %><% mt('Set promised payment date' ) |h %></A> + <BR><BR> +% } +% } + % if ( $curuser->access_right('Resend invoices') ) { <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A> diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index 467c3bc0c..63708e63c 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -398,6 +398,8 @@ my %opt = ( ) ); +$opt{'date_format'} ||= '%m/%d/%Y'; + #legacy invoices foreach my $legacy_cust_bill ($cust_main->legacy_cust_bill) { push @history, { diff --git a/httemplate/view/cust_main/payment_history/invoice.html b/httemplate/view/cust_main/payment_history/invoice.html index d7ee0047a..3028f0f69 100644 --- a/httemplate/view/cust_main/payment_history/invoice.html +++ b/httemplate/view/cust_main/payment_history/invoice.html @@ -1,4 +1,4 @@ -<% $link %><% $invoice %><% $link ? '</A>' : '' %><% $delete %><% $events %> +<% $link %><% $invoice %><% $link ? '</A>' : '' %><% $delete %><% $under %> <%init> my( $cust_bill, %opt ) = @_; @@ -8,10 +8,17 @@ my $conf = new FS::Conf; my $curuser = $FS::CurrentUser::CurrentUser; my $invoice = emt("Invoice #[_1] (Balance [_2])",$cust_bill->display_invnum,$cust_bill->owed); -$invoice = '<B><FONT SIZE="+1" COLOR="#FF0000">' . + +my $under = ''; +if ( $cust_bill->owed > 0 ) { + $invoice = '<B><FONT SIZE="+1" COLOR="#FF0000">' . emt("Open Invoice #[_1] (Balance [_2])",$cust_bill->display_invnum,$cust_bill->owed) . - '</FONT></B>' -if ( $cust_bill->owed > 0 ); + '</FONT></B>'; + if ( $cust_bill->promised_date ) { + $under .= '<BR>'. emt('Payment promised on [_1]', + time2str($opt{'date_format'}, $cust_bill->promised_date)); + } +} #if $cust_bill->owed my $invnum = $cust_bill->invnum; @@ -34,10 +41,10 @@ if ( $cust_bill->num_cust_event || $curuser->access_right('View customer billing events') ) ) { - $events = - qq!<BR><FONT SIZE="-1"><A HREF="${p}search/cust_event.html?invnum=$invnum!. - '">( '.emt('View invoice events').' )</A></FONT>'; + $under .= + qq!<BR><A HREF="${p}search/cust_event.html?invnum=$invnum">( !. + emt('View invoice events').' )</A>'; } -# +$under = '<FONT SIZE="-1">'.$under.'</FONT>' if length($under); </%init> |