From: ivan Date: Sun, 13 Aug 2006 10:25:58 +0000 (+0000) Subject: customer view work: X-Git-Tag: BEFORE_FINAL_MASONIZE~33 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=8e3dfb380406e145494a5fffa7a0e4aab7b38253 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 --- 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') ) { %> Error: <%= $cgi->param('error') %> @@ -60,7 +63,6 @@ $title .= " against Invoice #$linknum" if $link eq 'invnum';
- <% 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')) %> +<% } %> 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') %> + + + + <% + + } 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') ) { %> Edit this customer | 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 (Bill now) <%= ntable("#cccccc") %><%= ntable("#cccccc",2) %> +<% +( my $balance = $cust_main->balance ) + =~ s/^(\-?)(.*)$/$1<\/FONT>$money_char$2/; +%> + + + Balance due + <%= $balance %> + + Billing type @@ -159,7 +171,7 @@ if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format <%= join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %> -<% my $conf = new FS::Conf; if ( $conf->exists('voip-cust_cdr_spools') ) { %> +<% if ( $conf->exists('voip-cust_cdr_spools') ) { %> Spool CDRs <%= $cust_main->spool_cdr ? 'yes' : 'no' %> 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") %><%= &ntable("#cccccc",2) %> + Customer number <%= $cust_main->custnum %> + + Status + <%= ucfirst($cust_main->status) %> + + <% my @agents = qsearch( 'agent', {} ); my $agent; @@ -51,10 +57,6 @@ <% } %> - Order taker - <%= $cust_main->otaker %> - - Referring Customer @@ -82,5 +84,10 @@ + + Order taker + <%= $cust_main->otaker %> + + 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); %> - - Packages <% if ( $curuser->access_right('Order customer package') ) { %> @@ -54,30 +50,33 @@ Current packages <% if ( @$packages ) { %> - +<%= include('/elements/table-grid.html') %> + +<% my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor = ''; +%> + - - - + + + <% 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; + } + %> - - + + + + + + + + + + + + + <% + } + + } + 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('- $%.2f', $item->{'void_payment'}) + + $payment ||= sprintf( "- $money_char\%.2f", + $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/^\$\-/- \$/; %> - + >
PackageStatusServicesPackageStatusServices
> + <%=$pkg->{pkgnum}%>: <%=$pkg->{pkg}%> - <%=$pkg->{comment}%>
@@ -94,8 +93,8 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { <% } %>
> - + -<% - if ($rowspan == 0) { print qq!\n!; next; } + + +<% } #end display packages %>
+ <% sub myfreq { @@ -315,42 +314,51 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) {
+ - my $cnt = 0; + +<% foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) { foreach my $service (@{$svcpart->{services}}) { - print '' if ($cnt > 0); %> - - + + + + + <% if ( $curuser->access_right('Unprovision customer service') ) { %> + + + + <% } %> + <% } %> - - -<% - $cnt++; - } - if ( $svcpart->{count} < $svcpart->{quantity} ) { - print '' if ($cnt > 0); - if ( $curuser->access_right('Provision customer service') ) { - print ''; - } else { - #print ''; - print ''; - } - } - } -} -#end display packages + <% if ( $curuser->access_right('Provision customer service') + && $svcpart->{count} < $svcpart->{quantity} + ) + { + %> + + + + + + <% } %> + +<% } %> + +
<%=svc_link($svcpart,$service)%><%=svc_label_link($svcpart,$service)%> - <% if ( $curuser->access_right('Unprovision customer service') ) { %> -
( <%=svc_unprovision_link($service)%> ) +
<%=svc_link($svcpart,$service)%><%=svc_label_link($svcpart,$service)%>
( <%=svc_unprovision_link($service)%> )
'. - svc_provision_link($pkg, $svcpart, $conf, $curuser). - '
 
+ <%= svc_provision_link($pkg, $svcpart, $conf, $curuser) %> +
+
+ <% } else { %>
<% } %> 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++ ? ' | ' : '' %> - Post check payment + Enter check payment <% } %> <% if ( $payby{'CASH'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> - Post cash payment + Enter cash payment <% } %> <% if ( $payby{'WEST'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> - Post Western Union payment + Enter Western Union payment <% } %> @@ -62,7 +62,7 @@ <% if ( $payby{'MCRD'} && $curuser->access_right('Post payment') ) { %> <%= $s++ ? ' | ' : '' %> - Post manual credit card payment + Post manual (offline) credit card payment <% } %> @@ -70,7 +70,7 @@ <% if ( $curuser->access_right('Post credit') ) { %> - Post credit + Enter credit
@@ -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/^\$\-/- \$/; + %> + +
+ <%= time2str("%D",$item->{'date'}) %> + + Starting balance on <%= time2str("%D",$item->{'date'}) %> + (show prior history) + <%= $balance_forward %>
<% unless ( !$target || $target{$target}++ ) { %> @@ -502,3 +551,20 @@ foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) {
+ + 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 (View all tickets for this customer) (New ticket for this customer) -<%= include("/elements/table.html") %> + +<%= include("/elements/table-grid.html") %> + +<% my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor = ''; +%> + - # - Subject - Priority - Queue - Status + # + Subject + Priority + Queue + Status + <% foreach my $ticket ( @tickets ) { my $href = FS::TicketSystem->href_ticket($ticket->{id}); + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } %> + - ><%= $ticket->{id} %> - ><%= $ticket->{subject} %> - <%= $ticket->{content} || $ticket->{priority} %> - <%= $ticket->{name} %> - <%= $ticket->{status} %> + + ><%= $ticket->{id} %> + + ><%= $ticket->{subject} %> + + <%= $ticket->{content} || $ticket->{priority} %> + + <%= $ticket->{name} %> + + <%= $ticket->{status} %> + + <% } %> +