diff options
author | ivan <ivan> | 2006-08-13 10:25:58 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-08-13 10:25:58 +0000 |
commit | 8e3dfb380406e145494a5fffa7a0e4aab7b38253 (patch) | |
tree | b810048e9a0ccd6976d3927da9224a956084e1ce | |
parent | a2bddcaabfdaf11d4b726b21af7f6ffc13c458d3 (diff) |
customer view work:
DONE 1. add status and balance to top
DONE 2. add some sort of oldest date thing so the history doesn't get too
big (# years and a link to "show older")
3. make the rest of the action links into js popups? maybe later,
weird IENess when closing em
DONE (finished) - so revert out or finish/commit the Enter check payment one
- Process page can wait until another day.. it should be more of an *action*
DONE 4. Ticket list config knobs for wtxs (grid it too)
DONE 5. grid the package list
-rw-r--r-- | FS/FS/Conf.pm | 22 | ||||
-rw-r--r-- | FS/FS/TicketSystem/RT_External.pm | 46 | ||||
-rwxr-xr-x | httemplate/edit/cust_pay.cgi | 20 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_pay.cgi | 30 | ||||
-rwxr-xr-x | httemplate/view/cust_main.cgi | 19 | ||||
-rw-r--r-- | httemplate/view/cust_main/billing.html | 14 | ||||
-rw-r--r-- | httemplate/view/cust_main/misc.html | 15 | ||||
-rwxr-xr-x | httemplate/view/cust_main/packages.html | 100 | ||||
-rw-r--r-- | httemplate/view/cust_main/payment_history.html | 92 | ||||
-rw-r--r-- | httemplate/view/cust_main/tickets.html | 46 |
10 files changed, 278 insertions, 126 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 5b77234a6..68ca49d0b 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1716,6 +1716,28 @@ httemplate/docs/config.html 'type' => 'textarea', }, + { + 'key' => 'payment_history-years', + 'section' => 'UI', + 'description' => 'Number of years of payment history to show by default. Currently defaults to 2.', + 'type' => 'text', + }, + + { + 'key' => 'cust_main-ticket_statuses', + 'section' => 'UI', + 'description' => 'Show tickets with these statuses on the customer view page.', + 'type' => 'selectmultiple', + 'select_enum' => [qw( new open stalled resolved rejected deleted )], + }, + + { + 'key' => 'cust_main-max_tickets', + 'section' => 'UI', + 'description' => 'Maximum number of tickets to show on the customer view page.', + 'type' => 'text', + }, + ); 1; diff --git a/FS/FS/TicketSystem/RT_External.pm b/FS/FS/TicketSystem/RT_External.pm index ea3448039..7dde86228 100644 --- a/FS/FS/TicketSystem/RT_External.pm +++ b/FS/FS/TicketSystem/RT_External.pm @@ -10,7 +10,7 @@ use FS::Record qw(qsearchs); use FS::cust_main; FS::UID->install_callback( sub { - my $conf = new FS::Conf; + $conf = new FS::Conf; $default_queueid = $conf->config('ticket_system-default_queueid'); $priority_field = $conf->config('ticket_system-custom_priority_field'); @@ -57,7 +57,7 @@ sub customer_tickets { my( $from_sql, @param) = $self->_from_customer( $custnum, $priority ); my $sql = "SELECT tickets.*, queues.name". ( length($priority) ? ", objectcustomfieldvalues.content" : '' ). - " $from_sql ORDER BY priority DESC LIMIT $limit"; + " $from_sql ORDER BY priority, id DESC LIMIT $limit"; my $sth = $dbh->prepare($sql) or die $dbh->errstr. "preparing $sql"; $sth->execute(@param) or die $sth->errstr. "executing $sql"; @@ -131,7 +131,7 @@ sub _from_customer { JOIN queues ON ( tickets.queue = queues.id ) JOIN links ON ( tickets.id = links.localbase ) $join - WHERE ( status = 'new' OR status = 'open' OR status = 'stalled' ) + WHERE ( ". join(' OR ', map "status = '$_'", $self->statuses ). " ) AND target = 'freeside://freeside/cust_main/$custnum' $where "; @@ -140,31 +140,44 @@ sub _from_customer { } +sub statuses { + #my $self = shift; + my @statuses = grep { ! /^\s*$/ } $conf->config('cust_main-ticket_statuses'); + @statuses = (qw( new open stalled )) unless scalar(@statuses); + @statuses; +} + sub href_customer_tickets { my( $self, $custnum, $priority ) = @_; - my $href = $self->baseurl; + #my $href = $self->baseurl; - #i snarfed this from an RT bookmarked search, it could be unescaped in the - #source for readability and run through uri_escape - $href .= - 'Search/Results.html?Order=ASC&Query=%20MemberOf%20%3D%20%27freeside%3A%2F%2Ffreeside%2Fcust_main%2F'. - $custnum. - '%27%20%20AND%20%28%20Status%20%3D%20%27open%27%20%20OR%20Status%20%3D%20%27new%27%20%20OR%20Status%20%3D%20%27stalled%27%20%29%20' + #i snarfed this from an RT bookmarked search, then unescaped (some of) it with + #perl -npe 's/%([0-9A-F]{2})/pack('C', hex($1))/eg;' + + my $href .= + "Search/Results.html?Order=ASC&". + "Query= MemberOf = 'freeside://freeside/cust_main/$custnum' ". + #" AND ( Status = 'open' OR Status = 'new' OR Status = 'stalled' )" + " AND ( ". join(' OR ', map "Status = '$_'", $self->statuses ). " ) " ; if ( defined($priority) && $field && $priority_field_queue ) { - $href .= 'AND%20Queue%20%3D%20%27'. $priority_field_queue. '%27%20'; + $href .= " AND Queue = '$priority_field_queue' "; } if ( defined($priority) && $field ) { - $href .= '%20AND%20%27CF.'. $field. '%27%20'; + $href .= " AND 'CF.$field' "; if ( $priority ) { - $href .= '%3D%20%27'. $priority. '%27%20'; + $href .= "= '$priority' "; } else { - $href .= 'IS%20%27NULL%27%20'; + $href .= "IS 'NULL' "; #this is "RTQL", not SQL } } + #$href = + uri_escape($href); + #eventually should unescape all of it... + $href .= '&Rows=100'. '&OrderBy=id&Page=1'. '&Format=%27%20%20%20%3Cb%3E%3Ca%20href%3D%22'. @@ -185,7 +198,10 @@ sub href_customer_tickets { $href .= '%20%0A%27%3Csmall%3E__ToldRelative__%3C%2Fsmall%3E%27%2C%20%0A%27%3Csmall%3E__LastUpdatedRelative__%3C%2Fsmall%3E%27%2C%20%0A%27%3Csmall%3E__TimeLeft__%3C%2Fsmall%3E%27'; - $href; + #$href = + #uri_escape($href); + + $self->baseurl. $href; } diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index a03a245eb..e7734c1fc 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -9,22 +9,20 @@ my %payby = ( 'MCRD' => 'Manual credit card', ); -my($link, $linknum, $paid, $payby, $payinfo, $quickpay, $_date); +my($link, $linknum, $paid, $payby, $payinfo, $_date); if ( $cgi->param('error') ) { $link = $cgi->param('link'); $linknum = $cgi->param('linknum'); $paid = $cgi->param('paid'); $payby = $cgi->param('payby'); $payinfo = $cgi->param('payinfo'); - $quickpay = $cgi->param('quickpay'); $_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time; } elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { - $link = 'custnum'; + $link = $cgi->param('popup') ? 'popup' : 'custnum'; $linknum = $1; $paid = ''; $payby = $cgi->param('payby') || 'BILL'; $payinfo = ''; - $quickpay = $cgi->param('quickpay'); $_date = time; } elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) { $link = 'invnum'; @@ -32,7 +30,6 @@ if ( $cgi->param('error') ) { $paid = ''; $payby = $cgi->param('payby') || 'BILL'; $payinfo = ""; - $quickpay = ''; $_date = time; } else { die "illegal query ". $cgi->keywords; @@ -43,9 +40,15 @@ my $paybatch = "webui-$_date-$$-". rand() * 2**32; my $title = 'Post '. $payby{$payby}. ' payment'; $title .= " against Invoice #$linknum" if $link eq 'invnum'; -%> +if ( $link eq 'popup' ) { + +%><%= include('/elements/header-popup.html', $title ) %> + +<% } else { %> -<%= include("/elements/header.html",$title, '') %> +<%= include("/elements/header.html", $title, '') %> + +<% } %> <% if ( $cgi->param('error') ) { %> <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> @@ -60,7 +63,6 @@ $title .= " against Invoice #$linknum" if $link eq 'invnum'; <FORM ACTION="<%= popurl(1) %>process/cust_pay.cgi" METHOD=POST> <INPUT TYPE="hidden" NAME="link" VALUE="<%= $link %>"> <INPUT TYPE="hidden" NAME="linknum" VALUE="<%= $linknum %>"> -<INPUT TYPE="hidden" NAME="quickpay" VALUE="<%= $quickpay %>"> <% my $money_char = $conf->config('money_char') || '$'; @@ -74,7 +76,9 @@ if ( $link eq 'invnum' ) { } %> +<% unless ( $link eq 'popup' ) { %> <%= small_custview($custnum, $conf->config('countrydefault')) %> +<% } %> <INPUT TYPE="hidden" NAME="payby" VALUE="<%= $payby %>"> diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi index 87d6011e7..cecccb59e 100755 --- a/httemplate/edit/process/cust_pay.cgi +++ b/httemplate/edit/process/cust_pay.cgi @@ -4,15 +4,16 @@ $cgi->param('linknum') =~ /^(\d+)$/ or die "Illegal linknum: ". $cgi->param('linknum'); my $linknum = $1; -$cgi->param('link') =~ /^(custnum|invnum)$/ +$cgi->param('link') =~ /^(custnum|invnum|popup)$/ or die "Illegal link: ". $cgi->param('link'); -my $link = $1; +my $field = my $link = $1; +$field = 'custnum' if $field eq 'popup'; my $_date = str2time($cgi->param('_date')); my $new = new FS::cust_pay ( { - $link => $linknum, - _date => $_date, + $field => $linknum, + _date => $_date, map { $_, scalar($cgi->param($_)); } qw(paid payby payinfo paybatch) @@ -24,19 +25,30 @@ my $error = $new->insert; if ($error) { $cgi->param('error', $error); print $cgi->redirect(popurl(2). 'cust_pay.cgi?'. $cgi->query_string ); -} elsif ( $link eq 'invnum' ) { +} elsif ( $field eq 'invnum' ) { print $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum"); -} elsif ( $link eq 'custnum' ) { +} elsif ( $field eq 'custnum' ) { if ( $cgi->param('apply') eq 'yes' ) { my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum }) or die "unknown custnum $linknum"; $cust_main->apply_payments; } - if ( $cgi->param('quickpay') eq 'yes' ) { - print $cgi->redirect(popurl(3). "search/cust_main-quickpay.html"); - } else { + if ( $link eq 'popup' ) { + + %><%= header('Payment entered') %> + <SCRIPT TYPE="text/javascript"> + window.top.location.reload(); + </SCRIPT> + + </BODY></HTML> + <% + + } elsif ( $link eq 'custnum' ) { print $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum"); + } else { + die "unknown link $link"; } + } %> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 89ddc38f2..8267fea51 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -2,24 +2,6 @@ my $conf = new FS::Conf; -my %uiview = (); -my %uiadd = (); -foreach my $part_svc ( qsearch('part_svc',{}) ) { - $uiview{$part_svc->svcpart} = $p. "view/". $part_svc->svcdb . ".cgi"; - $uiadd{$part_svc->svcpart}= $p. "edit/". $part_svc->svcdb . ".cgi"; -} - -%> - - -<%= include("/elements/header.html","Customer View", - include("/elements/menubar.html", - 'Main Menu' => $p, -)) %> - - -<% - my $curuser = $FS::CurrentUser::CurrentUser; die "No customer specified (bad URL)!" unless $cgi->keywords; @@ -31,6 +13,7 @@ die "Customer not found!" unless $cust_main; %> +<%= include("/elements/header.html","Customer View: ". $cust_main->name ) %> <% if ( $curuser->access_right('Edit customer') ) { %> <A HREF="<%= $p %>edit/cust_main.cgi?<%= $custnum %>">Edit this customer</A> | diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 895814cc2..191d3092f 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -1,12 +1,24 @@ <% my( $cust_main ) = @_; my @invoicing_list = $cust_main->invoicing_list; + my $conf = new FS::Conf; + my $money_char = $conf->config('money_char') || '$'; %> Billing information (<A HREF="<%= $p %>misc/bill.cgi?<%= $cust_main->custnum %>">Bill now</A>) <%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %> +<% +( my $balance = $cust_main->balance ) + =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/; +%> + +<TR> + <TD ALIGN="right">Balance due</TD> + <TD BGCOLOR="#ffffff"><B><%= $balance %></B></TD> +</TR> + <TR> <TD ALIGN="right">Billing type</TD> <TD BGCOLOR="#ffffff"> @@ -159,7 +171,7 @@ if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format <%= join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %> </TD> </TR> -<% my $conf = new FS::Conf; if ( $conf->exists('voip-cust_cdr_spools') ) { %> +<% if ( $conf->exists('voip-cust_cdr_spools') ) { %> <TR> <TD ALIGN="right">Spool CDRs</TD> <TD BGCOLOR="#ffffff"><%= $cust_main->spool_cdr ? 'yes' : 'no' %></TD> diff --git a/httemplate/view/cust_main/misc.html b/httemplate/view/cust_main/misc.html index 742b35958..f06a4fbd2 100644 --- a/httemplate/view/cust_main/misc.html +++ b/httemplate/view/cust_main/misc.html @@ -4,11 +4,17 @@ %> <%= ntable("#cccccc") %><TR><TD><%= &ntable("#cccccc",2) %> + <TR> <TD ALIGN="right">Customer number</TD> <TD BGCOLOR="#ffffff"><%= $cust_main->custnum %></TD> </TR> +<TR> + <TD ALIGN="right">Status</TD> + <TD BGCOLOR="#ffffff"><FONT COLOR="#<%= $cust_main->statuscolor %>"><B><%= ucfirst($cust_main->status) %></B></FONT></TD> +</TR> + <% my @agents = qsearch( 'agent', {} ); my $agent; @@ -51,10 +57,6 @@ <% } %> <TR> - <TD ALIGN="right">Order taker</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->otaker %></TD> -</TR> -<TR> <TD ALIGN="right">Referring Customer</TD> <TD BGCOLOR="#ffffff"> @@ -82,5 +84,10 @@ </TD> </TR> +<TR> + <TD ALIGN="right">Order taker</TD> + <TD BGCOLOR="#ffffff"><%= $cust_main->otaker %></TD> +</TR> + </TABLE></TD></TR></TABLE> diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html index beb67f325..9cd1e284f 100755 --- a/httemplate/view/cust_main/packages.html +++ b/httemplate/view/cust_main/packages.html @@ -7,10 +7,6 @@ my $packages = get_packages($cust_main, $conf); %> -<STYLE TYPE="text/css"> -.package .provision { font-weight: bold } -</STYLE> - <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A> <% if ( $curuser->access_right('Order customer package') ) { %> @@ -54,30 +50,33 @@ Current packages <% if ( @$packages ) { %> -<TABLE CLASS="package" BORDER=1 CELLSPACING=0 CELLPADDING=2 BORDERCOLOR="#999999"> +<%= include('/elements/table-grid.html') %> + +<% my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor = ''; +%> + <TR> - <TH>Package</TH> - <TH>Status</TH> - <TH COLSPAN=2>Services</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH> </TR> <% foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { - my $rowspan = 0; - if ($pkg->{cancel}) { - $rowspan = 0; + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; } else { - foreach my $svcpart (@{$pkg->{svcparts}}) { - $rowspan += $svcpart->{count}; - $rowspan++ if ($svcpart->{count} < $svcpart->{quantity}); - } - } + $bgcolor = $bgcolor1; + } + %> <!--pkgnum: <%=$pkg->{pkgnum}%>--> <TR> - <TD ROWSPAN=<%= $rowspan || 1 %>> + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"> <A NAME="cust_pkg<%=$pkg->{pkgnum}%>"><%=$pkg->{pkgnum}%></A>: <%=$pkg->{pkg}%> - <%=$pkg->{comment}%><BR> <FONT SIZE=-1> @@ -94,8 +93,8 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { <% } %> </FONT> </TD> - <TD ROWSPAN=<%= $rowspan || 1 %>> - <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> + <TD CLASS="inv" BGCOLOR="<%= $bgcolor %>"> + <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> <% sub myfreq { @@ -315,42 +314,51 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { </TABLE> </TD> -<% - if ($rowspan == 0) { print qq!</TR>\n!; next; } +<TD CLASS="inv" BGCOLOR="<%= $bgcolor %>"> + <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> - my $cnt = 0; + +<% foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) { foreach my $service (@{$svcpart->{services}}) { - print '<TR>' if ($cnt > 0); %> - <TD><%=svc_link($svcpart,$service)%></TD> - <TD><%=svc_label_link($svcpart,$service)%> - <% if ( $curuser->access_right('Unprovision customer service') ) { %> - <BR>( <%=svc_unprovision_link($service)%> ) + <TR> + <TD ALIGN="right" VALIGN="top" ROWSPAN=2><%=svc_link($svcpart,$service)%></TD> + <TD STYLE="padding-bottom:0px"><B><%=svc_label_link($svcpart,$service)%></B></TD> + </TR> + + <% if ( $curuser->access_right('Unprovision customer service') ) { %> + <TR> + <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">( <%=svc_unprovision_link($service)%> )</FONT></TD> + </TR> + <% } %> + <% } %> - </TD> -</TR> -<% - $cnt++; - } - if ( $svcpart->{count} < $svcpart->{quantity} ) { - print '<TR>' if ($cnt > 0); - if ( $curuser->access_right('Provision customer service') ) { - print '<TD COLSPAN=2>'. - svc_provision_link($pkg, $svcpart, $conf, $curuser). - '</TD></TR>'; - } else { - #print '<TD COLSPAN=2> </TD></TR>'; - print '<TD COLSPAN=2></TD></TR>'; - } - } - } -} -#end display packages + <% if ( $curuser->access_right('Provision customer service') + && $svcpart->{count} < $svcpart->{quantity} + ) + { + %> + + <TR> + <TD COLSPAN=2 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px"> + <B><%= svc_provision_link($pkg, $svcpart, $conf, $curuser) %></B> + </TD> + </TR> + + <% } %> + +<% } %> + +</TABLE> +</TD> + +<% } #end display packages %> </TABLE> + <% } else { %> <BR> <% } %> diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index 482136fa1..aef5fb8f8 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -21,21 +21,21 @@ <% if ( $payby{'BILL'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=BILL;custnum=<%= $custnum %>">Post check payment</A> + <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<%= $p %>edit/cust_pay.cgi?popup=1;payby=BILL;custnum=<%= $custnum %>', 392, 336, 'cust_pay_popup' ), CAPTION, 'Enter check payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter check payment</A> <% } %> <% if ( $payby{'CASH'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=CASH;custnum=<%= $custnum %>">Post cash payment</A> + <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<%= $p %>edit/cust_pay.cgi?popup=1;payby=CASH;custnum=<%= $custnum %>', 392, 336, 'cust_pay_popup' ), CAPTION, 'Enter cash payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter cash payment</A> <% } %> <% if ( $payby{'WEST'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;custnum=<%= $custnum %>">Post Western Union payment</A> + <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;custnum=<%= $custnum %>">Enter Western Union payment</A> <% } %> @@ -62,7 +62,7 @@ <% if ( $payby{'MCRD'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=MCRD;custnum=<%= $custnum %>">Post manual credit card payment</A> + <A HREF="<%= $p %>edit/cust_pay.cgi?payby=MCRD;custnum=<%= $custnum %>">Post manual (offline) credit card payment</A> <% } %> @@ -70,7 +70,7 @@ <% if ( $curuser->access_right('Post credit') ) { %> - <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<%= $p %>edit/cust_credit.cgi?<%= $custnum %>', 392, 336, 'cust_credit_popup' ), CAPTION, 'Post credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Post credit</A> + <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<%= $p %>edit/cust_credit.cgi?<%= $custnum %>', 392, 336, 'cust_credit_popup' ), CAPTION, 'Enter credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter credit</A> <BR> @@ -430,10 +430,53 @@ foreach my $cust_refund ($cust_main->cust_refund) { <% #display payment history -my %target; my $balance = 0; +my %target = (); +my $money_char = $conf->config('money_char') || '$'; + +my $years = $conf->config('payment_history-years') || 2; +my $older_than = time - $years * 31556736; #60*60*24*365.24 +my $hidden = 0; +my $seen = 0; +my $old_history = 0; + foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { + my $display; + if ( $item->{'date'} < $older_than ) { + $display = ' STYLE="display:none" '; + $hidden = 1; + } else { + + $display = ''; + + if ( $hidden && ! $seen++ ) { + ( my $balance_forward = $money_char. $balance ) =~ s/^\$\-/- \$/; + %> + + <TR ID="balance_forward_row"> + <TD CLASS="grid" BGCOLOR="#dddddd"> + <%= time2str("%D",$item->{'date'}) %> + </TD> + + <TD CLASS="grid" BGCOLOR="#dddddd"> + <I>Starting balance on <%= time2str("%D",$item->{'date'}) %></I> + (<A HREF="javascript:void(0);" onClick="show_history();">show prior history</A>) + </TD> + + <TD CLASS="grid" BGCOLOR="#dddddd"></TD> + <TD CLASS="grid" BGCOLOR="#dddddd"></TD> + <TD CLASS="grid" BGCOLOR="#dddddd"></TD> + <TD CLASS="grid" BGCOLOR="#dddddd"></TD> + <TD CLASS="grid" BGCOLOR="#dddddd"><I><%= $balance_forward %></I></TD> + + </TR> + + <% + } + + } + if ( $bgcolor eq $bgcolor1 ) { $bgcolor = $bgcolor2; } else { @@ -441,18 +484,24 @@ foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { } my $charge = exists($item->{'charge'}) - ? sprintf('$%.2f', $item->{'charge'}) + ? sprintf("$money_char\%.2f", $item->{'charge'}) : ''; + my $payment = exists($item->{'payment'}) - ? sprintf('- $%.2f', $item->{'payment'}) + ? sprintf("- $money_char\%.2f", $item->{'payment'}) : ''; - $payment ||= sprintf('<DEL>- $%.2f</DEL>', $item->{'void_payment'}) + + $payment ||= sprintf( "<DEL>- $money_char\%.2f</DEL>", + $item->{'void_payment'} + ) if exists($item->{'void_payment'}); + my $credit = exists($item->{'credit'}) - ? sprintf('- $%.2f', $item->{'credit'}) + ? sprintf("- $money_char\%.2f", $item->{'credit'}) : ''; + my $refund = exists($item->{'refund'}) - ? sprintf('$%.2f', $item->{'refund'}) + ? sprintf("$money_char\%.2f", $item->{'refund'}) : ''; my $target = exists($item->{'target'}) ? $item->{'target'} : ''; @@ -463,11 +512,11 @@ foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { $balance += $item->{'refund'} if exists $item->{'refund'}; $balance = sprintf("%.2f", $balance); $balance =~ s/^\-0\.00$/0.00/; #yay ieee fp - ( my $showbalance = '$'. $balance ) =~ s/^\$\-/- \$/; + ( my $showbalance = $money_char. $balance ) =~ s/^\$\-/- \$/; %> - <TR> + <TR <%= $display ? $display.' ID="old_history'.$old_history++.'"' : ''%>> <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"> <% unless ( !$target || $target{$target}++ ) { %> <A NAME="<%= $target %>"> @@ -502,3 +551,20 @@ foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { </TABLE> +<SCRIPT TYPE="text/javascript"> + +function show_history () { + //alert('showing history!'); + + var balance_forward_row = document.getElementById('balance_forward_row'); + + balance_forward_row.style.display = 'none'; + for ( var i = 0; i < <%= $old_history %>; i++ ) { + var oldRow = document.getElementById('old_history'+i); + oldRow.style.display = ''; + } + +} + +</SCRIPT> + diff --git a/httemplate/view/cust_main/tickets.html b/httemplate/view/cust_main/tickets.html index 5c1d94ee1..93cb51f25 100644 --- a/httemplate/view/cust_main/tickets.html +++ b/httemplate/view/cust_main/tickets.html @@ -2,7 +2,7 @@ my( $cust_main ) = @_; my $conf = new FS::Conf; - my $num = 10; + my $num = $conf->config('cust_main-max_tickets') || 10; my @tickets = (); unless ( $conf->config('ticket_system-custom_priority_field') ) { @@ -31,24 +31,46 @@ Highest priority tickets (<A HREF="<%= FS::TicketSystem->href_customer_tickets($cust_main->custnum) %>">View all tickets for this customer</A>) (<A HREF="<%= FS::TicketSystem->href_new_ticket($cust_main, join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) ) %>">New ticket for this customer</A>) -<%= include("/elements/table.html") %> + +<%= include("/elements/table-grid.html") %> + +<% my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor = ''; +%> + <TR> - <TH>#</TH> - <TH>Subject</TH> - <TH>Priority</TH> - <TH>Queue</TH> - <TH>Status</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">#</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Subject</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Priority</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Queue</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH> </TR> + <% foreach my $ticket ( @tickets ) { my $href = FS::TicketSystem->href_ticket($ticket->{id}); + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } %> + <TR> - <TD><A HREF=<%=$href%>><%= $ticket->{id} %></A></TD> - <TD><A HREF=<%=$href%>><%= $ticket->{subject} %></A></TD> - <TD ALIGN="right"><%= $ticket->{content} || $ticket->{priority} %></TD> - <TD><%= $ticket->{name} %></TD> - <TD><%= $ticket->{status} %></TD> + + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF=<%=$href%>><%= $ticket->{id} %></A></TD> + + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF=<%=$href%>><%= $ticket->{subject} %></A></TD> + + <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $ticket->{content} || $ticket->{priority} %></TD> + + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $ticket->{name} %></TD> + + <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $ticket->{status} %></TD> + </TR> + <% } %> + </TABLE> |