diff options
author | Ivan Kohler <ivan@freeside.biz> | 2012-10-04 20:25:37 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2012-10-04 20:25:37 -0700 |
commit | 0af38652da3b3be7da2d35b048285ef6f2194e1a (patch) | |
tree | c43e871e406a11ad9ddca7f5af225f8e5e507000 /httemplate/elements | |
parent | a8e1cb65cd92239721b8e81ef9fdf99f60fb3c3c (diff) | |
parent | 51b5bd15c154065a9a0f521565bd6187609c8348 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate/elements')
-rw-r--r-- | httemplate/elements/dashboard-toplist.html | 103 | ||||
-rw-r--r-- | httemplate/elements/location.html | 8 | ||||
-rw-r--r-- | httemplate/elements/menu.html | 9 | ||||
-rw-r--r-- | httemplate/elements/select-rt-customfield.html | 3 | ||||
-rw-r--r-- | httemplate/elements/select-table.html | 33 | ||||
-rw-r--r-- | httemplate/elements/tr-amount_fee.html | 4 | ||||
-rw-r--r-- | httemplate/elements/tr-select-cust_location.html | 1 | ||||
-rw-r--r-- | httemplate/elements/tr-select-discount.html | 26 | ||||
-rw-r--r-- | httemplate/elements/tr-select-part_referral.html | 8 | ||||
-rwxr-xr-x | httemplate/elements/tr-select-reason.html | 57 | ||||
-rw-r--r-- | httemplate/elements/tr-select-voip_class.html | 24 | ||||
-rw-r--r-- | httemplate/elements/tr-svc_export_machine.html | 37 |
12 files changed, 270 insertions, 43 deletions
diff --git a/httemplate/elements/dashboard-toplist.html b/httemplate/elements/dashboard-toplist.html index 72f596f4a..c6362e0c9 100644 --- a/httemplate/elements/dashboard-toplist.html +++ b/httemplate/elements/dashboard-toplist.html @@ -32,18 +32,21 @@ </FONT> </TD> -% foreach my $priority ( @custom_priorities, '' ) { -% my $num = -% FS::TicketSystem->num_customer_tickets($custnum,$priority); -% my $ahref = ''; -% $ahref= '<A HREF="'. -% FS::TicketSystem->href_customer_tickets($custnum,$priority). -% '">' -% if $num; - +% foreach my $priority ( @custom_priorities ) { <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> - <% $ahref.$num %></A> - </TD> +% my $num = $num_tickets_by_priority{$priority}->{$custnum}; +% if ( $num ) { + <A HREF="<% + FS::TicketSystem->href_customer_tickets($custnum,$priority) + %>"><% $num %></A> +% 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; +% } +% } + </TD> % } </TR> @@ -77,7 +80,7 @@ <TH CLASS="grid" BGCOLOR="#cccccc"><% $line %></TH> <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Lint') |h %></TH> <TH CLASS="grid" BGCOLOR="#cccccc"></TH> -% foreach my $priority ( @custom_priorities, '' ) { +% foreach my $priority ( @custom_priorities ) { <TH CLASS="grid" BGCOLOR="#cccccc"> <% $priority || '<i>(none)</i>'%> </TH> @@ -105,11 +108,83 @@ 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' + and $conf->config('dashboard-toplist') ) +{ + 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; + # optimization to keep this from taking a million years + my $cust_tickets = + "SELECT custnum, Tickets.Id, Tickets.Queue + FROM cust_main + JOIN Links ON ( + Links.Target = 'freeside://freeside/cust_main/' || CAST(cust_main.custnum AS $text) + AND Links.Base LIKE '%rt://%/ticket/%' + AND Links.Type = 'MemberOf' + ) JOIN Tickets ON (Links.LocalBase = Tickets.Id) + UNION + SELECT custnum, Tickets.Id, Tickets.Queue + FROM cust_pkg JOIN cust_svc USING (pkgnum) + JOIN Links ON ( + 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) + "; + + if ( $custom_priority_field ) { + $sql = + "SELECT cust_tickets.custnum AS custnum, + ObjectCustomFieldValues.Content as priority, + COUNT(DISTINCT cust_tickets.Id) AS num_tickets + FROM ($cust_tickets) AS cust_tickets + LEFT JOIN ObjectCustomFields ON ( + ObjectCustomFields.ObjectId = '0' OR + ObjectCustomFields.ObjectId = cust_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 = cust_tickets.Id + ) + GROUP BY cust_tickets.custnum, ObjectCustomFieldValues.Content"; + #warn $sql."\n"; + } else { # no custom_priority_field + $sql = + "SELECT cust_tickets.custnum, + '' as priority, + COUNT(DISTINCT cust_tickets.Id) AS num_tickets + FROM ($cust_tickets) AS cust_tickets + GROUP BY cust_tickets.custnum"; + } + 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}; + } +} +#warn Dumper \%num_tickets_by_priority; </%init> diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html index 767231856..5c7c888de 100644 --- a/httemplate/elements/location.html +++ b/httemplate/elements/location.html @@ -11,8 +11,10 @@ Example: 'no_asterisks' => 0, #set true to disable the red asterisks next #to required fields 'address1_label' => 'Address', #label for address + 'enable_coords' => 1, #show latitude/longitude fields 'enable_district' => 1, #show tax district field 'enable_censustract' => 1, #show censustract field + ) </%doc> @@ -175,6 +177,7 @@ Example: <TD COLSPAN=6><% include('/elements/select-country.html', %select_hash ) %></TD> </TR> +% if ( $opt{enable_coords} ) { <TR> <TD ALIGN="right"><% mt('Latitude') |h %></TH> <TD COLSPAN=7> @@ -195,6 +198,11 @@ Example: > </TD> </TR> +% } else { +% foreach (qw(latitude longitude)) { +<INPUT TYPE="hidden" NAME="<% $_ %>" VALUE="<% $object->get($_) |h%>"> +% } +% } <INPUT TYPE="hidden" NAME="<%$pre%>coord_auto" VALUE="<% $object->coord_auto %>"> <INPUT TYPE="hidden" NAME="<%$pre%>geocode" VALUE="<% $object->geocode %>"> diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 019afe94e..b2141e991 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -94,6 +94,11 @@ tie my %report_prospects, 'Tie::IxHash', 'Advanced prospect reports' => [ $fsurl. 'search/report_prospect_main.html', '' ], ; +tie my %report_quotations, 'Tie::IxHash', + 'List quotations' => [ $fsurl. 'search/quotation.html', '' ], + 'Advanced quotation reports' => [ $fsurl. 'search/report_quotation.html', '' ], +; + tie my %report_customers_lists, 'Tie::IxHash', 'by customer number' => [ $fsurl. 'search/cust_main.cgi?browse=custnum', '' ], 'by last name' => [ $fsurl. 'search/cust_main.cgi?browse=last', '' ], @@ -256,6 +261,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_' ] @@ -342,6 +349,8 @@ if($curuser->access_right('Financial reports')) { tie my %report_menu, 'Tie::IxHash'; $report_menu{'Prospects'} = [ \%report_prospects, 'Prospect reports' ] if $curuser->access_right('List prospects'); +$report_menu{'Quotations'} = [ \%report_quotations, 'Quotation reports' ] + if $curuser->access_right('List quotations'); $report_menu{'Customers'} = [ \%report_customers, 'Customer reports' ] if $curuser->access_right('List customers'); $report_menu{'Invoices'} = [ \%report_invoices, 'Invoice reports' ] 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 @@ <OPTION VALUE="<% shift @fields %>"><% shift @fields %></OPTION> % } </SELECT> -<%once> -RT::Init(); -</%once> <%init> my %opt = @_; my $lookuptype = $opt{lookuptype}; diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 127028ee5..c0cd7a50b 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -181,24 +181,29 @@ if ( $opt{'records'} ) { }); } -unless ( $value < 1 # !$value #ignore negatives too - or ref($value) +if ( ref( $value ) eq 'ARRAY' ) { + $value = { map { $_ => 1 } @$value }; +} + +unless ( !ref($value) && $value < 1 # !$value #ignore negatives too or ! exists( $opt{hashref}->{disabled} ) #?? - or grep { $value == $_->$key() } @records + #or grep { $value == $_->$key() } @records ) { delete $opt{hashref}->{disabled}; - $opt{hashref}->{$key} = $value; - my $record = qsearchs( { - 'table' => $opt{table}, - 'addl_from' => $opt{'addl_from'}, - 'hashref' => $hashref, - 'extra_sql' => $extra_sql, - }); - push @records, $record if $record; -} -if ( ref( $value ) eq 'ARRAY' ) { - $value = { map { $_ => 1 } @$value }; + foreach my $v ( ref($value) ? keys %$value : ($value) ) { + next if grep { $v == $_->$key() } @records; + + $opt{hashref}->{$key} = $v; + my $record = qsearchs( { + 'table' => $opt{table}, + 'addl_from' => $opt{'addl_from'}, + 'hashref' => $hashref, + 'extra_sql' => $extra_sql, + }); + push @records, $record if $record; + + } } my @pre_options = $opt{pre_options} ? @{ $opt{pre_options} } : (); 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); } diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html index d9e3e9e27..b804f4548 100644 --- a/httemplate/elements/tr-select-cust_location.html +++ b/httemplate/elements/tr-select-cust_location.html @@ -216,6 +216,7 @@ Example: 'no_asterisks' => 1, 'no_bold' => $opt{'no_bold'}, 'alt_format' => $opt{'alt_format'}, + 'enable_coords'=> 1, ) %> <SCRIPT TYPE="text/javascript"> diff --git a/httemplate/elements/tr-select-discount.html b/httemplate/elements/tr-select-discount.html index 30a60ec85..ee862519f 100644 --- a/httemplate/elements/tr-select-discount.html +++ b/httemplate/elements/tr-select-discount.html @@ -6,7 +6,7 @@ % } else { <TR> - <TD ALIGN="right" WIDTH="176"><% $opt{'label'} || '<B>'.emt('Discount').'</B>' %></TD> + <TD ALIGN="right" WIDTH="275"><% $opt{'label'} || '<B>'.emt('Discount').'</B>' %></TD> <TD <% $colspan %>> <% include( '/elements/select-discount.html', 'curr_value' => $discountnum, @@ -74,6 +74,16 @@ ) %> +%# <% include( '/elements/tr-checkbox.html', +%# 'label' => '<B>Apply discount to add-on packages</B>', +%# 'field' => $name.'_linked', +%# 'id' => $name.'_linked', +%# 'curr_value' => scalar($cgi->param($name.'_linked')), +%# 'value' => 'Y', +%# 'colspan' => $opt{'colspan'}, +%# ) +%# %> + <SCRIPT TYPE="text/javascript"> % my $ge = 'document.getElementById'; @@ -136,6 +146,10 @@ <% $ge %>('<% $name %>_percent_label0').style.visibility = 'hidden'; <% $ge %>('<% $name %>_percent_input0').style.display = 'none'; <% $ge %>('<% $name %>_percent_input0').style.visibility = 'hidden'; +// <% $ge %>('<% $name %>_linked_label0').style.display = 'none'; +// <% $ge %>('<% $name %>_linked_label0').style.visibility = 'hidden'; +// <% $ge %>('<% $name %>_linked').style.display = 'none'; +// <% $ge %>('<% $name %>_linked').style.visibility = 'hidden'; } else if ( <% $name %>__type == 'Amount' ) { <% $ge %>('<% $name %>_amount_label0').style.display = ''; <% $ge %>('<% $name %>_amount_label0').style.visibility = ''; @@ -145,6 +159,11 @@ <% $ge %>('<% $name %>_percent_label0').style.visibility = 'hidden'; <% $ge %>('<% $name %>_percent_input0').style.display = 'none'; <% $ge %>('<% $name %>_percent_input0').style.visibility = 'hidden'; + <% $ge %>('<% $name %>_percent_input0').style.visibility = 'hidden'; +// <% $ge %>('<% $name %>_linked_label0').style.display = 'none'; +// <% $ge %>('<% $name %>_linked_label0').style.visibility = 'hidden'; +// <% $ge %>('<% $name %>_linked').style.display = 'none'; +// <% $ge %>('<% $name %>_linked').style.visibility = 'hidden'; } else if ( <% $name %>__type == 'Percentage' ) { <% $ge %>('<% $name %>_amount_label0').style.display = 'none'; <% $ge %>('<% $name %>_amount_label0').style.visibility = 'hidden'; @@ -154,6 +173,11 @@ <% $ge %>('<% $name %>_percent_label0').style.visibility = ''; <% $ge %>('<% $name %>_percent_input0').style.display = ''; <% $ge %>('<% $name %>_percent_input0').style.visibility = ''; + <% $ge %>('<% $name %>_percent_input0').style.visibility = ''; +// <% $ge %>('<% $name %>_linked_label0').style.display = ''; +// <% $ge %>('<% $name %>_linked_label0').style.visibility = ''; +// <% $ge %>('<% $name %>_linked').style.display = ''; +// <% $ge %>('<% $name %>_linked').style.visibility = ''; } } 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 @@ <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'refnum' %>" VALUE="<% $opt{'part_referrals'}->[0]->refnum %>"> % } else { - - <TR> -% if ( $opt{'label'} ) { - <TD ALIGN="right"><% $opt{'label'} %></TD> -% } else { - <TH ALIGN="right"><%$r%><% mt('Advertising source') |h %></TH> -% } + <& /elements/tr-td-label.html, label => 'Advertising source', %opt &> <TD COLSPAN="<% $colspan %>"> <& /elements/select-part_referral.html, 'curr_value' => $refnum, 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: <SCRIPT TYPE="text/javascript"> function sh_add<% $func_suffix %>() { + var hints = <% encode_json(\@hints) %>; + var select_reason = document.getElementById('<% $id %>'); - if (document.getElementById('<% $id %>').selectedIndex == 0){ +% if ( $class eq 'S' ) { + document.getElementById('<% $id %>_hint').innerHTML = + hints[select_reason.selectedIndex]; +% } + + if (select_reason.selectedIndex == 0){ <% $controlledbutton ? $controlledbutton.'.disabled = true;' : ';' %> }else{ <% $controlledbutton ? $controlledbutton.'.disabled = false;' : ';' %> @@ -41,8 +48,8 @@ Example: %if ($curuser->access_right($add_access_right)){ - if (document.getElementById('<% $id %>').selectedIndex == - (document.getElementById('<% $id %>').length - 1)) { + if (select_reason.selectedIndex == + (select_reason.length - 1)) { document.getElementById('new<% $id %>').disabled = false; document.getElementById('new<% $id %>').style.display = 'inline'; document.getElementById('new<% $id %>Label').style.display = 'inline'; @@ -113,6 +120,13 @@ Example: </TR> % } +% if ( $class eq 'S' ) { +<TR> + <TD COLSPAN=2 ALIGN="center" id="<% $id %>_hint"> + </TD> +</TR> +% } + <TR> <TD ALIGN="right"> <P id="new<% $id %>Label" style="display:<% $display %>"><% mt('New Reason') |h %></P> @@ -184,6 +198,43 @@ my @reasons = qsearch({ order_by => 'ORDER BY reason_type.type ASC, reason.reason ASC', }); +my @hints; +if ( $class eq 'S' ) { + my $conf = FS::Conf->new; + @hints = ( '' ); + foreach my $reason (@reasons) { + if ( $reason->unsuspend_pkgpart ) { + my $part_pkg = FS::part_pkg->by_key($reason->unsuspend_pkgpart); + if ( $part_pkg ) { + if ( $part_pkg->option('setup_fee',1) > 0 and + $part_pkg->option('recur_fee',1) == 0 ) { + # the usual case + push @hints, + mt('A [_1] unsuspension fee will apply.', + ($conf->config('money_char') || '$') . + sprintf('%.2f', $part_pkg->option('setup_fee')) + ); + } else { + # oddball cases--not really supported + push @hints, + mt('An unsuspension package will apply: [_1]', + $part_pkg->price_info + ); + } + } else { #no $part_pkg + push @hints, + '<FONT COLOR="#ff0000">Unsuspend pkg #'.$reason->unsuspend_pkgpart. + ' not found.</FONT>'; + } + } else { #no unsuspend_pkgpart + push @hints, ''; + } + } + push @hints, ''; # for the "new reason" case + @hints = map {'<FONT SIZE="-1">'.$_.'</FONT>'} @hints; +} + + my $curuser = $FS::CurrentUser::CurrentUser; </%init> diff --git a/httemplate/elements/tr-select-voip_class.html b/httemplate/elements/tr-select-voip_class.html new file mode 100644 index 000000000..dcc1487cc --- /dev/null +++ b/httemplate/elements/tr-select-voip_class.html @@ -0,0 +1,24 @@ +<& tr-td-label.html, label => 'Category', @_ &> +<TD> +<SELECT NAME="<% $opt{'field'} %>"> +% while(@options) { +% my $value = shift @options; +% my $selected = ($value eq $opt{'curr_value'}) ? 'SELECTED' : ''; + <OPTION VALUE="<% $value %>" <% $selected %>><% shift @options %></OPTION> +% } +</SELECT> +</TD></TR> +<%init> +my %opt = ( + field => 'fcc_voip_class', + label => 'Category', + @_ +); +my @options = ( + '' => '', + 1 => 'VoIP without Broadband', + 2 => 'VoIP with Broadband', + 3 => 'Wholesale VoIP' +); + +</%init> diff --git a/httemplate/elements/tr-svc_export_machine.html b/httemplate/elements/tr-svc_export_machine.html new file mode 100644 index 000000000..92b6ac1d7 --- /dev/null +++ b/httemplate/elements/tr-svc_export_machine.html @@ -0,0 +1,37 @@ +% foreach my $part_export (@part_export) { +% my $label = ( $part_export->exportname +% ? $part_export->exportname +% : $part_export->label +% ). +% ' hostname'; +% +% my $element = 'exportnum'. $part_export->exportnum. 'machinenum'; +% my $machinenum = $opt{cgi}->param($element); +% if ( ! $machinenum && $opt{svc}->svcnum ) { +% my $svc_export_machine = qsearchs('svc_export_machine', { +% 'svcnum' => $opt{svc}->svcnum, +% 'exportnum' => $part_export->exportnum, +% }); +% $machinenum = $svc_export_machine->machinenum if $svc_export_machine; +% } + + <& /elements/tr-select-table.html, + 'label' => $label, + 'element_name' => 'exportnum'. $part_export->exportnum. 'machinenum', + 'table' => 'part_export_machine', + 'name_col' => 'machine', + 'hashref' => { 'exportnum' => $part_export->exportnum, + 'disabled' => '', + }, + 'curr_value' => $machinenum, + 'empty_label' => 'Select export hostname', + &> +% } +<%init> + +my %opt = @_; + +my @part_export = grep { $_->machine eq '_SVC_MACHINE' } + $opt{part_svc}->part_export; + +</%init> |