diff options
Diffstat (limited to 'httemplate/browse')
27 files changed, 2955 insertions, 0 deletions
diff --git a/httemplate/browse/access_group.html b/httemplate/browse/access_group.html new file mode 100644 index 000000000..736ab9c62 --- /dev/null +++ b/httemplate/browse/access_group.html @@ -0,0 +1,108 @@ +<% include( 'elements/browse.html', + 'title' => 'Internal Access Groups', + 'menubar' => [ 'Internal users' => $p.'browse/access_user.html', ], + 'html_init' => $html_init, + 'name' => 'internal access groups', + 'query' => { 'table' => 'access_group', + 'hashref' => {}, + 'extra_sql' => 'ORDER BY groupname', #?? + }, + 'count_query' => $count_query, + 'header' => [ '#', + 'Group name', + 'Agents', + 'Rights', + ], + 'fields' => [ 'groupnum', + 'groupname', + $agents_sub, + $rights_sub, + ], + 'links' => [ $link, + $link, + '', + '', + ], + ) +%> +<%once> + +my $html_init = + "Internal access groups control access to the back-office interface.<BR><BR>". + qq!<A HREF="${p}edit/access_group.html"><I>Add an internal access group</I></A><BR><BR>!; + +#false laziness w/access_user.html & agent_type.cgi +my $agents_sub = sub { + my $access_group = shift; + + [ map { + my $access_groupagent = $_; + my $agent = $access_groupagent->agent; + [ + { + 'data' => $agent->agent, + 'align' => 'left', + 'link' => $p. 'edit/agent.cgi?'. $agent->agentnum, + }, + ]; + } + grep { $_->agent } #? + $access_group->access_groupagent, + + ]; + +}; + +tie my %rights, 'Tie::IxHash', FS::AccessRight->rights_info; + +my $rights_sub = sub { + my $access_group = shift; + + #[ map { my $access_right = $_; + # [ + # { + # 'data' => $access_right->rightname, + # 'align' => 'left', + # }, + # ]; + # } + # $access_group->access_rights, + #]; + + #some false laziness w/edit/access_group.html + my $columns = 3; + my $count = 0; + + #include('/elements/table-grid.html', bgcolor=>'#cccccc' ). + '<TABLE>'. + '<TR>'. join( '', map { + + '<TD CLASS="inv" VALIGN="top"><TABLE WIDTH=100%>'. + '<TR><TH BGCOLOR="#dcdcdc">'. $_. '</TH></TR>'. + '<TR><TD>'. + + join('<BR>', grep { warn "$access_group->access_right($_): ". + $access_group->access_right($_). "\n"; + $access_group->access_right($_); } + map { ref($_) ? $_->{'rightname'} : $_; } + @{ $rights{$_} } + ). + + '</TD></TR></TABLE></TD>'. + ( ++$count % $columns ? '' : '</TR><TR>') + + } keys %rights ). '</TR></TABLE>'; + +}; + +my $count_query = 'SELECT COUNT(*) FROM access_group'; + +my $link = [ $p.'edit/access_group.html?', 'groupnum' ]; + +</%once> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/browse/access_user.html b/httemplate/browse/access_user.html new file mode 100644 index 000000000..2aa752b73 --- /dev/null +++ b/httemplate/browse/access_user.html @@ -0,0 +1,61 @@ +<% include( 'elements/browse.html', + 'title' => 'Internal Users', + 'menubar' => [ 'Internal access groups' => $p.'browse/access_group.html', ], + 'html_init' => $html_init, + 'name' => 'internal users', + 'disableable' => 1, + 'disabled_statuspos' => 2, + 'query' => { 'table' => 'access_user', + 'hashref' => {}, + 'extra_sql' => 'ORDER BY last, first' + }, + 'count_query' => $count_query, + 'header' => \@header, + 'fields' => \@fields, + 'links' => \@links, + 'align' => $align, + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $html_init = + "Internal users have access to the back-office interface. Typically, this is your employees and contractors. In a VISP setup, you can also add accounts for your reseller's employees.<BR><BR>It is <B>highly recommended</B> to add a <B>separate account for each person</B> rather than using role accounts.<BR><BR>". + qq!<A HREF="${p}edit/access_user.html"><I>Add an internal user</I></A><BR><BR>!; + +#false laziness w/access_group.html & agent_type.cgi +my $groups_sub = sub { + my $access_user = shift; + + [ map { + my $access_usergroup = $_; + my $access_group = $access_usergroup->access_group; + [ + { + 'data' => $access_group->groupname, + 'align' => 'left', + 'link' => + $p. 'edit/access_group.html?'. $access_usergroup->groupnum, + }, + ]; + } + grep { $_->access_group # and ! $_->access_group->disabled + } + $access_user->access_usergroup, + + ]; + +}; + +my $count_query = 'SELECT COUNT(*) FROM access_user'; + +my $link = [ $p.'edit/access_user.html?', 'usernum' ]; + +my @header = ( '#', 'Username', 'Full name', 'Groups' ); +my @fields = ( 'usernum', 'username', 'name', $groups_sub ); +my $align = 'rlll'; +my @links = ( $link, $link, $link, '' ); + +</%init> diff --git a/httemplate/browse/addr_block.cgi b/httemplate/browse/addr_block.cgi new file mode 100644 index 000000000..eac7cf7b6 --- /dev/null +++ b/httemplate/browse/addr_block.cgi @@ -0,0 +1,80 @@ +<% include('/elements/header.html', 'Address Blocks') %> + +<% include('/elements/error.html') %> + +<%table()%> +% foreach $block (sort {$a->NetAddr cmp $b->NetAddr} @addr_block) { + + <TR> + <TD><%$block->NetAddr%></TD> +% if (my $router = $block->router) { +% if (scalar($block->svc_broadband) == 0) { + + <TD> + <%$router->routername%> + </TD> + <TD> + <FORM ACTION="<%$path%>/deallocate.cgi" METHOD="POST"> + <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%$block->blocknum%>"> + <INPUT TYPE="submit" NAME="submit" VALUE="Deallocate"> + </FORM> + </TD> +% } else { + + <TD COLSPAN="2"> + <%$router->routername%> + </TD> +% } +% } else { + + <TD> + <FORM ACTION="<%$path%>/allocate.cgi" METHOD="POST"> + <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%$block->blocknum%>"> + <SELECT NAME="routernum" SIZE="1"> +% foreach (@router) { + + <OPTION VALUE="<%$_->routernum %>"><%$_->routername%></OPTION> +% } + + </SELECT> + <INPUT TYPE="submit" NAME="submit" VALUE="Allocate"> + </FORM> + </TD> + <TD> + <FORM ACTION="<%$path%>/split.cgi" METHOD="POST"> + <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%$block->blocknum%>"> + <INPUT TYPE="submit" NAME="submit" VALUE="Split"> + </FORM> + </TD> + </TR> +% } +% } + + <TR><TD COLSPAN="3"><BR></TD></TR> + <TR> + <FORM ACTION="<%$path%>/add.cgi" METHOD="POST"> + <TD>Gateway/Netmask</TD> + <TD> + <INPUT TYPE="text" NAME="ip_gateway" SIZE="15">/<INPUT TYPE="text" NAME="ip_netmask" SIZE="2"> + </TD> + <TD> + <INPUT TYPE="submit" NAME="submit" VALUE="Add"> + </TD> + </FORM> + </TR> +</TABLE> + +<% include('/elements/footer.html') %> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my @addr_block = qsearch('addr_block', {}); +my @router = qsearch('router', {}); +my $block; +my $p2 = popurl(2); +my $path = $p2 . "edit/process/addr_block"; + +</%init> diff --git a/httemplate/browse/agent.cgi b/httemplate/browse/agent.cgi new file mode 100755 index 000000000..234bfa74a --- /dev/null +++ b/httemplate/browse/agent.cgi @@ -0,0 +1,401 @@ +<% include("/elements/header.html",'Agent Listing', menubar( + 'Agent Types' => $p. 'browse/agent_type.cgi', +# 'Add new agent' => '../edit/agent.cgi' +)) %> +Agents are resellers of your service. Agents may be limited to a subset of your +full offerings (via their type).<BR><BR> +<A HREF="<% $p %>edit/agent.cgi"><I>Add a new agent</I></A><BR><BR> +% if ( dbdef->table('agent')->column('disabled') ) { + + <% $cgi->param('showdisabled') + ? do { $cgi->param('showdisabled', 0); + '( <a href="'. $cgi->self_url. '">hide disabled agents</a> )'; } + : do { $cgi->param('showdisabled', 1); + '( <a href="'. $cgi->self_url. '">show disabled agents</a> )'; } + %> +% } + + +<% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; +% + + +<TR> + <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% ( $cgi->param('showdisabled') || !dbdef->table('agent')->column('disabled') ) ? 2 : 3 %>>Agent</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Type</TH> + <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Invoice<BR>Template</FONT></TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Customers</TH> + <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Customer<BR>packages</FONT></TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Reports</TH> + <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Registration<BR>codes</FONT></TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Prepaid cards</TH> +% if ( $conf->config('ticket_system') ) { + + <TH CLASS="grid" BGCOLOR="#cccccc">Ticketing</TH> +% } + + <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Payment Gateway Overrides</FONT></TH> + <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Configuration Overrides</FONT></TH> +</TR> +% +%# <TH><FONT SIZE=-1>Agent #</FONT></TH> +%# <TH>Agent</TH> +% +%foreach my $agent ( sort { +% #$a->getfield('agentnum') <=> $b->getfield('agentnum') +% $a->getfield('agent') cmp $b->getfield('agent') +%} qsearch('agent', \%search ) ) { +% +% my $cust_main_link = $p. 'search/cust_main.cgi?agentnum_on=1&'. +% 'agentnum='. $agent->agentnum; +% +% my $cust_pkg_link = $p. 'search/cust_pkg.cgi?agentnum='. $agent->agentnum; +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% + + + <TR> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>"><% $agent->agentnum %></A> + </TD> + +% if ( dbdef->table('agent')->column('disabled') +% && !$cgi->param('showdisabled') ) { + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $agent->disabled ? 'DISABLED' : '' %> + </TD> +% } + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>"><% $agent->agent %></A> + </TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <A HREF="<%$p%>edit/agent_type.cgi?<% $agent->typenum %>"><% $agent->agent_type->atype %></A> + </TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $agent->invoice_template || '(Default)' %> + </TD> + + <TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> + <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#7e0079"> + <% my $num_prospect = $agent->num_prospect_cust_main %> + </FONT> + </TH> + + <TD> +% if ( $num_prospect ) { + + <A HREF="<% $cust_main_link %>&prospect=1"> +% } +prospects +% if ($num_prospect ) { +</A> +% } + + <TD> + </TR> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#0000CC"> + <% my $num_inactive = $agent->num_inactive_cust_main %> + </FONT> + </TH> + + <TD> +% if ( $num_inactive ) { + + <A HREF="<% $cust_main_link %>&inactive=1"> +% } +inactive +% if ( $num_inactive ) { +</A> +% } + + </TD> + </TR> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#00CC00"> + <% my $num_active = $agent->num_active_cust_main %> + </FONT> + </TH> + + <TD> +% if ( $num_active ) { + + <A HREF="<% $cust_main_link %>&active=1"> +% } +active +% if ( $num_active ) { +</A> +% } + + </TD> + </TR> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#FF9900"> + <% my $num_susp = $agent->num_susp_cust_main %> + </FONT> + </TH> + + <TD> +% if ( $num_susp ) { + + <A HREF="<% $cust_main_link %>&suspended=1"> +% } +suspended +% if ( $num_susp ) { +</A> +% } + + </TD> + </TR> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#FF0000"> + <% my $num_cancel = $agent->num_cancel_cust_main %> + </FONT> + </TH> + + <TD> +% if ( $num_cancel ) { + + <A HREF="<% $cust_main_link %>&showcancelledcustomers=1&cancelled=1"> +% } +cancelled +% if ( $num_cancel ) { +</A> +% } + + </TD> + </TR> + + </TABLE> + </TD> + + <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" VALIGN="bottom"> + <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#0000CC"> + <% my $num_inactive_pkg = $agent->num_inactive_cust_pkg %> + </FONT> + </TH> + + <TD> +% if ( $num_inactive_pkg ) { + + <A HREF="<% $cust_pkg_link %>&magic=inactive"> +% } +inactive +% if ( $num_inactive_pkg ) { +</A> +% } + + </TD> + </TR> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#00CC00"> + <% my $num_active_pkg = $agent->num_active_cust_pkg %> + </FONT> + </TH> + + <TD> +% if ( $num_active_pkg ) { + + <A HREF="<% $cust_pkg_link %>&magic=active"> +% } +active +% if ( $num_active_pkg ) { +</A> +% } + + </TD> + </TR> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#FF9900"> + <% my $num_susp_pkg = $agent->num_susp_cust_pkg %> + </FONT> + + </TH> + <TD> +% if ( $num_susp_pkg ) { + + <A HREF="<% $cust_pkg_link %>&magic=suspended"> +% } +suspended +% if ( $num_susp_pkg ) { +</A> +% } + + </TD> + </TR> + + <TR> + <TH ALIGN="right" WIDTH="40%"> + <FONT COLOR="#FF0000"> + <% my $num_cancel_pkg = $agent->num_cancel_cust_pkg %> + </FONT> + </TH> + + <TD> +% if ( $num_cancel_pkg ) { + + <A HREF="<% $cust_pkg_link %>&magic=cancelled"> +% } +cancelled +% if ( $num_cancel_pkg ) { +</A> +% } + + </TD> + </TR> + + </TABLE> + </TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <A HREF="<% $p %>graph/report_cust_pkg.html?agentnum=<% $agent->agentnum %>">Package Churn</A> + <BR><A HREF="<% $p %>search/report_cust_pay.html?agentnum=<% $agent->agentnum %>">Payments</A> + <BR><A HREF="<% $p %>search/report_cust_credit.html?agentnum=<% $agent->agentnum %>">Credits</A> + <BR><A HREF="<% $p %>search/report_receivables.cgi?agentnum=<% $agent->agentnum %>">A/R Aging</A> + <!--<BR><A HREF="<% $p %>search/money_time.cgi?agentnum=<% $agent->agentnum %>">Sales/Credits/Receipts</A>--> + + </TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% my $num_reg_code = $agent->num_reg_code %> +% if ( $num_reg_code ) { + + <A HREF="<%$p%>search/reg_code.html?agentnum=<% $agent->agentnum %>"> +% } +Unused +% if ( $num_reg_code ) { +</A> +% } + + <BR><A HREF="<%$p%>edit/reg_code.cgi?agentnum=<% $agent->agentnum %>">Generate codes</A> + </TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% my $num_prepay_credit = $agent->num_prepay_credit %> +% if ( $num_prepay_credit ) { + + <A HREF="<%$p%>search/prepay_credit.html?agentnum=<% $agent->agentnum %>"> +% } +Unused +% if ( $num_prepay_credit ) { +</A> +% } + + <BR><A HREF="<%$p%>edit/prepay_credit.cgi?agentnum=<% $agent->agentnum %>">Generate cards</A> + </TD> +% if ( $conf->config('ticket_system') ) { + + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> +% if ( $agent->ticketing_queueid ) { + + Queue: <% $agent->ticketing_queueid %>: <% $agent->ticketing_queue %><BR> +% } + + </TD> +% } + + + <TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> + <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0> +% foreach my $override ( +% # sort { } want taxclass-full stuff first? and default cards (empty cardtype) +% qsearch('agent_payment_gateway', { 'agentnum' => $agent->agentnum } ) +% ) { +% + + <TR> + <TD> + <% $override->cardtype || 'Default' %> to <% $override->payment_gateway->gateway_module %> (<% $override->payment_gateway->gateway_username %>) + <% $override->taxclass + ? ' for '. $override->taxclass. ' only' + : '' + %> + <FONT SIZE=-1><A HREF="<%$p%>misc/delete-agent_payment_gateway.cgi?<% $override->agentgatewaynum %>">(delete)</A></FONT> + </TD> + </TR> +% } + + <TR> + <TD><FONT SIZE=-1><A HREF="<%$p%>edit/agent_payment_gateway.html?agentnum=<% $agent->agentnum %>">(add override)</A></FONT></TD> + </TR> + </TABLE> + </TD> + + <TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> + <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0> +% foreach my $override ( +% qsearch('conf', { 'agentnum' => $agent->agentnum } ) +% ) { +% + + <TR> + <TD> + <% $override->name %> + <FONT SIZE=-1><A HREF="<%$p%>config/config-delete.cgi?<% $override->confnum %>">(delete)</A></FONT> + </TD> + </TR> +% } + + <TR> + <TD><FONT SIZE=-1><A HREF="<%$p%>config/config-view.cgi?agentnum=<% $agent->agentnum %>">(add override)</A></FONT></TD> + </TR> + </TABLE> + </TD> + + </TR> +% } + + + </TABLE> + </BODY> +</HTML> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my %search; +if ( $cgi->param('showdisabled') + || !dbdef->table('agent')->column('disabled') ) { + %search = (); +} else { + %search = ( 'disabled' => '' ); +} + +my $conf = new FS::Conf; + +</%init> diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi new file mode 100755 index 000000000..d64ff186a --- /dev/null +++ b/httemplate/browse/agent_type.cgi @@ -0,0 +1,61 @@ +<% include( 'elements/browse.html', + 'title' => 'Agent Types', + 'menubar' => [ 'Agents' =>"${p}browse/agent.cgi", ], + 'html_init' => $html_init, + 'name' => 'agent types', + 'query' => { 'table' => 'agent_type', + 'hashref' => {}, + 'extra_sql' => 'ORDER BY typenum', # 'ORDER BY atype', + }, + 'count_query' => $count_query, + 'header' => [ '#', + 'Agent Type', + 'Packages', + ], + 'fields' => [ 'typenum', + 'atype', + $packages_sub, + ], + 'links' => [ $link, + $link, + '', + ], + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $html_init = +'Agent types define groups of packages that you can then assign to'. +' particular agents.<BR><BR>'. +qq!<A HREF="${p}edit/agent_type.cgi"><I>Add a new agent type</I></A><BR><BR>!; + +my $count_query = 'SELECT COUNT(*) FROM agent_type'; + +#false laziness w/access_user.html +my $packages_sub = sub { +my $agent_type = shift; + +[ map { + my $type_pkgs = $_; + #my $part_pkg = $type_pkgs->part_pkg; + [ + { + #'data' => $part_pkg->pkg. ' - '. $part_pkg->comment, + 'data' => $type_pkgs->pkg. ' - '. $type_pkgs->comment, + 'align' => 'left', + 'link' => $p. 'edit/part_pkg.cgi?'. $type_pkgs->pkgpart, + }, + ]; + } + + $agent_type->type_pkgs_enabled +]; + +}; + +my $link = [ $p.'edit/agent_type.cgi?', 'typenum' ]; + +</%init> diff --git a/httemplate/browse/cust_main_county.cgi b/httemplate/browse/cust_main_county.cgi new file mode 100755 index 000000000..12bdeb333 --- /dev/null +++ b/httemplate/browse/cust_main_county.cgi @@ -0,0 +1,288 @@ +<% include( 'elements/browse.html', + 'title' => "Tax Rates $title", + 'name_singular' => 'tax rate', + 'menubar' => \@menubar, + 'html_init' => $html_init, + 'html_posttotal' => $html_posttotal, + 'query' => { + 'table' => 'cust_main_county', + 'hashref' => $hashref, + 'order_by' => + 'ORDER BY country, state, county, taxclass', + }, + 'count_query' => $count_query, + 'header' => \@header, + 'header2' => \@header2, + 'fields' => \@fields, + 'align' => $align, + 'color' => \@color, + 'cell_style' => \@cell_style, + 'links' => \@links, + 'link_onclicks' => \@link_onclicks, + ) +%> +% +% # <FONT SIZE=-1><A HREF="<% $p %>edit/process/cust_main_county-collapse.cgi?<% $hashref->{taxnum} %>">collapse state</A></FONT> +% # % } +% +<%once> + +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; + +my @manual_countries = ( 'US', 'CA', 'AU', 'NZ', 'GB' ); #some manual ordering +my @all_countries = ( @manual_countries, + grep { my $c = $_; ! grep { $c eq $_ } @manual_countries } + map { $_->country } + qsearch({ + 'select' => 'country', + 'table' => 'cust_main_county', + 'hashref' => {}, + 'extra_sql' => 'GROUP BY country', + }) + ); + +my $exempt_sub = sub { + my $cust_main_county = shift; + + my @exempt = (); + push @exempt, + sprintf("$money_char%.2f per month", $cust_main_county->exempt_amount ) + if $cust_main_county->exempt_amount > 0; + + push @exempt, 'Setup fee' + if $cust_main_county->setuptax =~ /^Y$/i; + + push @exempt, 'Recurring fee' + if $cust_main_county->recurtax =~ /^Y$/i; + + [ map [ {'data'=>$_} ], @exempt ]; +}; + +my $oldrow; +my $cell_style; +my $cell_style_sub = sub { + my $row = shift; + if ( $oldrow ne $row ) { + if ( $oldrow ) { + if ( $oldrow->country ne $row->country ) { + $cell_style = 'border-top:1px solid #000000'; + } elsif ( $oldrow->state ne $row->state ) { + $cell_style = 'border-top:1px solid #cccccc'; #default? + } elsif ( $oldrow->state eq $row->state ) { + #$cell_style = 'border-top:dashed 1px dark gray'; + $cell_style = 'border-top:1px dashed #cccccc'; + } + } + $oldrow = $row; + } + return $cell_style; +}; + +#my $edit_link = [ "${p}edit/cust_main_county.html", 'taxnum' ]; +my $edit_link = [ 'javascript:void(0);', sub { ''; } ]; + +my $edit_onclick = sub { + my $row = shift; + my $taxnum = $row->taxnum; + my $color = '#333399'; + qq!overlib( OLiframeContent('${p}edit/cust_main_county.html?$taxnum', 540, 420, 'edit_cust_main_county_popup' ), CAPTION, 'Edit tax rate', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;!; +}; + +sub expand_link { + my( $row, $desc ) = @_; + my $taxnum = $row->taxnum; + my $url = "${p}edit/cust_main_county-expand.cgi?$taxnum"; + my $color = '#333399'; + + qq!<FONT SIZE="-1"><A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('$url', 540, 420, 'edit_cust_main_county_popup' ), CAPTION, '$desc', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;">!; +} + +sub separate_taxclasses_link { + my( $row ) = @_; + my $taxnum = $row->taxnum; + my $url = "${p}edit/process/cust_main_county-expand.cgi?taxclass=1;taxnum=$taxnum"; + + qq!<FONT SIZE="-1"><A HREF="$url">!; +} + +</%once> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +#my $conf = new FS::Conf; +#my $money_char = $conf->config('money_char') || '$'; +my $enable_taxclasses = $conf->exists('enable_taxclasses'); + +my @menubar; + +my $html_init = + "Click on <u>add states</u> to specify a country's tax rates by state or province. + <BR>Click on <u>add counties</u> to specify a state's tax rates by county."; +$html_init .= "<BR>Click on <u>separate taxclasses</u> to specify taxes per taxclass." + if $enable_taxclasses; +$html_init .= '<BR><BR>'; + +$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 $title = ''; + +my $country = ''; +if ( $cgi->param('country') =~ /^(\w\w)$/ ) { + $country = $1; + $title = $country; +} +$cgi->delete('country'); + +my $state = ''; +if ( $cgi->param('state') =~ /^([\w \-\'\[\]]+)$/ ) { + $state = $1; + $title = "$state, $title"; +} +$cgi->delete('state'); + +my $county = ''; +if ( $cgi->param('county') =~ /^([\w \-\'\[\]]+)$/ ) { + $county = $1; + $title = "$county county, $title"; +} +$cgi->delete('county'); + +$title = " for $title" if $title; + +my $taxclass = ''; +if ( $cgi->param('taxclass') =~ /^([\w \-]+)$/ ) { + $taxclass = $1; + $title .= " for $taxclass tax class"; +} +$cgi->delete('taxclass'); + +if ( $country || $taxclass ) { + push @menubar, 'View all tax rates' => $p.'browse/cust_main_county.cgi'; +} + +$cgi->param('dummy', 1); + +my $country_filter_change = + "window.location = '". + $cgi->self_url. ";country=' + this.options[this.selectedIndex].value;"; + +#restore this so pagination works +$cgi->param('country', $country) if $country; +$cgi->param('state', $state ) if $state; +$cgi->param('county', $county ) if $county; +$cgi->param('taxclass', $county ) if $taxclass; + +my $html_posttotal = + '(show country: '. + qq(<SELECT NAME="country" onChange="$country_filter_change">). + qq(<OPTION VALUE="">(all)\n). + join("\n", map qq[<OPTION VALUE="$_"]. + ( $_ eq $country ? 'SELECTED' : '' ). + '>'. code2country($_). " ($_)", + @all_countries + ). + '</SELECT>)'; + +my $hashref = {}; +my $count_query = 'SELECT COUNT(*) FROM cust_main_county'; +if ( $country ) { + $hashref->{'country'} = $country; + $count_query .= ' WHERE country = '. dbh->quote($country); +} +if ( $state ) { + $hashref->{'state'} = $state; + $count_query .= ' AND state = '. dbh->quote($state); +} +if ( $county ) { + $hashref->{'country'} = $country; + $count_query .= ' AND county = '. dbh->quote($county); +} +if ( $taxclass ) { + $hashref->{'taxclass'} = $taxclass; + $count_query .= ( $count_query =~ /WHERE/i ? ' AND ' : ' WHERE ' ). + ' taxclass = '. dbh->quote($taxclass); +} + + +$cell_style = ''; + +my @header = ( 'Country', 'State/Province', 'County',); +my @header2 = ( '', '', '', ); +my @links = ( '', '', '', ); +my @link_onclicks = ( '', '', '', ); +my $align = 'lll'; + +my @fields = ( + sub { my $country = shift->country; + code2country($country). " ($country)"; + }, + sub { state_label($_[0]->state, $_[0]->country). + ( $_[0]->state + ? '' + : ' '. expand_link($_[0], 'Add States'). + 'add states</A></FONT>' + ) + }, + sub { $_[0]->county || '(all) '. + expand_link($_[0], 'Add Counties'). + 'add counties</A></FONT>' + }, +); + +my @color = ( + '000000', + sub { shift->state ? '000000' : '999999' }, + sub { shift->county ? '000000' : '999999' }, +); + +if ( $conf->exists('enable_taxclasses') ) { + push @header, qq!Tax class (<A HREF="${p}edit/part_pkg_taxclass.html">add new</A>)!; + push @header2, '(per-package classification)'; + push @fields, sub { $_[0]->taxclass || '(all) '. + separate_taxclasses_link($_[0], 'Separate Taxclasses'). + 'separate taxclasses</A></FONT>' + }; + push @color, sub { shift->taxclass ? '000000' : '999999' }; + push @links, ''; + push @link_onclicks, ''; + $align .= 'l'; +} + +push @header, 'Tax name', + 'Rate', #'Tax', + 'Exemptions', + ; + +push @header2, '(printed on invoices)', + '', + '', + ; + +push @fields, + sub { shift->taxname || 'Tax' }, + sub { shift->tax. '% <FONT SIZE="-1">(edit)</FONT>' }, + $exempt_sub, +; + +push @color, + sub { shift->taxname ? '000000' : '666666' }, + sub { shift->tax ? '000000' : '666666' }, + '000000', +; + +$align .= 'lrl'; + +my @cell_style = map $cell_style_sub, (1..scalar(@header)); + +push @links, '', $edit_link, ''; +push @link_onclicks, '', $edit_onclick, ''; + +</%init> diff --git a/httemplate/browse/elements/browse.html b/httemplate/browse/elements/browse.html new file mode 100644 index 000000000..513c2c4e9 --- /dev/null +++ b/httemplate/browse/elements/browse.html @@ -0,0 +1,6 @@ +<% include( '/search/elements/search.html', + 'disable_download' => 1, + 'disable_nonefound' => 1, + @_, + ) +%> diff --git a/httemplate/browse/inventory_class.html b/httemplate/browse/inventory_class.html new file mode 100644 index 000000000..8ce131ac2 --- /dev/null +++ b/httemplate/browse/inventory_class.html @@ -0,0 +1,93 @@ +<% include( 'elements/browse.html', + 'title' => 'Inventory Classes', + 'name' => 'inventory classes', + 'menubar' => [ 'Add a new inventory class' => + $p.'edit/inventory_class.html', + ], + 'query' => { 'table' => 'inventory_class', }, + 'count_query' => 'SELECT COUNT(*) FROM inventory_class', + 'header' => [ '#', 'Inventory class', 'Inventory' ], + 'fields' => [ 'classnum', + 'classname', + sub { + #my $inventory_class = shift; + my $i_c = shift; + + my $link = + $p. 'search/inventory_item.html?'. + 'classnum='. $i_c->classnum; + + my %actioncol = (); + foreach ( keys %inv_action_link ) { + my($label, $baseurl, $method) = + @{ $inv_action_link{$_} }; + my $url = $baseurl. $i_c->$method(); + $actioncol{$_} = + '<FONT SIZE="-1">'. + '('. + '<A HREF="'.$url.'">'. + $label. + '</A>'. + ')'. + '</FONT>'; + } + + my %num = map { + $_ => $i_c->$_(); + } keys %labels; + + [ map { + [ + { + 'data' => '<B>'. $num{$_}. '</B>', + 'align' => 'right', + }, + { + 'data' => $labels{$_}, + 'align' => 'left', + 'link' => ( $num{$_} + ? $link.$link{$_} + : '' + ), + }, + { 'data' => $actioncol{$_}, + 'align' => 'left', + }, + ] + } keys %labels + ]; + }, + ], + 'links' => [ $link, + $link, + '', + ], + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +tie my %labels, 'Tie::IxHash', + 'num_avail' => 'Available', # <FONT SIZE="-1"><A HREF="eventually">(upload batch)</A></FONT>', + 'num_used' => 'In use', #'Used', #'Allocated', + 'num_total' => 'Total', +; + +my %link = ( + 'num_avail' => ';avail=1', + 'num_used' => ';used=1', + 'num_total' => '', +); + +my %inv_action_link = ( + 'num_avail' => [ 'upload batch', + $p.'misc/inventory_item-import.html?classnum=', + 'classnum' + ], +); + +my $link = [ "${p}edit/inventory_class.html?", 'classnum' ]; + +</%init> diff --git a/httemplate/browse/invoice_template.html b/httemplate/browse/invoice_template.html new file mode 100644 index 000000000..0bbfb2452 --- /dev/null +++ b/httemplate/browse/invoice_template.html @@ -0,0 +1,124 @@ +<% include("/elements/header.html", 'Invoice templates') %> + +<% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; + +<TR> + <TH CLASS="grid" BGCOLOR="#cccccc">Template</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">HTML</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Print/PDF (typeset)</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Plaintext</TH> +</TR> + +% foreach my $templatename ( '', @templatenames ) { +% my $tname = length($templatename) ? "_$templatename" : ''; +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% my $display = length($templatename) ? $templatename : '<i>(Default)</i>'; + + <TR> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $display %> + </TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + +% my( $logo_label, $logo_link_label)= length( $templatename ) +% ? labels("logo_$templatename.png") +% : ( '', 'edit' ); + <% $logo_label %> Logo + (<A HREF="<% $p %>edit/invoice_logo.html?type=png;name=<% $templatename %>"><% $logo_link_label %></A>) + <BR> + +% foreach my $suffix (qw( returnaddress notes footer), '' ) { +% my $file = "invoice_html$suffix$tname"; +% my($label, $link_label) = length($templatename) +% ? labels($file) +% : ( '', 'edit' ); + + <% $label %> <% $suffix2name{$suffix} %> + (<A HREF="<% $p %>edit/invoice_template.html?type=html;suffix=<% $suffix %>;name=<% $templatename %>"><% $link_label %></A>) + <BR> + +% } + + </TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + +% my( $logo_label, $logo_link_label)= length( $templatename ) +% ? labels("logo_$templatename.eps") +% : ( '', 'edit' ); + <% $logo_label %> Logo + (<A HREF="<% $p %>edit/invoice_logo.html?type=eps;name=<% $templatename %>"><% $logo_link_label %></A>) + <BR> + +% foreach my $suffix (qw( returnaddress notes footer smallfooter), '' ) { +% my $file = "invoice_latex$suffix$tname"; +% my($label, $link_label) = length($templatename) +% ? labels($file) +% : ( '', 'edit' ); + + <% $label %> <% $suffix2name{$suffix} %> + (<A HREF="<% $p %>edit/invoice_template.html?type=latex;suffix=<% $suffix %>;name=<% $templatename %>"><% $link_label %></A>) + <BR> + +% } + + </TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + +% my( $txt_label, $txtlink_label)= +% length( $templatename ) +% ? labels("invoice_template_$templatename.png") +% : ( 'Main template', 'edit' ); + <% $txt_label %> + (<A HREF="<% $p %>edit/invoice_template.html?type=text;name=<% $templatename %>"><% $txtlink_label %></A>) + + </TD> + + </TR> + +% } + +<% include("/elements/footer.html") %> + +<%once> + +my %suffix2name = ( + 'returnaddress' => 'Return address', + 'notes' => 'Notes', + 'footer' => 'Footer', + 'smallfooter' => 'Small footer', + '' => 'Main template', +); + +my $conf = new FS::Conf; + +sub labels { + my $filename = shift; + if ( $conf->exists($filename) ) { + ( 'Custom', 'edit' ); + } else { + ( 'Standard', 'customize' ); + } +} + +</%once> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my @templatenames = $conf->invoice_templatenames; + +</%init> diff --git a/httemplate/browse/msgcat.cgi b/httemplate/browse/msgcat.cgi new file mode 100755 index 000000000..2c916dc9f --- /dev/null +++ b/httemplate/browse/msgcat.cgi @@ -0,0 +1,44 @@ +<% include('/elements/header.html', "View Message catalog", menubar( + 'Edit message catalog' => $p. "edit/msgcat.cgi", +)) %> +<% $widget->html %> +<% include('/elements/footer.html') %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $widget = new HTML::Widgets::SelectLayers( + 'selected_layer' => 'en_US', + 'options' => { 'en_US'=>'en_US' }, + 'layer_callback' => sub { + my $layer = shift; + my $html = "<BR>Messages for locale $layer<BR>". table(). + "<TR><TH COLSPAN=2>Code</TH>". + "<TH>Message</TH>"; + $html .= "<TH>en_US Message</TH>" unless $layer eq 'en_US'; + $html .= '</TR>'; + + #foreach my $msgcat ( sort { $a->msgcode cmp $b->msgcode } + # qsearch('msgcat', { 'locale' => $layer } ) ) { + foreach my $msgcat ( qsearch('msgcat', { 'locale' => $layer } ) ) { + $html .= '<TR><TD>'. $msgcat->msgnum. '</TD>'. + '<TD>'. $msgcat->msgcode. '</TD>'. + '<TD>'. $msgcat->msg. '</TD>'; + unless ( $layer eq 'en_US' ) { + my $en_msgcat = qsearchs('msgcat', { + 'locale' => 'en_US', + 'msgcode' => $msgcat->msgcode, + } ); + $html .= '<TD>'. $en_msgcat->msg. '</TD>'; + } + $html .= '</TR>'; + } + + $html .= '</TABLE>'; + $html; + }, + +); + +</%init> diff --git a/httemplate/browse/nas.cgi b/httemplate/browse/nas.cgi new file mode 100755 index 000000000..b5e0ef8b7 --- /dev/null +++ b/httemplate/browse/nas.cgi @@ -0,0 +1,82 @@ +%print header('NAS ports'); +% +%my $now = time; +% +%foreach my $nas ( sort { $a->nasnum <=> $b->nasnum } qsearch( 'nas', {} ) ) { +% print $nas->nasnum. ": ". $nas->nas. " ". +% $nas->nasfqdn. " (". $nas->nasip. ") ". +% "as of ". time2str("%c",$nas->last). +% " (". &pretty_interval($now - $nas->last). " ago)<br>". +% &table(). "<TR><TH>Nas<BR>Port #</TH><TH>Global<BR>Port #</BR></TH>". +% "<TH>IP address</TH><TH>User</TH><TH>Since</TH><TH>Duration</TH><TR>", +% ; +% foreach my $port ( sort { +% $a->nasport <=> $b->nasport || $a->portnum <=> $b->portnum +% } qsearch( 'port', { 'nasnum' => $nas->nasnum } ) ) { +% my $session = $port->session; +% my($user, $since, $pretty_since, $duration); +% if ( ! $session ) { +% $user = "(empty)"; +% $since = 0; +% $pretty_since = "(never)"; +% $duration = ''; +% } elsif ( $session->logout ) { +% $user = "(empty)"; +% $since = $session->logout; +% } else { +% my $svc_acct = $session->svc_acct; +% $user = "<A HREF=\"$p/view/svc_acct.cgi?". $svc_acct->svcnum. "\">". +% $svc_acct->username. "</A>"; +% $since = $session->login; +% } +% $pretty_since = time2str("%c", $since) if $since; +% $duration = pretty_interval( $now - $since ). " ago" +% unless defined($duration); +% print "<TR><TD>". $port->nasport. "</TD><TD>". $port->portnum. "</TD><TD>". +% $port->ip. "</TD><TD>$user</TD><TD>$pretty_since". +% "</TD><TD>$duration</TD></TR>" +% ; +% } +% print "</TABLE><BR>"; +%} +% +%#Time::Duration?? +%sub pretty_interval { +% my $interval = shift; +% my %howlong = ( +% '604800' => 'week', +% '86400' => 'day', +% '3600' => 'hour', +% '60' => 'minute', +% '1' => 'second', +% ); +% +% my $pretty = ""; +% foreach my $key ( sort { $b <=> $a } keys %howlong ) { +% my $value = int( $interval / $key ); +% if ( $value ) { +% if ( $value == 1 ) { +% $pretty .= +% ( $howlong{$key} eq 'hour' ? 'an ' : 'a ' ). $howlong{$key}. " " +% } else { +% $pretty .= $value. ' '. $howlong{$key}. 's '; +% } +% } +% $interval -= $value * $key; +% } +% $pretty =~ /^\s*(\S.*\S)\s*$/; +% $1; +%} +% +%#print &table(), <<END; +%#<TR> +%# <TH>#</TH> +%# <TH>NAS</ +% + +<%init> + +#this hasn't been used in ages, and isn't linked from anywhere... +die 'NAS browse not currently active'; + +</%init> diff --git a/httemplate/browse/part_bill_event.cgi b/httemplate/browse/part_bill_event.cgi new file mode 100755 index 000000000..11bc14e5c --- /dev/null +++ b/httemplate/browse/part_bill_event.cgi @@ -0,0 +1,122 @@ +<% include('/elements/header.html', 'Invoice Event Listing') %> + + <FONT SIZE="+1">Invoice events are the deprecated, old-style actions taken on open invoices. Any events still listed here should be migrated to new-style events.</FONT><BR><BR> + +<A HREF="<% $p %>edit/part_bill_event.cgi"><I>Add a new invoice event</I></A> +<BR><BR> + +<% $total %> events +<% $cgi->param('showdisabled') + ? do { $cgi->param('showdisabled', 0); + '( <a href="'. $cgi->self_url. '">hide disabled events</a> )'; } + : do { $cgi->param('showdisabled', 1); + '( <a href="'. $cgi->self_url. '">show disabled events</a> )'; } +%> +<BR><BR> +% tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname; +% tie my %freq, 'Tie::IxHash', '1d' => 'daily', '1m' => 'monthly'; +% foreach my $payby ( keys %payby ) { +% my $oldfreq = ''; +% +% my @payby_part_bill_event = +% grep { $payby eq $_->payby } +% sort { ( $a->freq || '1d') cmp ( $b->freq || '1d' ) # for now +% || $a->seconds <=> $b->seconds +% || $a->weight <=> $b->weight +% || $a->eventpart <=> $b->eventpart +% } +% @part_bill_event; +% +% +% if ( @payby_part_bill_event ) { + + + <% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor; +% +% +% foreach my $part_bill_event ( @payby_part_bill_event ) { +% my $url = "${p}edit/part_bill_event.cgi?". $part_bill_event->eventpart; +% my $delay = duration_exact($part_bill_event->seconds); +% ( my $plandata = $part_bill_event->plandata ) =~ s/\n/<BR>/go; +% my $freq = $part_bill_event->freq || '1d'; +% my $reason = $part_bill_event->reasontext ; +% +% if ( $oldfreq ne $freq ) { + + + <TR> + <TH CLASS="grid" BGCOLOR="#999999" COLSPAN=<% $cgi->param('showdisabled') ? 7 : 8 %>><% ucfirst($freq{$freq}) %> event tests for <FONT SIZE="+1"><I><% $payby{$payby} %> customers</I></FONT></TH> + </TR> + + <TR> + <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% $cgi->param('showdisabled') ? 2 : 3 %>>Event</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">After</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Action</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Reason</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Options</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Code</TH> + </TR> +% +% $oldfreq = $freq; +% $bgcolor = ''; +% +% } +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% + + + <TR> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<% $url %>"> + <% $part_bill_event->eventpart %></A></TD> +% unless ( $cgi->param('showdisabled') ) { + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $part_bill_event->disabled ? 'DISABLED' : '' %></TD> +% } + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<% $url %>"> + <% $part_bill_event->event %></A></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $delay %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $part_bill_event->plan %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $reason %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $plandata %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><FONT SIZE="-1"> + <% $part_bill_event->eventcode %></FONT></TD> + </TR> +% } + + </TABLE> + <BR><BR> +% } +% } + +<% include('/elements/footer.html') %> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my %search; +if ( $cgi->param('showdisabled') ) { +%search = (); +} else { +%search = ( 'disabled' => '' ); +} + +my @part_bill_event = qsearch('part_bill_event', \%search ); +my $total = scalar(@part_bill_event); + +</%init> diff --git a/httemplate/browse/part_event.html b/httemplate/browse/part_event.html new file mode 100644 index 000000000..4a0582633 --- /dev/null +++ b/httemplate/browse/part_event.html @@ -0,0 +1,157 @@ +<% include( 'elements/browse.html', + 'title' => 'Billing Event Definitions', + 'html_init' => $html_init, + 'name' => 'billing event definitions', + 'disableable' => 1, + 'disabled_statuspos' => 2, + 'agent_virt' => 1, + 'agent_null_right' => 'Edit global billing events', + 'agent_pos' => 3, + 'query' => { 'select' => 'part_event.*', + 'table' => 'part_event', + 'addl_from' => $join_conditions, + 'hashref' => {}, + 'order_by' => $order_conditions, + }, + 'count_query' => $count_query, + 'header' => [ '#', + 'Event', + 'Type', + 'Check freq.', + 'Conditions', + 'Action', + ], + 'fields' => [ 'eventpart', + 'event', + $eventtable_sub, + $check_freq_sub, + $conditions_sub, + $action_sub, + ], + 'links' => [ $link, + $link, + '', + '', + '', + '', + ], + 'align' => 'rllccc', + ) +%> +<%once> + +my $eventtable_labels = FS::part_event->eventtable_labels; +my $eventtable_sub = sub { $eventtable_labels->{ shift->eventtable }; }; + +my $check_freq_labels = FS::part_event->check_freq_labels; +my $check_freq_sub = sub { $check_freq_labels->{ shift->check_freq }; }; + +my $conditions_sub = sub { + my $part_event = shift; + my $addl = 0; + + [ + map { + my $part_event_condition = $_; + my %options = $part_event_condition->options; + + [ + { + 'data' => $part_event_condition->description, + 'width' => '100%', + 'align' => 'center', + 'colspan' => 2, + 'style' => ( $addl++ ? 'border-top: 1px solid gray' : '' ), + }, + ], + + map { + + my $data = $options{$_}; + if ( ref($data) ) { + $data = join('<BR>', keys %$data); #XXX display hash values too? + } + + [ + { + 'data' => $part_event_condition->option_label($_). ':', + 'align' => 'right', + 'valign' => 'top', + 'size' => '-1', + }, + { + 'data' => $data, + 'align' => 'left', + 'size' => '-1', + }, + ]; + + } keys %options + + } + $part_event->part_event_condition + + ]; + +}; + +my $action_sub = sub { + my $part_event = shift; + + my %options = $part_event->options; + + [ + + [ + { + 'data' => $part_event->description, + 'width' => '100%', + 'align' => 'center', + 'colspan' => 2, + }, + ], + + map { + [ + { + 'data' => $part_event->option_label($_). ':', + 'align' => 'right', + 'size' => '-1', + }, + { + 'data' => $options{$_}, + 'align' => 'left', + 'size' => '-1', + }, + ]; + } + + keys %options + ]; + +}; + +my $link = [ $p.'edit/part_event.html?', 'eventpart' ]; + +</%once> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Edit billing events') + || $FS::CurrentUser::CurrentUser->access_right('Edit global billing events'); + +my $html_init = + #XXX better description + 'Events are billing, collection or other actions triggered when certain '. + 'customer, invoice, package or other conditions are met.<BR><BR>'. + qq!<A HREF="${p}edit/part_event.html"><I>Add a new event</I></A><BR><BR>!; + +my $count_query = 'SELECT COUNT(*) FROM part_event WHERE '. + $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => 'Edit global billing events', + ); + +my $join_conditions = FS::part_event_condition->join_conditions_sql; +my $order_conditions = FS::part_event_condition->order_conditions_sql; + +</%init> diff --git a/httemplate/browse/part_export.cgi b/httemplate/browse/part_export.cgi new file mode 100755 index 000000000..1cd201360 --- /dev/null +++ b/httemplate/browse/part_export.cgi @@ -0,0 +1,65 @@ +<% include("/elements/header.html", "Export Listing") %> + +Provisioning services to external machines, databases and APIs.<BR><BR> + +<A HREF="<% $p %>edit/part_export.cgi"><I>Add a new export</I></A><BR><BR> + +<SCRIPT> +function part_export_areyousure(href) { + if (confirm("Are you sure you want to delete this export?") == true) + window.location.href = href; +} +</SCRIPT> + +<% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; + + <TR> + <TH COLSPAN=2 CLASS="grid" BGCOLOR="#cccccc">Export</TH> + <TH CLASS="grid" BGCOLOR="#cccccc">Options</TH> + </TR> + +% foreach my $part_export ( sort { +% $a->getfield('exportnum') <=> $b->getfield('exportnum') +% } qsearch('part_export',{}) +% ) { +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } + + <TR> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>"><% $part_export->exportnum %></A></TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $part_export->exporttype %> to <% $part_export->machine %> (<A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>">edit</A> | <A HREF="javascript:part_export_areyousure('<% $p %>misc/delete-part_export.cgi?<% $part_export->exportnum %>')">delete</A>)</TD> + + <TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> + <% itable() %> +% my %opt = $part_export->options; +% foreach my $opt ( keys %opt ) { + + <TR> + <TD ALIGN="right" VALIGN="top" WIDTH="33%"><% $opt %>: </TD> + <TD ALIGN="left" WIDTH="67%"><% encode_entities($opt{$opt}) %></TD> + </TR> +% } + + </TABLE> + </TD> + + </TR> + +% } + +</TABLE> + +<% include('/elements/footer.html') %> + +<%init> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +</%init> diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi new file mode 100755 index 000000000..78cb77d26 --- /dev/null +++ b/httemplate/browse/part_pkg.cgi @@ -0,0 +1,231 @@ +<% include( 'elements/browse.html', + 'title' => 'Package Definitions', + 'html_init' => $html_init, + 'name' => 'package definitions', + 'disableable' => 1, + 'disabled_statuspos' => 3, + 'agent_virt' => 1, + 'agent_null_right' => 'Edit global package definitions', + 'agent_pos' => 4, + 'query' => { 'select' => $select, + 'table' => 'part_pkg', + 'hashref' => {}, + 'order_by' => "ORDER BY $orderby", + }, + 'count_query' => $count_query, + 'header' => \@header, + 'fields' => \@fields, + 'links' => \@links, + 'align' => $align, + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Edit package definitions') + || $FS::CurrentUser::CurrentUser->access_right('Edit global package definitions'); + +my $select = '*'; +my $orderby = 'pkgpart'; +if ( $cgi->param('active') ) { + + $orderby = 'num_active DESC'; +} + $select = " + + *, + + ( SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.pkgpart = part_pkg.pkgpart + AND ( cancel IS NULL OR cancel = 0 ) + AND ( susp IS NULL OR susp = 0 ) + ) AS num_active, + + ( SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.pkgpart = part_pkg.pkgpart + AND ( cancel IS NULL OR cancel = 0 ) + AND susp IS NOT NULL AND susp != 0 + ) AS num_suspended, + + ( SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.pkgpart = part_pkg.pkgpart + AND cancel IS NOT NULL AND cancel != 0 + ) AS num_cancelled + + "; + +#} + +my $conf = new FS::Conf; +my $taxclasses = $conf->exists('enable_taxclasses'); + +my $html_init; +#unless ( $cgi->param('active') ) { + $html_init = qq! + One or more service definitions are grouped together into a package + definition and given pricing information. Customers purchase packages + rather than purchase services directly.<BR><BR> + <A HREF="${p}edit/part_pkg.cgi"><I>Add a new package definition</I></A> + <BR><BR> + !; +#} + +# ------ + +my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ]; + +my @header = ( '#', 'Package', 'Comment' ); +my @fields = ( 'pkgpart', 'pkg', 'comment' ); +my $align = 'rll'; +my @links = ( $link, $link, '' ); + +unless ( 0 ) { #already showing only one class or something? + push @header, 'Class'; + push @fields, sub { shift->classname || '(none)'; }; + $align .= 'l'; +} + +#if ( $cgi->param('active') ) { + push @header, 'Customer<BR>packages'; + my %col = ( + 'active' => '00CC00', + 'suspended' => 'FF9900', + 'cancelled' => 'FF0000', + #'one-time charge' => '000000', + 'charge' => '000000', + ); + my $cust_pkg_link = $p. 'search/cust_pkg.cgi?pkgpart='; + push @fields, sub { my $part_pkg = shift; + [ + map { + my $magic = $_; + my $label = $_; + if ( $magic eq 'active' && $part_pkg->freq == 0 ) { + $magic = 'inactive'; + #$label = 'one-time charge', + $label = 'charge', + } + + [ + { + 'data' => '<B><FONT COLOR="#'. $col{$label}. '">'. + $part_pkg->get("num_$_"). + '</FONT></B>', + 'align' => 'right', + }, + { + 'data' => $label. + ( $part_pkg->get("num_$_") != 1 + && $label =~ /charge$/ + ? 's' + : '' + ), + 'align' => 'left', + 'link' => ( $part_pkg->get("num_$_") + ? $cust_pkg_link. + $part_pkg->pkgpart. + ";magic=$magic" + : '' + ), + }, + ], + } (qw( active suspended cancelled )) + ]; }; + $align .= 'r'; +#} + +push @header, 'Frequency'; +push @fields, sub { shift->freq_pretty; }; +$align .= 'l'; + +if ( $taxclasses ) { + push @header, 'Taxclass'; + push @fields, sub { shift->taxclass() || ' '; }; + $align .= 'l'; +} + +push @header, 'Plan', + 'Data', + 'Services'; + #'Service', 'Quan', 'Primary'; + +push @fields, sub { shift->plan || '(legacy)' }, + + sub { + my $part_pkg = shift; + if ( $part_pkg->plan ) { + + [ map { + /^(\w+)=(.*)$/; #or something; + [ + { 'data' => $1, + 'align' => 'right', + }, + { 'data' => $part_pkg->format($1,$2), + 'align' => 'left', + }, + ]; + } + split(/\n/, $part_pkg->plandata) + ]; + + } else { + + [ map { [ + { 'data' => uc($_), + 'align' => 'right', + }, + { + 'data' => $part_pkg->$_(), + 'align' => 'left', + }, + ]; + } + (qw(setup recur)) + ]; + + } + + }, + + sub { + my $part_pkg = shift; + + [ map { + my $pkg_svc = $_; + my $part_svc = $pkg_svc->part_svc; + my $svc = $part_svc->svc; + if ( $pkg_svc->primary_svc =~ /^Y/i ) { + $svc = "<B>$svc (PRIMARY)</B>"; + } + $svc =~ s/ +/ /g; + + [ + { + 'data' => '<B>'. $pkg_svc->quantity. '</B>', + 'align' => 'right' + }, + { + 'data' => $svc, + 'align' => 'left', + 'link' => $p. 'edit/part_svc.cgi?'. + $part_svc->svcpart, + }, + ]; + } + sort { $b->primary_svc =~ /^Y/i + <=> $a->primary_svc =~ /^Y/i + } + $part_pkg->pkg_svc + + ]; + + }; + +$align .= 'lrl'; #rr'; + +# -------- + +my $count_query = 'SELECT COUNT(*) FROM part_pkg WHERE '. + $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => 'Edit global package definitions', + ); + +</%init> diff --git a/httemplate/browse/part_referral.html b/httemplate/browse/part_referral.html new file mode 100755 index 000000000..9cc32c459 --- /dev/null +++ b/httemplate/browse/part_referral.html @@ -0,0 +1,181 @@ +<% include("/elements/header.html","Advertising source Listing" ) %> + +Where a customer heard about your service. Tracked for informational purposes. +<BR><BR> + +<A HREF="<% $p %>edit/part_referral.html"><I>Add a new advertising source</I></A> +<BR><BR> + +<% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; + +<TR> + <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2 ROWSPAN=2>Advertising source</TH> +% if ( $show_agentnums ) { + + <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Agent</TH> +% } + + <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% scalar(keys %after) %>>Customers and Packages</TH> +</TR> +% for my $period ( keys %after ) { + + <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1><% $period %></FONT></TH> +% } + +</TR> + +%foreach my $part_referral ( FS::part_referral->all_part_referral(1) ) { +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% $a = 0; + + <TR> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> +% if ( $part_referral->agentnum || $curuser->access_right('Edit global advertising sources') ) { +% $a++; +% + + <A HREF="<% $p %>edit/part_referral.html?<% $part_referral->refnum %>"> +% } + + <% $part_referral->refnum %><% $a ? '</A>' : '' %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> +% if ( $a ) { + + <A HREF="<% $p %>edit/part_referral.html?<% $part_referral->refnum %>"> +% } + + <% $part_referral->referral %><% $a ? '</A>' : '' %></TD> +% if ( $show_agentnums ) { + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $part_referral->agentnum ? $part_referral->agent->agent : '(global)' %></TD> +% } +% for my $period ( keys %after ) { +% my @param = ( $part_referral->refnum, +% $today-$after{$period}, +% $today+$before{$period}, +% ); +% $cust_sth->execute(@param) or die $cust_sth->errstr; +% my $num_cust = $cust_sth->fetchrow_arrayref->[0]; +% $pkg_sth->execute(@param) or die $pkg_sth->errstr; +% my $num_pkg = $pkg_sth->fetchrow_arrayref->[0]; + + <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0> + <TR> + <TD ALIGN="right"><B><% $num_cust %></B></TD> + <TD ALIGN="left">customers</TD> + </TR> + <TR> + <TD ALIGN="right"><B><% $num_pkg %></B></TD> + <TD ALIGN="left">packages</TD> + </TR> + </TABLE> + </TD> +% } + + </TR> +% } +% +% $cust_statement =~ s/AND refnum = \?//; +% $cust_sth = dbh->prepare($cust_statement) +% or die dbh->errstr; +% $pkg_statement =~ s/AND h_pkg_referral\.refnum = \?//; +% $pkg_sth = dbh->prepare($pkg_statement) +% or die dbh->errstr; + + <TR> + <TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=3><B>Total</B></TD> +% for my $period ( keys %after ) { +% my @param = ( $today-$after{$period}, +% $today+$before{$period}, +% ); +% $cust_sth->execute( @param ) or die $cust_sth->errstr; +% my $num_cust = $cust_sth->fetchrow_arrayref->[0]; +% $pkg_sth->execute(@param) or die $pkg_sth->errstr; +% my $num_pkg = $pkg_sth->fetchrow_arrayref->[0]; + + <TD CLASS="inv" BGCOLOR="#dddddd" ALIGN="right"> + <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0> + <TR> + <TD ALIGN="right"><B><% $num_cust %></B></TD> + <TD ALIGN="left">customers</TD> + </TR> + <TR> + <TD ALIGN="right"><B><% $num_pkg %></B></TD> + <TD ALIGN="left">packages</TD> + </TR> + </TABLE> + </TD> + +% } + + </TR> + </TABLE> + </BODY> +</HTML> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Edit advertising sources') + || $FS::CurrentUser::CurrentUser->access_right('Edit global advertising sources'); + +my $today = timelocal(0, 0, 0, (localtime(time))[3..5] ); + +tie my %after, 'Tie::IxHash', + 'Today' => 0, + 'Yesterday' => 86400, # 60sec * 60min * 24hrs + 'Past week' => 518400, # 60sec * 60min * 24hrs * 6days + 'Past 30 days' => 2505600, # 60sec * 60min * 24hrs * 29days + 'Past 60 days' => 5097600, # 60sec * 60min * 24hrs * 59days + 'Past 90 days' => 7689600, # 60sec * 60min * 24hrs * 89days + 'Past 6 months' => 15724800, # 60sec * 60min * 24hrs * 182days + 'Past year' => 31486000, # 60sec * 60min * 24hrs * 364days + 'Total' => $today, +; +my %before = ( + 'Today' => 86400, # 60sec * 60min * 24hrs + 'Yesterday' => 0, + 'Past week' => 86400, # 60sec * 60min * 24hrs + 'Past 30 days' => 86400, # 60sec * 60min * 24hrs + 'Past 60 days' => 86400, # 60sec * 60min * 24hrs + 'Past 90 days' => 86400, # 60sec * 60min * 24hrs + 'Past 6 months' => 86400, # 60sec * 60min * 24hrs + 'Past year' => 86400, # 60sec * 60min * 24hrs + 'Total' => 86400, # 60sec * 60min * 24hrs +); + +my $curuser = $FS::CurrentUser::CurrentUser; + +my $show_agentnums = ( scalar($curuser->agentnums) > 1 ); + +my $cust_statement = "SELECT COUNT(*) FROM h_cust_main + WHERE history_action = 'insert' + AND refnum = ? + AND history_date >= ? + AND history_date < ? + AND ". $curuser->agentnums_sql; +my $cust_sth = dbh->prepare($cust_statement) + or die dbh->errstr; + +my $pkg_statement = "SELECT COUNT(*) FROM h_pkg_referral + LEFT JOIN cust_pkg USING ( pkgnum ) + LEFT JOIN cust_main USING ( custnum ) + WHERE history_action = 'insert' + AND h_pkg_referral.refnum = ? + AND history_date >= ? + AND history_date < ? + AND ". $curuser->agentnums_sql; +my $pkg_sth = dbh->prepare($pkg_statement) + or die dbh->errstr; + +</%init> diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi new file mode 100755 index 000000000..f1b283638 --- /dev/null +++ b/httemplate/browse/part_svc.cgi @@ -0,0 +1,215 @@ +<% include('/elements/header.html', 'Service Definition Listing') %> + +<SCRIPT> +function part_export_areyousure(href) { + if (confirm("Are you sure you want to delete this export?") == true) + window.location.href = href; +} +</SCRIPT> + + Service definitions are the templates for items you offer to your customers.<BR><BR> + +<FORM METHOD="POST" ACTION="<% $p %>edit/part_svc.cgi"> +<A HREF="<% $p %>edit/part_svc.cgi"><I>Add a new service definition</I></A> +% if ( @part_svc ) { + or <SELECT NAME="clone"><OPTION></OPTION> +% foreach my $part_svc ( @part_svc ) { + + <OPTION VALUE="<% $part_svc->svcpart %>"><% $part_svc->svc %></OPTION> +% } + +</SELECT><INPUT TYPE="submit" VALUE="Clone existing service"> +% } + +</FORM><BR> + +<% $total %> service definitions +<% $cgi->param('showdisabled') + ? do { $cgi->param('showdisabled', 0); + '( <a href="'. $cgi->self_url. '">hide disabled services</a> )'; } + : do { $cgi->param('showdisabled', 1); + '( <a href="'. $cgi->self_url. '">show disabled services</a> )'; } +%> +% $cgi->param('showdisabled', ( 1 ^ $cgi->param('showdisabled') ) ); + +<% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; + + <TR> + + <TH CLASS="grid" BGCOLOR="#cccccc"><A HREF="<% do { $cgi->param('orderby', 'svcpart'); $cgi->self_url } %>">#</A></TH> + +% if ( $cgi->param('showdisabled') ) { + <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH> +% } + + <TH CLASS="grid" BGCOLOR="#cccccc"><A HREF="<% do { $cgi->param('orderby', 'svc'); $cgi->self_url; } %>">Service</A></TH> + + <TH CLASS="grid" BGCOLOR="#cccccc">Table</TH> + + <TH CLASS="grid" BGCOLOR="#cccccc"><A HREF="<% do { $cgi->param('orderby', 'active'); $cgi->self_url; } %>"><FONT SIZE=-1>Customer<BR>Services</FONT></A></TH> + + <TH CLASS="grid" BGCOLOR="#cccccc">Export</TH> + + <TH CLASS="grid" BGCOLOR="#cccccc">Field</TH> + + <TH COLSPAN=2 CLASS="grid" BGCOLOR="#cccccc">Modifier</TH> + + </TR> + +% foreach my $part_svc ( @part_svc ) { +% my $svcdb = $part_svc->svcdb; +% my $svc_x = "FS::$svcdb"->new( { svcpart => $part_svc->svcpart } ); +% my @dfields = $svc_x->fields; +% push @dfields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge +% my @fields = +% grep { $svc_x->pvf($_) +% or $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag } +% @dfields ; +% my $rowspan = scalar(@fields) || 1; +% my $url = "${p}edit/part_svc.cgi?". $part_svc->svcpart; +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } + + + <TR> + + <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <A HREF="<% $url %>"><% $part_svc->svcpart %></A> + </TD> + +% if ( $cgi->param('showdisabled') ) { + <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $part_svc->disabled + ? '<FONT COLOR="#FF0000"><B>Disabled</B></FONT>' + : '<FONT COLOR="#00CC00"><B>Enabled</B></FONT>' + %> + </TD> +% } + + <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<% $url %>"> + <% $part_svc->svc %></A></TD> + + <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $svcdb %></TD> + + <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <FONT COLOR="#00CC00"><B><% $num_active_cust_svc{$part_svc->svcpart} %></B></FONT> <% $num_active_cust_svc{$part_svc->svcpart} ? svc_url( 'ahref' => 1, 'm' => $m, 'action' => 'search', 'part_svc' => $part_svc, 'query' => "svcpart=". $part_svc->svcpart ) : '<A NAME="zero">' %>active</A> + +% if ( $num_active_cust_svc{$part_svc->svcpart} ) { + <BR><FONT SIZE="-1">[ <A HREF="<%$p%>edit/bulk-cust_svc.html?svcpart=<% $part_svc->svcpart %>">change</A> ]</FONT> +% } + + </TD> + + <TD ROWSPAN=<% $rowspan %> CLASS="inv" BGCOLOR="<% $bgcolor %>"> + <TABLE CLASS="inv"> +% +%# my @part_export = +%map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export_svc', { svcpart => $part_svc->svcpart } ) ; +% foreach my $part_export ( +% map { qsearchs('part_export', { exportnum => $_->exportnum } ) } +% qsearch('export_svc', { svcpart => $part_svc->svcpart } ) +% ) { +% + + <TR> + <TD><A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>"><% $part_export->exportnum %>: <% $part_export->exporttype %> to <% $part_export->machine %></A></TD> + </TR> +% } + + </TABLE> + </TD> + +% unless ( @fields ) { +% for ( 1..3 ) { + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"</TD> +% } +% } +% +% my($n1)=''; +% foreach my $field ( @fields ) { +% my $formatter = +% FS::part_svc->svc_table_fields($svcdb)->{$field}->{format} +% || sub { shift }; +% my $flag = $part_svc->part_svc_column($field)->columnflag; +% + + <% $n1 %> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $field %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $flag{$flag} %></TD> + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> +% my $value = &$formatter($part_svc->part_svc_column($field)->columnvalue); +% if ( $flag =~ /^[MA]$/ ) { +% $inventory_class{$value} +% ||= qsearchs('inventory_class', { 'classnum' => $value } ); +% + + <% $inventory_class{$value} + ? $inventory_class{$value}->classname + : "WARNING: inventory_class.classnum $value not found" %> +% } else { + + <% $value %> +% } + + </TD> +% $n1="</TR><TR>"; +% } +% + + </TR> +% } + +</TABLE> +</BODY> +</HTML> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +#code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm +my %flag = ( + '' => '', + 'D' => 'Default', + 'F' => 'Fixed (unchangeable)', + 'S' => 'Selectable choice', + #'M' => 'Manual selection from inventory', + 'M' => 'Manual selected from inventory', + #'A' => 'Automatically fill in from inventory', + 'A' => 'Automatically filled in from inventory', + 'X' => 'Excluded', +); + +my %search; +if ( $cgi->param('showdisabled') ) { + %search = (); +} else { + %search = ( 'disabled' => '' ); +} + +my @part_svc = + sort { $a->getfield('svcpart') <=> $b->getfield('svcpart') } + qsearch('part_svc', \%search ); +my $total = scalar(@part_svc); + +my %num_active_cust_svc = map { $_->svcpart => $_->num_cust_svc } @part_svc; + +if ( $cgi->param('orderby') eq 'active' ) { + @part_svc = sort { $num_active_cust_svc{$b->svcpart} <=> + $num_active_cust_svc{$a->svcpart} } @part_svc; +} elsif ( $cgi->param('orderby') eq 'svc' ) { + @part_svc = sort { lc($a->svc) cmp lc($b->svc) } @part_svc; +} + +my %inventory_class = (); + +</%init> diff --git a/httemplate/browse/part_virtual_field.cgi b/httemplate/browse/part_virtual_field.cgi new file mode 100644 index 000000000..b18440036 --- /dev/null +++ b/httemplate/browse/part_virtual_field.cgi @@ -0,0 +1,42 @@ +<% include('/elements/header.html', 'Virtual field definitions') %> + +<% include('/elements/error.html') %> + +<A HREF="<%$p2%>edit/part_virtual_field.cgi"><I>Add a new field</I></A><BR><BR> +% foreach $dbtable (sort { $a cmp $b } keys (%pvfs)) { + +<H3><%$dbtable%></H3> + +<%table()%> +<TH><TD>Field name</TD><TD>Description</TD></TH> +% foreach my $pvf (sort {$a->name cmp $b->name} @{ $pvfs{$dbtable} }) { + + <TR> + <TD></TD> + <TD> + <A HREF="<%$p2%>edit/part_virtual_field.cgi?<%$pvf->vfieldpart%>"> + <%$pvf->name%></A></TD> + <TD><%$pvf->label%></TD> + </TR> +% } + +</TABLE> +% } + +<% include('/elements/footer.html') %> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my %pvfs; +my $block; +my $p2 = popurl(2); +my $dbtable; + +foreach (qsearch('part_virtual_field', {})) { + push @{ $pvfs{$_->dbtable} }, $_; +} + +</%init> diff --git a/httemplate/browse/payment_gateway.html b/httemplate/browse/payment_gateway.html new file mode 100644 index 000000000..848c58a82 --- /dev/null +++ b/httemplate/browse/payment_gateway.html @@ -0,0 +1,94 @@ +<% include( 'elements/browse.html', + 'title' => 'Payment gateways', + 'menubar' => [ 'Agents' => $p.'browse/agent.cgi', ], + 'html_init' => $html_init, + 'name' => 'payment gateways', + 'disableable' => 1, + 'disabled_statuspos' => 1, + 'query' => { 'table' => 'payment_gateway', + 'hashref' => {}, + }, + 'count_query' => $count_query, + 'header' => [ '#', + 'Gateway', + 'Username', + 'Password', + 'Action', + 'Options', + ], + 'fields' => [ 'gatewaynum', + $gateway_sub, + 'gateway_username', + sub { ' - '; }, + 'gateway_action', + $options_sub, + ], + ) +%> + +</TABLE> + +<% include('/elements/footer.html') %> +<%once> + +my $html_init = qq! + <A HREF="${p}edit/payment_gateway.html"><I>Add a new payment gateway</I></A> + <BR><BR> + + <SCRIPT> + function areyousure(href) { + if (confirm("Are you sure you want to disable this payment gateway?") == true) + window.location.href = href; + } + </SCRIPT> + +!; + +my $gateway_sub = sub { + my($payment_gateway) = @_; + + my $gatewaynum = $payment_gateway->gatewaynum; + + my $html = $payment_gateway->gateway_module. ' '. qq! + <FONT SIZE="-1"> + <A HREF="${p}edit/payment_gateway.html?$gatewaynum">(edit)</A> + !; + + unless ( $payment_gateway->disabled ) { + $html .= qq! + <A HREF="javascript:areyousure('${p}misc/disable-payment_gateway.cgi?$gatewaynum')">(disable)</A> + !; + } + + $html .= '</FONT>'; + + $html; + +}; + +my $options_sub = sub { + my($payment_gateway) = @_; + + #should return a structure instead of this manual formatting... + + my $html = '<TABLE CELLSPACING=0 CELLPADDING=0>'; + + my %options = $payment_gateway->options; + foreach my $option ( keys %options ) { + $html .= '<TR><TH>'. $option. ':</TH>'. + '<TD>'. $options{$option}. '</TD></TR>'; + } + $html .= '</TABLE>'; + + $html; +}; + +my $count_query = 'SELECT COUNT(*) FROM payment_gateway'; + +</%once> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/browse/pkg_class.html b/httemplate/browse/pkg_class.html new file mode 100644 index 000000000..4f02ca22d --- /dev/null +++ b/httemplate/browse/pkg_class.html @@ -0,0 +1,31 @@ +<% include( 'elements/browse.html', + 'title' => 'Package classes', + 'html_init' => $html_init, + 'name' => 'package classes', + 'disableable' => 1, + 'disabled_statuspos' => 2, + 'query' => { 'table' => 'pkg_class', + 'hashref' => {}, + 'extra_sql' => 'ORDER BY classnum', + }, + 'count_query' => $count_query, + 'header' => [ '#', 'Class', ], + 'fields' => [ 'classnum', 'classname' ], + 'links' => [ $link, $link ], + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $html_init = + 'Package classes define groups of packages, for reporting and '. + 'convenience purposes.<BR><BR>'. + qq!<A HREF="${p}edit/pkg_class.html"><I>Add a package class</I></A><BR><BR>!; + +my $count_query = 'SELECT COUNT(*) FROM pkg_class'; + +my $link = [ $p.'edit/pkg_class.html?', 'classnum' ]; + +</%init> diff --git a/httemplate/browse/rate.cgi b/httemplate/browse/rate.cgi new file mode 100644 index 000000000..b20c45c0c --- /dev/null +++ b/httemplate/browse/rate.cgi @@ -0,0 +1,67 @@ +<% include( 'elements/browse.html', + 'title' => 'Rate plans', + 'menubar' => [ 'Regions and Prefixes' => + $p.'browse/rate_region.html', + ], + 'html_init' => $html_init, + 'name' => 'rate plans', + 'query' => { 'table' => 'rate', + 'hashref' => {}, + 'extra_sql' => 'ORDER BY ratenum', + }, + 'count_query' => $count_query, + 'header' => [ '#', 'Rate plan', 'Rates' ], + 'fields' => [ 'ratenum', 'ratename', $rates_sub ], + 'links' => [ $link, $link, '' ], + ) +%> +<%once> + +my $sth = dbh->prepare("SELECT DISTINCT(countrycode) FROM rate_prefix") + or die dbh->errstr; +$sth->execute or die $sth->errstr; +my @all_countrycodes = map $_->[0], @{ $sth->fetchall_arrayref }; +my $all_countrycodes = join("\n", map qq(<OPTION VALUE="$_">$_), + @all_countrycodes + ); + +my $rates_sub = sub { + my $rate = shift; + my $ratenum = $rate->ratenum; + + qq( <FORM METHOD="GET" ACTION="${p}browse/rate_detail.html"> + <INPUT TYPE="hidden" NAME="ratenum" VALUE="$ratenum"> + <SELECT NAME="countrycode" onChange="this.form.submit();"> + <OPTION SELECTED>Select Country Code + <OPTION VALUE="">(all) + $all_countrycodes + </SELECT> + </FORM> + ); + + +}; + +</%once> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $html_init = + 'Rate plans for VoIP and call billing.<BR><BR>'. + qq!<A HREF="${p}edit/rate.cgi"><I>Add a rate plan</I></A>!. + '<BR><BR> + <SCRIPT> + function rate_areyousure(href) { + if (confirm("Are you sure you want to delete this rate plan?") == true) + window.location.href = href; + } + </SCRIPT> + '; + +my $count_query = 'SELECT COUNT(*) FROM rate'; + +my $link = [ $p.'edit/rate.cgi?', 'ratenum' ]; + +</%init> 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/browse/reason.html b/httemplate/browse/reason.html new file mode 100644 index 000000000..fe285be4a --- /dev/null +++ b/httemplate/browse/reason.html @@ -0,0 +1,53 @@ +<% include( 'elements/browse.html', + 'title' => ucfirst($classname) . ' Reasons', + 'menubar' => [ ucfirst($classname).' Reason Types' => + $p."browse/reason_type.html?class=$class" + ], + 'html_init' => $html_init, + 'name' => $classname . ' reasons', + 'disableable' => 1, + 'disabled_statuspos' => 3, + 'query' => { 'table' => 'reason', + 'hashref' => {}, + 'extra_sql' => $where_clause. + ' ORDER BY reason_type', + 'addl_from' => 'LEFT JOIN reason_type ON reason_type.typenum = reason.reason_type', + }, + 'count_query' => $count_query, + 'header' => [ '#', + ucfirst($classname) . ' Reason Type', + ucfirst($classname) . ' Reason', + ], + 'fields' => [ 'reasonnum', + sub { shift->reasontype->type }, + 'reason', + ], + 'links' => [ $link, + $link, + '', + ], + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +$cgi->param('class') =~ /^(\w)$/ or die "illegal class"; +my $class = $1; + +my $classname = $FS::reason_type::class_name{$class}; +my $classpurpose = $FS::reason_type::class_purpose{$class}; + +my $html_init = ucfirst($classname). " reasons $classpurpose.<BR><BR>". +qq!<A HREF="${p}edit/reason.html?class=$class">!. +"<I>Add a $classname reason</I></A><BR><BR>"; + +my $where_clause = " WHERE class='$class' "; + +my $count_query = 'SELECT COUNT(*) FROM reason LEFT JOIN reason_type on ' . + 'reason_type.typenum = reason.reason_type ' . $where_clause; + +my $link = [ $p."edit/reason.html?class=$class&reasonnum=", 'reasonnum' ]; + +</%init> diff --git a/httemplate/browse/reason_type.html b/httemplate/browse/reason_type.html new file mode 100644 index 000000000..6b444bad1 --- /dev/null +++ b/httemplate/browse/reason_type.html @@ -0,0 +1,68 @@ +<% include( 'elements/browse.html', + 'title' => ucfirst($classname) . " Reason Types", + 'menubar' => [ ucfirst($classname) . " reasons" => + $p.'browse/reason.html?class=' . $class, + ], + 'html_init' => $html_init, + 'name' => $classname . " reason types", + 'query' => { 'table' => 'reason_type', + 'hashref' => {}, + 'extra_sql' => $where_clause . + 'ORDER BY typenum', + }, + 'count_query' => $count_query, + 'header' => [ '#', + ucfirst($classname) . ' Reason Type', + ucfirst($classname) . ' Reasons', + ], + 'fields' => [ 'typenum', + 'type', + $reasons_sub, + ], + 'links' => [ $link, + $link, + '', + ], + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +$cgi->param('class') =~ /^(\w)$/ or die "illegal class"; +my $class=$1; + +my $classname = $FS::reason_type::class_name{$class}; + +my $html_init = ucfirst($classname) . + " reason types allow groups of $classname reasons for reporting purposes." . + qq!<BR><BR><A HREF="${p}edit/reason_type.html?class=$class"><I>Add a ! . + $classname . " reason type</I></A><BR><BR>"; + +my $reasons_sub = sub { + my $reason_type = shift; + + [ map { + [ + { + 'data' => $_->reason, + 'align' => 'left', + 'link' => $p. "edit/reason.html?class=$class&reasonnum=". + $_->reasonnum, + }, + ]; + } + $reason_type->enabled_reasons, + + ]; + +}; + +my $where_clause = "WHERE class='$class'"; +my $count_query = 'SELECT COUNT(*) FROM reason_type '; +$count_query .= $where_clause; + +my $link = [ $p.'edit/reason_type.html?class='.$class.'&typenum=', 'typenum' ]; + +</%init> diff --git a/httemplate/browse/router.cgi b/httemplate/browse/router.cgi new file mode 100644 index 000000000..acddf5677 --- /dev/null +++ b/httemplate/browse/router.cgi @@ -0,0 +1,59 @@ +<% include('/elements/header.html', 'Routers') %> + +<% include('/elements/error.html') %> + +%my $hidecustomerrouters = 0; +%my $hideurl = ''; +%if ($cgi->param('hidecustomerrouters') eq '1') { +% $hidecustomerrouters = 1; +% $cgi->param('hidecustomerrouters', 0); +% $hideurl = '<A HREF="' . $cgi->self_url() . '">Show customer routers</A>'; +%} else { +% $hidecustomerrouters = 0; +% $cgi->param('hidecustomerrouters', 1); +% $hideurl = '<A HREF="' . $cgi->self_url() . '">Hide customer routers</A>'; +%} + +<A HREF="<%$p2%>edit/router.cgi">Add a new router</A> | <%$hideurl%> + +<%table()%> + <TR> + <TD><B>Router name</B></TD> + <TD><B>Address block(s)</B></TD> + </TR> +% foreach my $router (sort {$a->routernum <=> $b->routernum} @router) { +% next if $hidecustomerrouters && $router->svcnum; +% my @addr_block = $router->addr_block; +% if (scalar(@addr_block) == 0) { +% push @addr_block, ' '; +% } +% + + <TR> + <TD ROWSPAN="<%scalar(@addr_block)+1%>"> + <A HREF="<%$p2%>edit/router.cgi?<%$router->routernum%>"><%$router->routername%></A> + </TD> + </TR> +% foreach my $block ( @addr_block ) { + + <TR> + <TD><%UNIVERSAL::isa($block, 'FS::addr_block') ? $block->NetAddr : ' '%></TD> + </TR> +% } + + </TR> +% } + +</TABLE> + +<% include('/elements/footer.html') %> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my @router = qsearch('router', {}); +my $p2 = popurl(2); + +</%init> diff --git a/httemplate/browse/svc_acct_pop.cgi b/httemplate/browse/svc_acct_pop.cgi new file mode 100755 index 000000000..44bc651cf --- /dev/null +++ b/httemplate/browse/svc_acct_pop.cgi @@ -0,0 +1,74 @@ +<% include( 'elements/browse.html', + 'title' => 'Access Numbers', + 'html_init' => $html_init, + 'name_singular' => 'access number', + 'query' => $query, + 'count_query' => $count_query, + 'header' => [ + '#', + 'City', + 'State', + 'Area code', + 'Exchange', + 'Local', + 'Accounts', + ], + 'fields' => [ + 'popnum', + 'city', + 'state', + 'ac', + 'exch', + 'loc', + $num_accounts_sub, + ], + 'align' => 'rllrrrr', + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $html_init = qq! + <A HREF="${p}edit/svc_acct_pop.cgi"><I>Add new Access Number</I></A> + <BR><BR> +!; + +my $query = { 'select' => '*, + ( SELECT COUNT(*) FROM svc_acct + WHERE svc_acct.popnum = svc_acct_pop.popnum + ) AS num_accounts + ', + 'table' => 'svc_acct_pop', + #'hashref' => { 'disabled' => '' }, + 'extra_sql' => 'ORDER BY state, city, ac, exch, loc', + }; + +my $count_query = "SELECT COUNT(*) FROM svc_acct_pop"; # WHERE DISABLED IS NULL OR DISABLED = ''"; + +my $svc_acct_pop_link = [ $p.'edit/svc_acct_pop.cgi?', 'popnum' ]; + +my $svc_acct_link = $p. 'search/svc_acct.cgi?popnum='; + +my $num_accounts_sub = sub { + my $svc_acct_pop = shift; + [ + [ + { 'data' => '<B><FONT COLOR="#00CC00">'. + $svc_acct_pop->get('num_accounts'). + '</FONT></B>', + 'align' => 'right', + }, + { 'data' => 'active', + 'align' => 'left', + 'link' => ( $svc_acct_pop->get('num_accounts') + ? $svc_acct_link. $svc_acct_pop->popnum + : '' + ), + }, + ], + ]; +}; + +</%init> |