diff options
| -rw-r--r-- | httemplate/browse/rate_detail.html | 95 | ||||
| -rw-r--r-- | httemplate/browse/rate_region.html | 53 | ||||
| -rw-r--r-- | httemplate/edit/process/rate_detail.html | 13 | ||||
| -rw-r--r-- | httemplate/edit/rate_detail.html | 59 | 
4 files changed, 220 insertions, 0 deletions
| diff --git a/httemplate/browse/rate_detail.html b/httemplate/browse/rate_detail.html new file mode 100644 index 000000000..5dde85f8b --- /dev/null +++ b/httemplate/browse/rate_detail.html @@ -0,0 +1,95 @@ +<% include( 'elements/browse.html', +     'title'          => $title, +     'name_singular'  => 'rate', +     'html_init'      => $html_init, +     'menubar'        => [ 'Rate plans' => $p.'browse/rate.cgi' ], +     'query'          => { +                           'table'     => 'rate_detail', +                           'addl_from' => $join, +                           'hashref'   => { 'ratenum' => $ratenum }, +                           'extra_sql' => $where, +                         }, +     'count_query'    => "SELECT COUNT(*) FROM rate_detail $join". +                         " WHERE ratenum = $ratenum $where", +     'header'         => [ +                           'Region', +                           'Prefix(es)', +                           'Included<BR>minutes', +                           'Charge per<BR>minute', +                           'Granularity', +                         ], +     'fields'         => [ +                           'regionname', +                           sub { shift->dest_region->prefixes_short }, +                           sub { shift->min_included. +                                 ' <FONT SIZE="-1">(edit)</FONT>'; +                               }, +                           sub { $money_char. shift->min_charge. +                                 ' <FONT SIZE="-1">(edit)</FONT>'; +                               }, +                           sub { $granularity{ shift->sec_granularity } }, +                         ], +     'links'          => [ '', '', $edit_link,    $edit_link,    '' ], +     'link_onclicks'  => [ '', '', $edit_onclick, $edit_onclick, '' ], +     'align'          => 'llrrc', +   ) +%> +<%once> + +my %granularity = ( +  '1', => '1 second', +  '6'  => '6 second', +  '30' => '30 second', # '1/2 minute', +  '60' => 'minute', +); + +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; + +my $html_init = qq( +  <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws.js"></SCRIPT> +  <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_iframe.js"></SCRIPT> +  <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_draggable.js"></SCRIPT> +  <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/iframecontentmws.js"></SCRIPT> +); + +my $join = +  ' JOIN rate_region ON ( rate_detail.dest_regionnum = rate_region.regionnum )'; + +my $edit_link = [ 'javascript:void(0);', sub { ''; } ]; + +my $edit_onclick = sub { +  my $rate_detail = shift; +  my $ratedetailnum = $rate_detail->ratedetailnum; +  my $color = '#333399'; +  qq!overlib( OLiframeContent('${p}edit/rate_detail.html?$ratedetailnum', 540, 420, 'edit_rate_detail_popup' ), CAPTION, 'Edit tax rate', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;!; +}; + +</%once> +<%init> + +die "access denied" +  unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +$cgi->param('ratenum') =~ /^(\d+)$/ or die "unparsable ratenum"; +my $ratenum = $1; +my $rate = qsearchs('rate', { 'ratenum' => $ratenum } ) +  or die "unknown ratenum $ratenum"; +my $ratename = $rate->ratename; +my $title = "$ratename rates"; + +my @where = (); + +if ( $cgi->param('countrycode') =~ /^(\d+)$/ ) {  +  my $countrycode = $1; +  push @where, "0 < ( SELECT COUNT(*) FROM rate_prefix +                        WHERE rate_prefix.regionnum = rate_region.regionnum +                          AND countrycode = '$countrycode' +                    ) +               "; +  $title .= " for +$countrycode"; +} + +my $where = scalar(@where) ? ' AND '.join(' AND ', @where ) : ''; + +</%init> diff --git a/httemplate/browse/rate_region.html b/httemplate/browse/rate_region.html new file mode 100644 index 000000000..1d04b648c --- /dev/null +++ b/httemplate/browse/rate_region.html @@ -0,0 +1,53 @@ +<% include( 'elements/browse.html', +     'title'          => 'Rating Regions and Prefixes', +     'name_singular'  => 'region', #'rate region', +     'menubar'        => [ 'Rate plans' => $p.'browse/rate.cgi' ], +     'html_init'      => $html_init, +     'query'          => { +                           'select'    => $select, +                           'table'     => 'rate_region', +                           'addl_from' => $join, +                           'extra_sql' => $extra_sql,  +                           'order_by'  => 'ORDER BY LOWER(regionname)', +                         }, +     'count_query'    => 'SELECT COUNT(*) FROM rate_region', +     'header'         => [ '#',         'Region',  'Country code', 'Prefixes' ], +     'fields'         => [ 'regionnum', 'regionname',   'ccode',   'prefixes' ], +     'links'          => [ $link, $link, $link, $link ], +   ) +%> +<%once> + +my $edit_url = $p.'edit/rate_region.cgi'; + +my $link = [ "$edit_url?", 'regionnum' ]; + +my $html_init = +  'Regions and prefixes for VoIP and call billing.<BR><BR>'. +  qq(<A HREF="$edit_url"><I>Add a new region</I></A><BR><BR>); + +#not quite right for the shouldn't-happen multiple countrycode per region case +my $select = 'rate_region.*, '; +my $join = ''; +my $extra_sql = ''; +if ( driver_name =~ /^Pg/ ) { +  my $fromwhere = 'FROM rate_prefix'. +                  ' WHERE rate_prefix.regionnum = rate_region.regionnum'; +  $select .= "( SELECT countrycode $fromwhere LIMIT 1 ) AS ccode,  +              ARRAY_TO_STRING( ARRAY(SELECT npa $fromwhere), ',' ) AS prefixes"; +} elsif ( driver_name =~ /^mysql/i ) { +  $join = 'LEFT JOIN rate_prefix USING ( regionnum )'; +  $select .= "GROUP_CONCAT( DISTINCT countrycode ) AS ccode, +              GROUP_CONCAT( npa ORDER BY npa     ) AS prefixes "; +  $extra_sql = 'GROUP BY regionnum, regionname'; +} else { +  die 'unknown database '. driver_name; +} + +</%once> +<%init> + +die "access denied" +  unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/process/rate_detail.html b/httemplate/edit/process/rate_detail.html new file mode 100644 index 000000000..6200d615f --- /dev/null +++ b/httemplate/edit/process/rate_detail.html @@ -0,0 +1,13 @@ +<% include( 'elements/process.html', +              'table' => 'rate_detail', +              'popup_reload' => 'Rate changed', #a popup "parent reload" for now +              #someday change the individual element and go away instead +          ) +%> +<%init> + +my $conf = new FS::Conf; +die "access denied" +  unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/rate_detail.html b/httemplate/edit/rate_detail.html new file mode 100644 index 000000000..b9eaf657e --- /dev/null +++ b/httemplate/edit/rate_detail.html @@ -0,0 +1,59 @@ +<% include('elements/edit.html', +     'popup'  => 1, +     'name'   => $name, +     'table'  => 'rate_detail', +     'labels' => { 'ratedetailnum'       => 'Rate', #should hide... +                   'dest_regionname'     => 'Region', +                   'dest_prefixes_short' => 'Prefix(es)', +                   'min_included'        => 'Included minutes', +                   'min_charge'          => 'Charge per minute', +                   'sec_granularity'     => 'Granularity', +                 }, +     'fields' => [ +                   { field=>'ratenum',             type=>'hidden', }, +                   { field=>'orig_regionnum',      type=>'hidden', }, +                   { field=>'dest_regionnum',      type=>'hidden', }, +                   { field=>'dest_regionname',     type=>'fixed',  }, +                   { field=>'dest_prefixes_short', type=>'fixed',  }, +                   { field=>'min_included',        type=>'text',  size=>5 }, +                   { field=>'min_charge',          type=>'money', size=>4 }, +                   { field         =>'sec_granularity', +                     type          =>'select', +                     options       => [qw( 1 6 30 60 )], +                     labels        => \%granularity, +                     disable_empty => 1, +                   }, + +                 ], +   ) +%> +<%once> + +tie my %granularity, 'Tie::IxHash', +  '1', => '1 second', +  '6'  => '6 second', +  '30' => '30 second', # '1/2 minute', +  '60' => 'minute', +; + +</%once> + +<%init> + +my $conf = new FS::Conf; +die "access denied" +  unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +#slightly inefficient, i suppose an edit+error callback would be better +my $name = 'rate'; +if (    $cgi->keywords               =~ /^(\d+)$/ +     || $cgi->param('ratedetailnum') =~ /^(\d+)$/ ) { +  my $rate_detail = qsearchs('rate_detail', { 'ratedetailnum' => $1 } ) +    or die "unknown ratedetailnum $1"; +  $name = +    $rate_detail->rate->ratename. ' rate for '. $rate_detail->dest_regionname; +} + +#sec_granularity should default to 60!  for new rates when this gets used for em + +</%init> | 
