From 437fb0a25140cd5a181f8d26204f4949874a00db Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Sun, 29 Jul 2012 16:11:01 -0700 Subject: more efficient ticket counting on dashboard page, #17067 --- httemplate/elements/dashboard-toplist.html | 81 ++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 14 deletions(-) (limited to 'httemplate/elements') diff --git a/httemplate/elements/dashboard-toplist.html b/httemplate/elements/dashboard-toplist.html index 72f596f4a..f6ebb60fe 100644 --- a/httemplate/elements/dashboard-toplist.html +++ b/httemplate/elements/dashboard-toplist.html @@ -32,18 +32,21 @@ -% foreach my $priority ( @custom_priorities, '' ) { -% my $num = -% FS::TicketSystem->num_customer_tickets($custnum,$priority); -% my $ahref = ''; -% $ahref= '' -% if $num; - +% foreach my $priority ( @custom_priorities ) { - <% $ahref.$num %> - +% my $num = $num_tickets_by_priority{$priority}->{$custnum}; +% if ( $num ) { + <% $num %> +% if ( $priority && +% exists($num_tickets_by_priority{''}{$custnum}) ) { +% # decrement the customer's total by the number in +% # this priority bin +% $num_tickets_by_priority{''}{$custnum} -= $num; +% } +% } + % } @@ -77,7 +80,7 @@ <% $line %> <% mt('Lint') |h %> -% foreach my $priority ( @custom_priorities, '' ) { +% foreach my $priority ( @custom_priorities ) { <% $priority || '(none)'%> @@ -105,11 +108,61 @@ my $conf = new FS::Conf; #false laziness w/httemplate/search/cust_main.cgi... care if # custom_priority_field becomes anything but a local hack... + my @custom_priorities = (); -if ( $conf->config('ticket_system-custom_priority_field') +my $custom_priority_field = $conf->config('ticket_system-custom_priority_field'); +if ( $custom_priority_field && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) { @custom_priorities = $conf->config('ticket_system-custom_priority_field-values'); } - +push @custom_priorities, ''; + +my %num_tickets_by_priority = map { $_ => {} } @custom_priorities; +# "optimization" (i.e. "terrible hack") to avoid constructing +# (@custom_priorities) x (cust_main) queries with a bazillion +# joins each just to count tickets +if ( $FS::TicketSystem::system eq 'RT_Internal' ) { + my $text = (driver_name =~ /^Pg/) ? 'text' : 'char'; + # The RT API does not play nicely with aggregate queries, + # so we're going to go around it. + my $sql = + "SELECT cust_main.custnum AS custnum, + ObjectCustomFieldValues.Content as priority, + COUNT(DISTINCT Tickets.Id) AS num_tickets + FROM cust_main + LEFT JOIN cust_pkg USING (custnum) + LEFT JOIN cust_svc USING (pkgnum) + JOIN Links ON ( + ( Links.Target = 'freeside://freeside/cust_main/' || CAST(cust_main.custnum AS $text) OR + Links.Target = 'freeside://freeside/cust_svc/' || CAST(cust_svc.svcnum AS $text) + ) AND + Links.Base LIKE '%rt://%/ticket/%' AND + Links.Type = 'MemberOf' + ) + JOIN Tickets ON (Links.LocalBase = Tickets.Id) + LEFT JOIN ObjectCustomFields ON ( + ObjectCustomFields.ObjectId = '0' OR + ObjectCustomFields.ObjectId = Tickets.Queue + ) + LEFT JOIN CustomFields ON ( + ObjectCustomFields.CustomField = CustomFields.Id AND + CustomFields.Name = '$custom_priority_field' + ) + LEFT JOIN ObjectCustomFieldValues ON ( + ObjectCustomFieldValues.CustomField = CustomFields.Id AND + ObjectCustomFieldValues.ObjectType = 'RT::Ticket' AND + ObjectCustomFieldValues.Disabled = '0' AND + ObjectCustomFieldValues.ObjectId = Tickets.Id + ) + GROUP BY cust_main.custnum, ObjectCustomFieldValues.Content"; + #warn $sql."\n"; + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + while ( my $row = $sth->fetchrow_hashref ) { + #warn to_json($row)."\n"; + $num_tickets_by_priority{ $row->{priority} }->{ $row->{custnum} } = + $row->{num_tickets}; + } +} -- cgit v1.2.1 From 0f2d1070bc6f1521ab50dd07e475587f1117eec6 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 2 Aug 2012 15:54:31 -0700 Subject: sales by ad source report: filter by ad source, #17971 --- httemplate/elements/tr-select-part_referral.html | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'httemplate/elements') diff --git a/httemplate/elements/tr-select-part_referral.html b/httemplate/elements/tr-select-part_referral.html index 765aa8400..5041f7f73 100644 --- a/httemplate/elements/tr-select-part_referral.html +++ b/httemplate/elements/tr-select-part_referral.html @@ -14,13 +14,7 @@ % } else { - - -% if ( $opt{'label'} ) { - <% $opt{'label'} %> -% } else { - <%$r%><% mt('Advertising source') |h %> -% } + <& /elements/tr-td-label.html, label => 'Advertising source', %opt &> <& /elements/select-part_referral.html, 'curr_value' => $refnum, -- cgit v1.2.1 From 45346fd655ba53b82c80b920da945cc0b87ece01 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 3 Aug 2012 13:09:05 -0700 Subject: selfservice payment fees, RT#18345 --- httemplate/elements/tr-amount_fee.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'httemplate/elements') diff --git a/httemplate/elements/tr-amount_fee.html b/httemplate/elements/tr-amount_fee.html index a1a9e3433..12488521a 100644 --- a/httemplate/elements/tr-amount_fee.html +++ b/httemplate/elements/tr-amount_fee.html @@ -90,7 +90,9 @@ if ( $amount > 0 ) { $amount += $fee if $fee && $fee_display eq 'subtract'; - &{ $opt{post_fee_callback} }( \$amount ) if $opt{post_fee_callback}; + #&{ $opt{post_fee_callback} }( \$amount ) if $opt{post_fee_callback}; + $amount += $amount * $opt{'surcharge_percentage'}/100 + if $opt{'surcharge_percentage'} > 0; $amount = sprintf("%.2f", $amount); } -- cgit v1.2.1 From 7b19b666fc36f8dc28747a11bd2b389d8d2ef75f Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 10 Aug 2012 16:07:50 -0700 Subject: sqlradius data usage report, #18823 --- httemplate/elements/menu.html | 2 ++ 1 file changed, 2 insertions(+) (limited to 'httemplate/elements') diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 019afe94e..c656cb9eb 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -256,6 +256,8 @@ tie my %report_inventory, 'Tie::IxHash', tie my %report_rating, 'Tie::IxHash'; $report_rating{'RADIUS sessions'} = [ $fsurl.'search/sqlradius.html', '' ] if $curuser->access_right("Usage: RADIUS sessions"); +$report_rating{'RADIUS data usage'} = [ $fsurl.'search/report_sqlradius_usage.html', '' ] + if $curuser->access_right("Usage: RADIUS sessions"); $report_rating{'Call Detail Records (CDRs)'} = [ $fsurl.'search/report_cdr.html', '' ] if $curuser->access_right("Usage: Call Detail Records (CDRs)"); $report_rating{'Unrateable CDRs'} = [ $fsurl.'search/cdr.html?freesidestatus=failed;cdrbatchnum=_ALL_' ] -- cgit v1.2.1 From dcb3f6aedb9f8af8495302ed7e2ba6b56bc6b0d8 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 13 Aug 2012 23:56:59 -0700 Subject: clean up various other RT initialization inconsistancy, RT#18719 --- httemplate/elements/select-rt-customfield.html | 3 --- 1 file changed, 3 deletions(-) (limited to 'httemplate/elements') diff --git a/httemplate/elements/select-rt-customfield.html b/httemplate/elements/select-rt-customfield.html index 7a45bb14b..85758d585 100644 --- a/httemplate/elements/select-rt-customfield.html +++ b/httemplate/elements/select-rt-customfield.html @@ -3,9 +3,6 @@ % } -<%once> -RT::Init(); - <%init> my %opt = @_; my $lookuptype = $opt{lookuptype}; -- cgit v1.2.1 From 00938b30a69411a743aa01db5e27100818a3c82b Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Tue, 14 Aug 2012 17:02:47 -0700 Subject: unsuspend fees, #6587 --- httemplate/elements/tr-select-reason.html | 57 +++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'httemplate/elements') diff --git a/httemplate/elements/tr-select-reason.html b/httemplate/elements/tr-select-reason.html index 5a79d68ef..c1df10b94 100755 --- a/httemplate/elements/tr-select-reason.html +++ b/httemplate/elements/tr-select-reason.html @@ -32,8 +32,15 @@ Example: