diff options
279 files changed, 17381 insertions, 16738 deletions
@@ -9,10 +9,8 @@ DATASOURCE = DBI:Pg:dbname=freeside DB_USER = freeside DB_PASSWORD= -#TEMPLATE = asp TEMPLATE = mason -ASP_GLOBAL = /usr/local/etc/freeside/asp-global MASON_HANDLER = /usr/local/etc/freeside/handler.pl MASONDATA = /usr/local/etc/freeside/masondata @@ -117,27 +115,19 @@ help: @echo @echo " dev dev-docs dev-perl-modules" @echo - @echo " aspdocs masondocs alldocs docs" + @echo " masondocs alldocs docs" @echo " htmlman forcehtmlman" @echo " perl-modules" #@echo #@echo " upload-docs release update-webdemo" -aspdocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* - rm -rf aspdocs - cp -pr httemplate aspdocs - touch aspdocs - masondocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* rm -rf masondocs cp -pr httemplate masondocs - ( cd masondocs; \ - ../bin/masonize; \ - ) touch masondocs -alldocs: aspdocs masondocs +alldocs: masondocs docs: make ${TEMPLATE}docs @@ -162,25 +152,17 @@ forcehtmlman: install-docs: docs [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true cp -r ${TEMPLATE}docs ${FREESIDE_DOCUMENT_ROOT} - [ "${TEMPLATE}" = "asp" -a ! -e ${ASP_GLOBAL} ] && mkdir ${ASP_GLOBAL} || true - [ "${TEMPLATE}" = "asp" ] && chown -R freeside ${ASP_GLOBAL} || true - [ "${TEMPLATE}" = "asp" ] && cp htetc/global.asa ${ASP_GLOBAL} || true - [ "${TEMPLATE}" = "asp" ] && \ - perl -p -i -e "\ - s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \ - " ${ASP_GLOBAL}/global.asa || true - [ "${TEMPLATE}" = "mason" ] && cp htetc/handler.pl ${MASON_HANDLER} || true - [ "${TEMPLATE}" = "mason" ] && \ - perl -p -i -e "\ - s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \ - s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \ - " ${MASON_HANDLER} || true - [ "${TEMPLATE}" = "mason" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true - [ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true - -dev-docs: docs + cp htetc/handler.pl ${MASON_HANDLER} + perl -p -i -e "\ + s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \ + s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \ + " ${MASON_HANDLER} + [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true + chown -R freeside ${MASONDATA} + +dev-docs: [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true - ln -s ${FREESIDE_PATH}/masondocs ${FREESIDE_DOCUMENT_ROOT} + ln -s ${FREESIDE_PATH}/httemplate ${FREESIDE_DOCUMENT_ROOT} cp htetc/handler.pl ${MASON_HANDLER} perl -p -i -e "\ s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \ @@ -332,7 +314,7 @@ install-rt: [ ${RT_ENABLED} -eq 1 ] && ( cd rt; make install ) || true clean: - rm -rf aspdocs masondocs + rm -rf masondocs cd FS; \ make clean diff --git a/httemplate/browse/access_group.html b/httemplate/browse/access_group.html index 9ebb2b882..d1c3aea4c 100644 --- a/httemplate/browse/access_group.html +++ b/httemplate/browse/access_group.html @@ -1,53 +1,54 @@ -<% - -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, - - ]; - -}; - -my $rights_sub = sub { - my $access_group = shift; - - [ map { my $access_right = $_; - [ - { - 'data' => $access_right->rightname, - 'align' => 'left', - }, - ]; - } - $access_group->access_rights, - - ]; - -}; - -my $count_query = 'SELECT COUNT(*) FROM access_group'; - -my $link = [ $p.'edit/access_group.html?', 'groupnum' ]; - -%><%= include( 'elements/browse.html', +% +% +%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, +% +% ]; +% +%}; +% +%my $rights_sub = sub { +% my $access_group = shift; +% +% [ map { my $access_right = $_; +% [ +% { +% 'data' => $access_right->rightname, +% 'align' => 'left', +% }, +% ]; +% } +% $access_group->access_rights, +% +% ]; +% +%}; +% +%my $count_query = 'SELECT COUNT(*) FROM access_group'; +% +%my $link = [ $p.'edit/access_group.html?', 'groupnum' ]; +% +% +<% include( 'elements/browse.html', 'title' => 'Internal Access Groups', 'menubar' => [ # 'Main menu' => $p, 'Internal users' => $p.'browse/access_user.html', diff --git a/httemplate/browse/access_user.html b/httemplate/browse/access_user.html index 5b787977d..05384289a 100644 --- a/httemplate/browse/access_user.html +++ b/httemplate/browse/access_user.html @@ -1,83 +1,84 @@ -<% - -my $html_init = - "Internal users have access to the back-office interface. Typically, this is your employees and contractors, but in a VISP setup, you can also add accounts for your reseller's employees. 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/part_pkg.cgi -my %search = (); -my $search = ''; -unless ( $cgi->param('showdisabled') ) { - %search = ( 'disabled' => '' ); - $search = "( disabled = '' OR disabled IS NULL )"; -} - -#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 $posttotal; -if ( $cgi->param('showdisabled') ) { - $cgi->param('showdisabled', 0); - $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled users</a> )'; - $cgi->param('showdisabled', 1); -} else { - $cgi->param('showdisabled', 1); - $posttotal = '( <a href="'. $cgi->self_url. '">show disabled users</a> )'; - $cgi->param('showdisabled', 0); -} - -my $count_query = 'SELECT COUNT(*) FROM access_user'; -$count_query .= " WHERE $search" - if $search; - -my $link = [ $p.'edit/access_user.html?', 'usernum' ]; - -my @header = ( '#', 'Username' ); -my @fields = ( 'usernum', 'username' ); -my $align = 'rl'; -my @links = ( $link, $link ); -my @style = ( '', '' ); - -#false laziness w/part_pkg.cgi -#unless ( $cgi->param('showdisabled') ) { #its been reversed already -if ( $cgi->param('showdisabled') ) { #its been reversed already - push @header, 'Status'; - push @fields, sub { shift->disabled - ? '<FONT COLOR="#FF0000">DISABLED</FONT>' - : '<FONT COLOR="#00CC00">Active</FONT>' - }; - push @links, ''; - $align .= 'c'; - push @style, 'b'; -} - -push @header, 'Full name', 'Groups'; -push @fields, 'name', $groups_sub; -push @links, $link, ''; -$align .= 'll'; - -%><%= include( 'elements/browse.html', +% +% +%my $html_init = +% "Internal users have access to the back-office interface. Typically, this is your employees and contractors, but in a VISP setup, you can also add accounts for your reseller's employees. 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/part_pkg.cgi +%my %search = (); +%my $search = ''; +%unless ( $cgi->param('showdisabled') ) { +% %search = ( 'disabled' => '' ); +% $search = "( disabled = '' OR disabled IS NULL )"; +%} +% +%#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 $posttotal; +%if ( $cgi->param('showdisabled') ) { +% $cgi->param('showdisabled', 0); +% $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled users</a> )'; +% $cgi->param('showdisabled', 1); +%} else { +% $cgi->param('showdisabled', 1); +% $posttotal = '( <a href="'. $cgi->self_url. '">show disabled users</a> )'; +% $cgi->param('showdisabled', 0); +%} +% +%my $count_query = 'SELECT COUNT(*) FROM access_user'; +%$count_query .= " WHERE $search" +% if $search; +% +%my $link = [ $p.'edit/access_user.html?', 'usernum' ]; +% +%my @header = ( '#', 'Username' ); +%my @fields = ( 'usernum', 'username' ); +%my $align = 'rl'; +%my @links = ( $link, $link ); +%my @style = ( '', '' ); +% +%#false laziness w/part_pkg.cgi +%#unless ( $cgi->param('showdisabled') ) { #its been reversed already +%if ( $cgi->param('showdisabled') ) { #its been reversed already +% push @header, 'Status'; +% push @fields, sub { shift->disabled +% ? '<FONT COLOR="#FF0000">DISABLED</FONT>' +% : '<FONT COLOR="#00CC00">Active</FONT>' +% }; +% push @links, ''; +% $align .= 'c'; +% push @style, 'b'; +%} +% +%push @header, 'Full name', 'Groups'; +%push @fields, 'name', $groups_sub; +%push @links, $link, ''; +%$align .= 'll'; +% +% +<% include( 'elements/browse.html', 'title' => 'Internal Users', 'menubar' => [ #'Main menu' => $p, 'Internal access groups' => $p.'browse/access_group.html', diff --git a/httemplate/browse/addr_block.cgi b/httemplate/browse/addr_block.cgi index d453adf8e..87f46c0e7 100644 --- a/httemplate/browse/addr_block.cgi +++ b/httemplate/browse/addr_block.cgi @@ -1,66 +1,73 @@ -<%= include("/elements/header.html",'Address Blocks', menubar('Main Menu' => $p)) %> -<% +<% include("/elements/header.html",'Address Blocks', menubar('Main Menu' => $p)) %> +% +% +%use NetAddr::IP; +% +%my @addr_block = qsearch('addr_block', {}); +%my @router = qsearch('router', {}); +%my $block; +%my $p2 = popurl(2); +%my $path = $p2 . "edit/process/addr_block"; +% +% +% if ($cgi->param('error')) { -use NetAddr::IP; - -my @addr_block = qsearch('addr_block', {}); -my @router = qsearch('router', {}); -my $block; -my $p2 = popurl(2); -my $path = $p2 . "edit/process/addr_block"; - -%> - -<% if ($cgi->param('error')) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%=$cgi->param('error')%></FONT> + <FONT SIZE="+1" COLOR="#ff0000">Error: <%$cgi->param('error')%></FONT> <BR><BR> -<% } %> +% } -<%=table()%> -<% foreach $block (sort {$a->NetAddr cmp $b->NetAddr} @addr_block) { %> +<%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><%$block->NetAddr%></TD> +% if (my $router = $block->router) { +% if (scalar($block->svc_broadband) == 0) { + <TD> - <%=$router->routername%> + <%$router->routername%> </TD> <TD> - <FORM ACTION="<%=$path%>/deallocate.cgi" METHOD="POST"> - <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%=$block->blocknum%>"> + <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 { %> +% } else { + <TD COLSPAN="2"> - <%=$router->routername%> + <%$router->routername%> </TD> - <% } %> - <% } else { %> +% } +% } else { + <TD> - <FORM ACTION="<%=$path%>/allocate.cgi" METHOD="POST"> - <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%=$block->blocknum%>"> + <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> - <% } %> +% 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%>"> + <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"> + <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"> diff --git a/httemplate/browse/agent.cgi b/httemplate/browse/agent.cgi index f5157d9b7..001e6ba50 100755 --- a/httemplate/browse/agent.cgi +++ b/httemplate/browse/agent.cgi @@ -1,283 +1,371 @@ -<% - - my %search; - if ( $cgi->param('showdisabled') - || !dbdef->table('agent')->column('disabled') ) { - %search = (); - } else { - %search = ( 'disabled' => '' ); - } - - my $conf = new FS::Conf; - -%> -<%= include("/elements/header.html",'Agent Listing', menubar( +% +% +% my %search; +% if ( $cgi->param('showdisabled') +% || !dbdef->table('agent')->column('disabled') ) { +% %search = (); +% } else { +% %search = ( 'disabled' => '' ); +% } +% +% my $conf = new FS::Conf; +% +% + +<% include("/elements/header.html",'Agent Listing', menubar( 'Main Menu' => $p, '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> +<A HREF="<% $p %>edit/agent.cgi"><I>Add a new agent</I></A><BR><BR> +% if ( dbdef->table('agent')->column('disabled') ) { -<% if ( dbdef->table('agent')->column('disabled') ) { %> - <%= $cgi->param('showdisabled') + <% $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 = ''; -%> +<% 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" 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">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">Registration codes</TH> <TH CLASS="grid" BGCOLOR="#cccccc">Prepaid cards</TH> - <% if ( $conf->config('ticket_system') ) { %> +% 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>Freq.</FONT></TH> <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Prog.</FONT></TH> </TR> -<% -# <TH><FONT SIZE=-1>Agent #</FONT></TH> -# <TH>Agent</TH> +% +%# <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; +% } +% +% + -foreach my $agent ( sort { - #$a->getfield('agentnum') <=> $b->getfield('agentnum') - $a->getfield('agent') cmp $b->getfield('agent') -} qsearch('agent', \%search ) ) { + <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') ) { - my $cust_main_link = $p. 'search/cust_main.cgi?agentnum_on=1&'. - 'agentnum='. $agent->agentnum; + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $agent->disabled ? 'DISABLED' : '' %></TD> +% } - my $cust_pkg_link = $p. 'search/cust_pkg.cgi?agentnum='. $agent->agentnum; - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } -%> + <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> - <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="inv" BGCOLOR="<%= $bgcolor %>"> + <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 %> + <% 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><% } %> +% 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 %> + <% 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><% } %> +% 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 %> + <% 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><% } %> +% 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 %> + <% 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><% } %> +% 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 %> + <% 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><% } %> +% 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"> + <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 %> + <% 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><% } %> +% 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 %> + <% 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><% } %> +% 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 %> + <% 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><% } %> +% 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 %> + <% 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><% } %> +% 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 %>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 CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <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 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 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') ) { - <% if ( $conf->config('ticket_system') ) { %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <% if ( $agent->ticketing_queueid ) { %> - Queue: <%= $agent->ticketing_queueid %>: <%= $agent->ticketing_queue %><BR> - <% } %> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> +% if ( $agent->ticketing_queueid ) { + + Queue: <% $agent->ticketing_queueid %>: <% $agent->ticketing_queue %><BR> +% } + </TD> +% } - <% } %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> <TABLE 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 } ) - ) { - %> +% 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 + <% $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?<%= 'XXXoverridenum' %>">(delete)</A></FONT> + <FONT SIZE=-1><A HREF="<%$p%>misc/delete-agent_payment_gateway.cgi?<% 'XXXoverridenum' %>">(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> + <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="grid" BGCOLOR="<%= $bgcolor %>"><%= $agent->freq %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $agent->prog %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $agent->freq %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $agent->prog %></TD> --> </TR> +% } -<% } %> </TABLE> </BODY> diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi index ceffce3d4..318d0b6ea 100755 --- a/httemplate/browse/agent_type.cgi +++ b/httemplate/browse/agent_type.cgi @@ -1,37 +1,38 @@ -<% - -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' ]; - -%><%= include( 'elements/browse.html', +% +% +%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' ]; +% +% +<% include( 'elements/browse.html', 'title' => 'Agent Types', 'menubar' => [ #'Main menu' => $p, 'Agents' =>"${p}browse/agent.cgi", diff --git a/httemplate/browse/cust_main_county.cgi b/httemplate/browse/cust_main_county.cgi index 9e3feb8f3..69a7eb9a0 100755 --- a/httemplate/browse/cust_main_county.cgi +++ b/httemplate/browse/cust_main_county.cgi @@ -1,22 +1,22 @@ -<%= include('/elements/header.html', "Tax Rate Listing", menubar( +<% include('/elements/header.html', "Tax Rate Listing", menubar( 'Edit tax rates' => $p. "edit/cust_main_county.cgi", )) %> Click on <u>expand country</u> to specify a country's tax rates by state. <BR>Click on <u>expand state</u> to specify a state's tax rates by county. +% +%my $conf = new FS::Conf; +%my $enable_taxclasses = $conf->exists('enable_taxclasses'); +% +%if ( $enable_taxclasses ) { -<% -my $conf = new FS::Conf; -my $enable_taxclasses = $conf->exists('enable_taxclasses'); - -if ( $enable_taxclasses ) { %> <BR>Click on <u>expand taxclasses</u> to specify tax classes +% } -<% } %> <BR><BR> -<%= table() %> +<% table() %> <TR> <TH><FONT SIZE=-1>Country</FONT></TH> @@ -27,123 +27,140 @@ if ( $enable_taxclasses ) { %> <TH><FONT SIZE=-1>Tax</FONT></TH> <TH><FONT SIZE=-1>Exemption</TH> </TR> +% +%my @regions = sort { $a->country cmp $b->country +% or $a->state cmp $b->state +% or $a->county cmp $b->county +% or $a->taxclass cmp $b->taxclass +% } qsearch('cust_main_county',{}); +% +%my $sup=0; +%#foreach $cust_main_county ( @regions ) { +%for ( my $i=0; $i<@regions; $i++ ) { +% my $cust_main_county = $regions[$i]; +% my $hashref = $cust_main_county->hashref; +% +% -<% -my @regions = sort { $a->country cmp $b->country - or $a->state cmp $b->state - or $a->county cmp $b->county - or $a->taxclass cmp $b->taxclass - } qsearch('cust_main_county',{}); - -my $sup=0; -#foreach $cust_main_county ( @regions ) { -for ( my $i=0; $i<@regions; $i++ ) { - my $cust_main_county = $regions[$i]; - my $hashref = $cust_main_county->hashref; - - %> <TR> - <TD BGCOLOR="#ffffff"><%= $hashref->{country} %></TD> - - <% - - my $j; - if ( $sup ) { - $sup--; - } else { - - #lookahead - for ( $j=1; $i+$j<@regions; $j++ ) { - last if $hashref->{country} ne $regions[$i+$j]->country - || $hashref->{state} ne $regions[$i+$j]->state - || $hashref->{tax} != $regions[$i+$j]->tax - || $hashref->{exempt_amount} != $regions[$i+$j]->exempt_amount - || $hashref->{setuptax} ne $regions[$i+$j]->setuptax - || $hashref->{recurtax} ne $regions[$i+$j]->recurtax; - } - - my $newsup=0; - if ( $j>1 && $i+$j+1 < @regions - && ( $hashref->{state} ne $regions[$i+$j+1]->state - || $hashref->{country} ne $regions[$i+$j+1]->country - ) - && ( ! $i - || $hashref->{state} ne $regions[$i-1]->state - || $hashref->{country} ne $regions[$i-1]->country - ) - ) { - $sup = $j-1; - } else { - $j = 1; - } - - %> - - <TD ROWSPAN=<%= $j %><%= + <TD BGCOLOR="#ffffff"><% $hashref->{country} %></TD> +% +% +% my $j; +% if ( $sup ) { +% $sup--; +% } else { +% +% #lookahead +% for ( $j=1; $i+$j<@regions; $j++ ) { +% last if $hashref->{country} ne $regions[$i+$j]->country +% || $hashref->{state} ne $regions[$i+$j]->state +% || $hashref->{tax} != $regions[$i+$j]->tax +% || $hashref->{exempt_amount} != $regions[$i+$j]->exempt_amount +% || $hashref->{setuptax} ne $regions[$i+$j]->setuptax +% || $hashref->{recurtax} ne $regions[$i+$j]->recurtax; +% } +% +% my $newsup=0; +% if ( $j>1 && $i+$j+1 < @regions +% && ( $hashref->{state} ne $regions[$i+$j+1]->state +% || $hashref->{country} ne $regions[$i+$j+1]->country +% ) +% && ( ! $i +% || $hashref->{state} ne $regions[$i-1]->state +% || $hashref->{country} ne $regions[$i-1]->country +% ) +% ) { +% $sup = $j-1; +% } else { +% $j = 1; +% } +% +% + + + <TD ROWSPAN=<% $j %><% $hashref->{state} ? ' BGCOLOR="#ffffff">'. $hashref->{state} : qq! BGCOLOR="#cccccc">(ALL) <FONT SIZE=-1>!. qq!<A HREF="${p}edit/cust_main_county-expand.cgi?!. $hashref->{taxnum}. qq!">expand country</A></FONT>! %> - <% if ( $j>1 ) { %> - <FONT SIZE=-1><A HREF="<%= $p %>edit/process/cust_main_county-collapse.cgi?<%= $hashref->{taxnum} %>">collapse state</A></FONT> - <% } %> +% if ( $j>1 ) { + + <FONT SIZE=-1><A HREF="<% $p %>edit/process/cust_main_county-collapse.cgi?<% $hashref->{taxnum} %>">collapse state</A></FONT> +% } + </TD> - <% } %> - -<% # $sup=$newsup; %> - - <TD<% if ( $hashref->{county} ) { - %> BGCOLOR="#ffffff"><%= $hashref->{county} %> - <% } else { - %> BGCOLOR="#cccccc">(ALL) - <% if ( $hashref->{state} ) { %> - <FONT SIZE=-1><A HREF="<%= $p %>edit/cust_main_county-expand.cgi?<%= $hashref->{taxnum} %>">expand state</A></FONT> - <% } %> - <% } %> +% } +% # $sup=$newsup; + + + <TD +% if ( $hashref->{county} ) { +% + BGCOLOR="#ffffff"><% $hashref->{county} %> +% } else { +% + BGCOLOR="#cccccc">(ALL) +% if ( $hashref->{state} ) { + + <FONT SIZE=-1><A HREF="<% $p %>edit/cust_main_county-expand.cgi?<% $hashref->{taxnum} %>">expand state</A></FONT> +% } +% } + </TD> - <TD<% if ( $hashref->{taxclass} ) { - %> BGCOLOR="#ffffff"><%= $hashref->{taxclass} %> - <% } else { - %> BGCOLOR="#cccccc">(ALL) - <% if ( $enable_taxclasses ) { %> - <FONT SIZE=-1><A HREF="<%= $p %>edit/cust_main_county-expand.cgi?taxclass<%= $hashref->{taxnum} %>">expand taxclasses</A></FONT> - <% } %> - <% } %> + <TD +% if ( $hashref->{taxclass} ) { +% + BGCOLOR="#ffffff"><% $hashref->{taxclass} %> +% } else { +% + BGCOLOR="#cccccc">(ALL) +% if ( $enable_taxclasses ) { + + <FONT SIZE=-1><A HREF="<% $p %>edit/cust_main_county-expand.cgi?taxclass<% $hashref->{taxnum} %>">expand taxclasses</A></FONT> +% } +% } + </TD> - <TD<% if ( $hashref->{taxname} ) { - %> BGCOLOR="#ffffff"><%= $hashref->{taxname} %> - <% } else { - %> BGCOLOR="#cccccc">Tax - <% } %> + <TD +% if ( $hashref->{taxname} ) { +% + BGCOLOR="#ffffff"><% $hashref->{taxname} %> +% } else { +% + BGCOLOR="#cccccc">Tax +% } + </TD> - <TD BGCOLOR="#ffffff"><%= $hashref->{tax} %>%</TD> + <TD BGCOLOR="#ffffff"><% $hashref->{tax} %>%</TD> <TD BGCOLOR="#ffffff"> +% if ( $hashref->{exempt_amount} > 0 ) { - <% if ( $hashref->{exempt_amount} > 0 ) { %> - $<%= sprintf("%.2f", $hashref->{exempt_amount} ) %> per month<BR> - <% } %> + $<% sprintf("%.2f", $hashref->{exempt_amount} ) %> per month<BR> +% } +% if ( $hashref->{setuptax} =~ /^Y$/i ) { - <% if ( $hashref->{setuptax} =~ /^Y$/i ) { %> Setup fee<BR> - <% } %> - - <% if ( $hashref->{recurtax} =~ /^Y$/i ) { %> +% } +% if ( $hashref->{recurtax} =~ /^Y$/i ) { + Recurring fee<BR> - <% } %> +% } + </TD> </TR> +% } -<% } %> </TABLE> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/browse/cust_pay_batch.cgi b/httemplate/browse/cust_pay_batch.cgi index 98ea2f5a2..e40e95870 100755 --- a/httemplate/browse/cust_pay_batch.cgi +++ b/httemplate/browse/cust_pay_batch.cgi @@ -1,27 +1,27 @@ <!-- mason kludge --> -<%= include("/elements/header.html","Credit card batch details", menubar( 'Main Menu' => $p,)) %> +<% include("/elements/header.html","Credit card batch details", menubar( 'Main Menu' => $p,)) %> +% +% +%die "No batch specified (bad URL)!" unless $cgi->keywords; +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $batchnum = $1; +%my $pay_batch = qsearchs('pay_batch',{'batchnum'=>$batchnum}); +%die "Batch not found!" unless $pay_batch; +% +% -<% -die "No batch specified (bad URL)!" unless $cgi->keywords; -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $batchnum = $1; -my $pay_batch = qsearchs('pay_batch',{'batchnum'=>$batchnum}); -die "Batch not found!" unless $pay_batch; - -%> - -<FORM ACTION="<%=$p%>misc/download-batch.cgi" METHOD="POST"> +<FORM ACTION="<%$p%>misc/download-batch.cgi" METHOD="POST"> Download batch in format <SELECT NAME="format"> <OPTION VALUE="">Default batch mode</OPTION> <OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV file for TD Canada Trust Merchant PC Batch</OPTION> <OPTION VALUE="PAP">80 byte file for TD Canada Trust PAP Batch</OPTION> <OPTION VALUE="BoM">Bank of Montreal ECA batch</OPTION> -</SELECT><INPUT TYPE="hidden" NAME="batchnum" VALUE="<%= $batchnum %>"><INPUT TYPE="submit" VALUE="Download"></FORM> +</SELECT><INPUT TYPE="hidden" NAME="batchnum" VALUE="<% $batchnum %>"><INPUT TYPE="submit" VALUE="Download"></FORM> <BR><BR> -<FORM ACTION="<%=$p%>misc/upload-batch.cgi" METHOD="POST" ENCTYPE="multipart/form-data"> +<FORM ACTION="<%$p%>misc/upload-batch.cgi" METHOD="POST" ENCTYPE="multipart/form-data"> Upload results<BR> Filename <INPUT TYPE="file" NAME="batch_results"><BR> Format <SELECT NAME="format"> @@ -32,26 +32,26 @@ Format <SELECT NAME="format"> </SELECT><BR> <INPUT TYPE="submit" VALUE="Upload"></FORM> <BR> +% +% my $statement = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=". +% $batchnum; +% my $sth = dbh->prepare($statement) or die dbh->errstr. "doing $statement"; +% $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; +% my $total = $sth->fetchrow_arrayref->[0]; +% +% my $c_statement = "SELECT COUNT(*) from cust_pay_batch WHERE batchnum=". +% $batchnum; +% my $c_sth = dbh->prepare($c_statement) +% or die dbh->errstr. "doing $c_statement"; +% $c_sth->execute or die "Error executing \"$c_statement\": ". $c_sth->errstr; +% my $cards = $c_sth->fetchrow_arrayref->[0]; +% -<% - my $statement = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=". - $batchnum; - my $sth = dbh->prepare($statement) or die dbh->errstr. "doing $statement"; - $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; - my $total = $sth->fetchrow_arrayref->[0]; - - my $c_statement = "SELECT COUNT(*) from cust_pay_batch WHERE batchnum=". - $batchnum; - my $c_sth = dbh->prepare($c_statement) - or die dbh->errstr. "doing $c_statement"; - $c_sth->execute or die "Error executing \"$c_statement\": ". $c_sth->errstr; - my $cards = $c_sth->fetchrow_arrayref->[0]; -%> -<%= $cards %> credit card payments batched<BR> -$<%= sprintf("%.2f", $total) %> total in batch<BR> +<% $cards %> credit card payments batched<BR> +$<% sprintf("%.2f", $total) %> total in batch<BR> <BR> -<%= &table() %> +<% &table() %> <TR> <TH>#</TH> <TH><font size=-1>inv#</font></TH> @@ -62,35 +62,35 @@ $<%= sprintf("%.2f", $total) %> total in batch<BR> <TH>Amount</TH> <TH>Status</TH> </TR> +% +%foreach my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum } +% qsearch('cust_pay_batch', {'batchnum'=>$batchnum} ) +%) { +% my $cardnum = $cust_pay_batch->payinfo; +% #$cardnum =~ s/.{4}$/xxxx/; +% $cardnum = 'x'x(length($cardnum)-4). substr($cardnum,(length($cardnum)-4)); +% +% $cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; +% my( $mon, $year ) = ( $2, $1 ); +% $mon = "0$mon" if $mon < 10; +% my $exp = "$mon/$year"; +% +% -<% -foreach my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum } - qsearch('cust_pay_batch', {'batchnum'=>$batchnum} ) -) { - my $cardnum = $cust_pay_batch->payinfo; - #$cardnum =~ s/.{4}$/xxxx/; - $cardnum = 'x'x(length($cardnum)-4). substr($cardnum,(length($cardnum)-4)); - - $cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; - my( $mon, $year ) = ( $2, $1 ); - $mon = "0$mon" if $mon < 10; - my $exp = "$mon/$year"; - -%> <TR> - <TD><%= $cust_pay_batch->paybatchnum %></TD> - <TD><A HREF="../view/cust_bill.cgi?<%= $cust_pay_batch->invnum %>"><%= $cust_pay_batch->invnum %></TD> - <TD><A HREF="../view/cust_main.cgi?<%= $cust_pay_batch->custnum %>"><%= $cust_pay_batch->custnum %></TD> - <TD><%= $cust_pay_batch->get('last'). ', '. $cust_pay_batch->first %></TD> - <TD><%= $cust_pay_batch->payname %></TD> - <TD><%= $cardnum %></TD> - <TD><%= $exp %></TD> - <TD align="right">$<%= $cust_pay_batch->amount %></TD> - <TD><%= $cust_pay_batch->status %></TD> + <TD><% $cust_pay_batch->paybatchnum %></TD> + <TD><A HREF="../view/cust_bill.cgi?<% $cust_pay_batch->invnum %>"><% $cust_pay_batch->invnum %></TD> + <TD><A HREF="../view/cust_main.cgi?<% $cust_pay_batch->custnum %>"><% $cust_pay_batch->custnum %></TD> + <TD><% $cust_pay_batch->get('last'). ', '. $cust_pay_batch->first %></TD> + <TD><% $cust_pay_batch->payname %></TD> + <TD><% $cardnum %></TD> + <TD><% $exp %></TD> + <TD align="right">$<% $cust_pay_batch->amount %></TD> + <TD><% $cust_pay_batch->status %></TD> </TR> +% } -<% } %> </TABLE> </BODY> diff --git a/httemplate/browse/elements/browse.html b/httemplate/browse/elements/browse.html index 6d146d356..2cc5a9660 100644 --- a/httemplate/browse/elements/browse.html +++ b/httemplate/browse/elements/browse.html @@ -1,4 +1,4 @@ -<%= include( '/search/elements/search.html', +<% 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 index 4a15bf7d4..6d9424e14 100644 --- a/httemplate/browse/inventory_class.html +++ b/httemplate/browse/inventory_class.html @@ -1,27 +1,28 @@ -<% - -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' ]; - -%><%= include( 'elements/browse.html', +% +% +%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' ]; +% +% +<% include( 'elements/browse.html', 'title' => 'Inventory Classes', 'name' => 'inventory classes', 'menubar' => [ 'Add a new inventory class' => diff --git a/httemplate/browse/msgcat.cgi b/httemplate/browse/msgcat.cgi index 318ebfdff..35ea06957 100755 --- a/httemplate/browse/msgcat.cgi +++ b/httemplate/browse/msgcat.cgi @@ -1,40 +1,42 @@ -<%= include('/elements/header.html', "View Message catalog", menubar( +<% include('/elements/header.html', "View Message catalog", menubar( 'Edit message catalog' => $p. "edit/msgcat.cgi", -)) %><% +)) %> +% +% +%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; +% }, +% +%); +% -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; - }, - -); -%> - -<%= $widget->html %> -<%= include('/elements/footer.html') %> +<% $widget->html %> +<% include('/elements/footer.html') %> diff --git a/httemplate/browse/nas.cgi b/httemplate/browse/nas.cgi index 9ccbfe632..022c65ea7 100755 --- a/httemplate/browse/nas.cgi +++ b/httemplate/browse/nas.cgi @@ -1,80 +1,81 @@ <!-- mason kludge --> -<% +% +% +%print header('NAS ports', menubar( +% 'Main Menu' => $p, +%)); +% +%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</ +% -print header('NAS ports', menubar( - 'Main Menu' => $p, -)); - -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</ -%> diff --git a/httemplate/browse/part_bill_event.cgi b/httemplate/browse/part_bill_event.cgi index 91e31d832..2486c6669 100755 --- a/httemplate/browse/part_bill_event.cgi +++ b/httemplate/browse/part_bill_event.cgi @@ -1,118 +1,116 @@ -<% -my %search; -if ( $cgi->param('showdisabled') ) { - %search = (); -} else { - %search = ( 'disabled' => '' ); -} +% +%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); +% -my @part_bill_event = qsearch('part_bill_event', \%search ); -my $total = scalar(@part_bill_event); -%> -<%= include("/elements/header.html",'Invoice Event Listing', menubar( 'Main Menu' => $p) ) %> +<% include("/elements/header.html",'Invoice Event Listing', menubar( 'Main Menu' => $p) ) %> Invoice events are actions taken on open invoices.<BR><BR> -<A HREF="<%= $p %>edit/part_bill_event.cgi"><I>Add a new invoice event</I></A> +<A HREF="<% $p %>edit/part_bill_event.cgi"><I>Add a new invoice event</I></A> <BR><BR> -<%= $total %> events -<%= $cgi->param('showdisabled') +<% $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 ) { -<% 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'; +% +% if ( $oldfreq ne $freq ) { - <%= 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'; - %> - - <% 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> + <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" 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">Options</TH> <TH CLASS="grid" BGCOLOR="#cccccc">Code</TH> </TR> - - <% - $oldfreq = $freq; - $bgcolor = ''; - %> - - <% } %> - - <% - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - %> +% +% $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 %>"> - <%= $plandata %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="-1"> - <%= $part_bill_event->eventcode %></FONT></TD> + <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 %>"> + <% $plandata %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><FONT SIZE="-1"> + <% $part_bill_event->eventcode %></FONT></TD> </TR> - <% } %> +% } + </TABLE> <BR><BR> +% } +% } - <% } %> - -<% } %> </BODY> </HTML> diff --git a/httemplate/browse/part_export.cgi b/httemplate/browse/part_export.cgi index 25a49cd20..0f6731739 100755 --- a/httemplate/browse/part_export.cgi +++ b/httemplate/browse/part_export.cgi @@ -1,7 +1,7 @@ <!-- mason kludge --> -<%= include("/elements/header.html","Export Listing", menubar( 'Main Menu' => "$p#sysadmin" )) %> +<% include("/elements/header.html","Export Listing", menubar( 'Main Menu' => "$p#sysadmin" )) %> 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> +<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) @@ -9,30 +9,32 @@ function part_export_areyousure(href) { } </SCRIPT> -<%= table() %> +<% table() %> <TR> <TH COLSPAN=2>Export</TH> <TH>Options</TH> </TR> +% foreach my $part_export ( sort { +% $a->getfield('exportnum') <=> $b->getfield('exportnum') +% } qsearch('part_export',{}) ) { +% -<% foreach my $part_export ( sort { - $a->getfield('exportnum') <=> $b->getfield('exportnum') - } qsearch('part_export',{}) ) { -%> <TR> - <TD><A HREF="<%= $p %>edit/part_export.cgi?<%= $part_export->exportnum %>"><%= $part_export->exportnum %></A></TD> - <TD><%= $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><A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>"><% $part_export->exportnum %></A></TD> + <TD><% $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> - <%= itable() %> - <% my %opt = $part_export->options; - foreach my $opt ( keys %opt ) { %> - <TR><TD><%= $opt %></TD><TD><%= encode_entities($opt{$opt}) %></TD></TR> - <% } %> + <% itable() %> +% my %opt = $part_export->options; +% foreach my $opt ( keys %opt ) { + + <TR><TD><% $opt %></TD><TD><% encode_entities($opt{$opt}) %></TD></TR> +% } + </TABLE> </TD> </TR> +% } -<% } %> </TABLE> </BODY> diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index a5e212d17..f2364b152 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -1,227 +1,228 @@ -<% - -#false laziness w/access_user.html -my %search = (); -my $search = ''; -unless ( $cgi->param('showdisabled') ) { - %search = ( 'disabled' => '' ); - $search = "( disabled = '' OR disabled IS NULL )"; -} - -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 $posttotal; -if ( $cgi->param('showdisabled') ) { - $cgi->param('showdisabled', 0); - $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled packages</a> )'; - $cgi->param('showdisabled', 1); -} else { - $cgi->param('showdisabled', 1); - $posttotal = '( <a href="'. $cgi->self_url. '">show disabled packages</a> )'; - $cgi->param('showdisabled', 0); -} - - -# ------ - -my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ]; - -my @header = ( '#', 'Package', 'Comment' ); -my @fields = ( 'pkgpart', 'pkg', 'comment' ); -my $align = 'rll'; -my @links = ( $link, $link, '' ); -my @style = ( '', '', '' ); - -#false laziness w/access_user.html -#unless ( $cgi->param('showdisabled') ) { #its been reversed already -if ( $cgi->param('showdisabled') ) { #its been reversed already - push @header, 'Status'; - push @fields, sub { shift->disabled - ? '<FONT COLOR="#FF0000">DISABLED</FONT>' - : '<FONT COLOR="#00CC00">Active</FONT>' - }; - push @links, ''; - $align .= 'c'; - push @style, 'b'; -} - -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', - ); - my $cust_pkg_link = $p. 'search/cust_pkg.cgi?pkgpart='; - push @fields, sub { my $part_pkg = shift; - [ - map { - [ - { - 'data' => '<B><FONT COLOR="#'. $col{$_}. '">'. - $part_pkg->get("num_$_"). - '</FONT></B>', - 'align' => 'right', - }, - { - 'data' => $_, - 'align' => 'left', - 'link' => ( $part_pkg->get("num_$_") - ? $cust_pkg_link. - $part_pkg->pkgpart. - ";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' => $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'; -$count_query .= " WHERE $search" - if $search; - -%><%= include( 'elements/browse.html', +% +% +%#false laziness w/access_user.html +%my %search = (); +%my $search = ''; +%unless ( $cgi->param('showdisabled') ) { +% %search = ( 'disabled' => '' ); +% $search = "( disabled = '' OR disabled IS NULL )"; +%} +% +%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 $posttotal; +%if ( $cgi->param('showdisabled') ) { +% $cgi->param('showdisabled', 0); +% $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled packages</a> )'; +% $cgi->param('showdisabled', 1); +%} else { +% $cgi->param('showdisabled', 1); +% $posttotal = '( <a href="'. $cgi->self_url. '">show disabled packages</a> )'; +% $cgi->param('showdisabled', 0); +%} +% +% +%# ------ +% +%my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ]; +% +%my @header = ( '#', 'Package', 'Comment' ); +%my @fields = ( 'pkgpart', 'pkg', 'comment' ); +%my $align = 'rll'; +%my @links = ( $link, $link, '' ); +%my @style = ( '', '', '' ); +% +%#false laziness w/access_user.html +%#unless ( $cgi->param('showdisabled') ) { #its been reversed already +%if ( $cgi->param('showdisabled') ) { #its been reversed already +% push @header, 'Status'; +% push @fields, sub { shift->disabled +% ? '<FONT COLOR="#FF0000">DISABLED</FONT>' +% : '<FONT COLOR="#00CC00">Active</FONT>' +% }; +% push @links, ''; +% $align .= 'c'; +% push @style, 'b'; +%} +% +%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', +% ); +% my $cust_pkg_link = $p. 'search/cust_pkg.cgi?pkgpart='; +% push @fields, sub { my $part_pkg = shift; +% [ +% map { +% [ +% { +% 'data' => '<B><FONT COLOR="#'. $col{$_}. '">'. +% $part_pkg->get("num_$_"). +% '</FONT></B>', +% 'align' => 'right', +% }, +% { +% 'data' => $_, +% 'align' => 'left', +% 'link' => ( $part_pkg->get("num_$_") +% ? $cust_pkg_link. +% $part_pkg->pkgpart. +% ";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' => $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'; +%$count_query .= " WHERE $search" +% if $search; +% +% +<% include( 'elements/browse.html', 'title' => 'Package Definitions', 'menubar' => [ 'Main Menu' => $p ], 'html_init' => $html_init, diff --git a/httemplate/browse/part_referral.html b/httemplate/browse/part_referral.html index c50a406ed..0e61a908e 100755 --- a/httemplate/browse/part_referral.html +++ b/httemplate/browse/part_referral.html @@ -1,129 +1,140 @@ -<%= include("/elements/header.html","Advertising source Listing" ) %> +<% 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> +<A HREF="<% $p %>edit/part_referral.html"><I>Add a new advertising source</I></A> <BR><BR> +% +% my $today = timelocal(0, 0, 0, (localtime(time))[3..5] ); +% my %after; +% tie %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 $statement = "SELECT COUNT(*) FROM h_cust_main +% WHERE history_action = 'insert' +% AND refnum = ? +% AND history_date >= ? +% AND history_date < ? +% AND ". $curuser->agentnums_sql; +% my $sth = dbh->prepare($statement) +% or die dbh->errstr; +% +% my $show_agentnums = scalar($curuser->agentnums); +% +% + + +<% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; +% -<% - my $today = timelocal(0, 0, 0, (localtime(time))[3..5] ); - my %after; - tie %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 $statement = "SELECT COUNT(*) FROM h_cust_main - WHERE history_action = 'insert' - AND refnum = ? - AND history_date >= ? - AND history_date < ? - AND ". $curuser->agentnums_sql; - my $sth = dbh->prepare($statement) - or die dbh->errstr; - - my $show_agentnums = scalar($curuser->agentnums); - -%> - -<%= 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 ) { %> +% if ( $show_agentnums ) { + <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Agent</TH> - <% } %> - <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<%= scalar(keys %after) %>>Customers</TH> +% } + + <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% scalar(keys %after) %>>Customers</TH> </TR> -<% for my $period ( keys %after ) { %> - <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1><%= $period %></FONT></TH> -<% } %> +% 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; +% +% -<% -foreach my $part_referral ( FS::part_referral->all_part_referral(1) ) { + <TR> - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> +% if ( $part_referral->agentnum || $curuser->access_right('Edit global advertising sources') ) { +% $a++; +% - $a = 0; + <A HREF="<% $p %>edit/part_referral.html?<% $part_referral->refnum %>"> +% } -%> - <TR> + <% $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 ) { +% $sth->execute( $part_referral->refnum, +% $today-$after{$period}, +% $today+$before{$period}, +% ) or die $sth->errstr; +% my $number = $sth->fetchrow_arrayref->[0]; +% + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"><% $number %></TD> +% } - <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 ) { - $sth->execute( $part_referral->refnum, - $today-$after{$period}, - $today+$before{$period}, - ) or die $sth->errstr; - my $number = $sth->fetchrow_arrayref->[0]; - %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"><%= $number %></TD> - <% } %> </TR> -<% } %> +% } +% +% $statement =~ s/AND refnum = \?//; +% $sth = dbh->prepare($statement) +% or die dbh->errstr; +% -<% - $statement =~ s/AND refnum = \?//; - $sth = dbh->prepare($statement) - or die dbh->errstr; -%> <TR> <TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=3><B>Total</B></TD> - <% for my $period ( keys %after ) { - $sth->execute( $today-$after{$period}, - $today+$before{$period}, - ) or die $sth->errstr; - my $number = $sth->fetchrow_arrayref->[0]; - %> - <TD BGCOLOR="#dddddd" ALIGN="right"><B><%= $number %><B></TD> - <% } %> +% for my $period ( keys %after ) { +% $sth->execute( $today-$after{$period}, +% $today+$before{$period}, +% ) or die $sth->errstr; +% my $number = $sth->fetchrow_arrayref->[0]; +% + + <TD BGCOLOR="#dddddd" ALIGN="right"><B><% $number %><B></TD> +% } + </TR> </TABLE> </BODY> diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index 805bd88b9..0113263fb 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -1,42 +1,43 @@ -<% - -#code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm -my %flag = ( - '' => '', - 'D' => 'Default', - 'F' => 'Fixed (unchangeable)', - #'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 = (); - -%> -<%= include("/elements/header.html",'Service Definition Listing', menubar( 'Main Menu' => $p) ) %> +% +% +%#code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm +%my %flag = ( +% '' => '', +% 'D' => 'Default', +% 'F' => 'Fixed (unchangeable)', +% #'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 = (); +% +% + +<% include("/elements/header.html",'Service Definition Listing', menubar( 'Main Menu' => $p) ) %> <SCRIPT> function part_export_areyousure(href) { @@ -47,113 +48,130 @@ function part_export_areyousure(href) { 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> -<% } %> +<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') +<% $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') ) ); %> -<%= table() %> +% $cgi->param('showdisabled', ( 1 ^ $cgi->param('showdisabled') ) ); + +<% table() %> <TR> - <TH><A HREF="<%= do { $cgi->param('orderby', 'svcpart'); $cgi->self_url } %>">#</A></TH> - <% if ( $cgi->param('showdisabled') ) { %> + <TH><A HREF="<% do { $cgi->param('orderby', 'svcpart'); $cgi->self_url } %>">#</A></TH> +% if ( $cgi->param('showdisabled') ) { + <TH>Status</TH> - <% } %> - <TH><A HREF="<%= do { $cgi->param('orderby', 'svc'); $cgi->self_url; } %>">Service</A></TH> +% } + + <TH><A HREF="<% do { $cgi->param('orderby', 'svc'); $cgi->self_url; } %>">Service</A></TH> <TH>Table</TH> - <TH><A HREF="<%= do { $cgi->param('orderby', 'active'); $cgi->self_url; } %>"><FONT SIZE=-1>Customer<BR>Services</FONT></A></TH> + <TH><A HREF="<% do { $cgi->param('orderby', 'active'); $cgi->self_url; } %>"><FONT SIZE=-1>Customer<BR>Services</FONT></A></TH> <TH>Export</TH> <TH>Field</TH> <TH COLSPAN=2>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; +% -<% 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; -%> <TR> - <TD ROWSPAN=<%= $rowspan %>><A HREF="<%= $url %>"> - <%= $part_svc->svcpart %></A></TD> -<% if ( $cgi->param('showdisabled') ) { %> - <TD ROWSPAN=<%= $rowspan %>> - <%= $part_svc->disabled + <TD ROWSPAN=<% $rowspan %>><A HREF="<% $url %>"> + <% $part_svc->svcpart %></A></TD> +% if ( $cgi->param('showdisabled') ) { + + <TD ROWSPAN=<% $rowspan %>> + <% $part_svc->disabled ? '<FONT COLOR="#FF0000"><B>Disabled</B></FONT>' : '<FONT COLOR="#00CC00"><B>Enabled</B></FONT>' %> </TD> -<% } %> - <TD ROWSPAN=<%= $rowspan %>><A HREF="<%= $url %>"> - <%= $part_svc->svc %></A></TD> - <TD ROWSPAN=<%= $rowspan %>> - <%= $svcdb %></TD> - <TD ROWSPAN=<%= $rowspan %>> - <FONT COLOR="#00CC00"><B><%= $num_active_cust_svc{$part_svc->svcpart} %></B></FONT> <A HREF="<%=$p%>search/<%= $svcdb %>.cgi?svcpart=<%= $part_svc->svcpart %>">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 ROWSPAN=<% $rowspan %>><A HREF="<% $url %>"> + <% $part_svc->svc %></A></TD> + <TD ROWSPAN=<% $rowspan %>> + <% $svcdb %></TD> + <TD ROWSPAN=<% $rowspan %>> + <FONT COLOR="#00CC00"><B><% $num_active_cust_svc{$part_svc->svcpart} %></B></FONT> <A HREF="<%$p%>search/<% $svcdb %>.cgi?svcpart=<% $part_svc->svcpart %>">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 %>><%= itable() %> -<% -# 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 } ) - ) { -%> + <TD ROWSPAN=<% $rowspan %>><% itable() %> +% +%# 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> -<% } %> + <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> +% my($n1)=''; +% foreach my $field ( @fields ) { +% my $flag = $part_svc->part_svc_column($field)->columnflag; +% -<% my($n1)=''; - foreach my $field ( @fields ) { - my $flag = $part_svc->part_svc_column($field)->columnflag; -%> - <%= $n1 %> - <TD><%= $field %></TD> - <TD><%= $flag{$flag} %></TD> + <% $n1 %> + <TD><% $field %></TD> + <TD><% $flag{$flag} %></TD> <TD> - <% my $value = $part_svc->part_svc_column($field)->columnvalue; - if ( $flag =~ /^[MA]$/ ) { - $inventory_class{$value} - ||= qsearchs('inventory_class', { 'classnum' => $value } ); - %> - <%= $inventory_class{$value} +% my $value = $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> +% } else { + <% $value %> +% } + + </TD> +% $n1="</TR><TR>"; +% } +% -<% $n1="</TR><TR>"; - } -%> </TR> -<% } %> +% } + </TABLE> </BODY> </HTML> diff --git a/httemplate/browse/part_virtual_field.cgi b/httemplate/browse/part_virtual_field.cgi index 555798818..7dcb58a53 100644 --- a/httemplate/browse/part_virtual_field.cgi +++ b/httemplate/browse/part_virtual_field.cgi @@ -1,39 +1,43 @@ -<%= include("/elements/header.html",'Virtual field definitions', menubar('Main Menu' => $p)) %> -<% +<% include("/elements/header.html",'Virtual field definitions', menubar('Main Menu' => $p)) %> +% +% +%my %pvfs; +%my $block; +%my $p2 = popurl(2); +%my $dbtable; +% +%foreach (qsearch('part_virtual_field', {})) { +% push @{ $pvfs{$_->dbtable} }, $_; +%} +% +% if ($cgi->param('error')) { -my %pvfs; -my $block; -my $p2 = popurl(2); -my $dbtable; - -foreach (qsearch('part_virtual_field', {})) { - push @{ $pvfs{$_->dbtable} }, $_; -} -%> - -<% if ($cgi->param('error')) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%=$cgi->param('error')%></FONT> + <FONT SIZE="+1" COLOR="#ff0000">Error: <%$cgi->param('error')%></FONT> <BR><BR> -<% } %> +% } + -<A HREF="<%=$p2%>edit/part_virtual_field.cgi"><I>Add a new field</I></A><BR><BR> +<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)) { -<% foreach $dbtable (sort { $a cmp $b } keys (%pvfs)) { %> -<H3><%=$dbtable%></H3> +<H3><%$dbtable%></H3> -<%=table()%> +<%table()%> <TH><TD>Field name</TD><TD>Description</TD></TH> -<% foreach my $pvf (sort {$a->name cmp $b->name} @{ $pvfs{$dbtable} }) { %> +% 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> + <A HREF="<%$p2%>edit/part_virtual_field.cgi?<%$pvf->vfieldpart%>"> + <%$pvf->name%></A></TD> + <TD><%$pvf->label%></TD> </TR> -<% } %> +% } + </TABLE> -<% } %> +% } + </BODY> </HTML> diff --git a/httemplate/browse/payment_gateway.html b/httemplate/browse/payment_gateway.html index 791906b78..6c14a1006 100644 --- a/httemplate/browse/payment_gateway.html +++ b/httemplate/browse/payment_gateway.html @@ -1,71 +1,76 @@ -<% +% +% +% my %search; +% if ( $cgi->param('showdisabled') ) { +% %search = (); +% } else { +% %search = ( 'disabled' => '' ); +% } +% +% - my %search; - if ( $cgi->param('showdisabled') ) { - %search = (); - } else { - %search = ( 'disabled' => '' ); - } - -%> -<%= include("/elements/header.html",'Payment gateways', menubar( +<% include("/elements/header.html",'Payment gateways', menubar( 'Main Menu' => $p, 'Agents' => $p. 'browse/agent.cgi', )) %> -<A HREF="<%= $p %>edit/payment_gateway.html"><I>Add a new payment gateway</I></A><BR><BR> +<A HREF="<% $p %>edit/payment_gateway.html"><I>Add a new payment gateway</I></A><BR><BR> -<%= $cgi->param('showdisabled') +<% $cgi->param('showdisabled') ? do { $cgi->param('showdisabled', 0); '( <a href="'. $cgi->self_url. '">hide disabled gateways</a> )'; } : do { $cgi->param('showdisabled', 1); '( <a href="'. $cgi->self_url. '">show disabled gateways</a> )'; } %> -<%= table() %> +<% table() %> <TR> - <TH COLSPAN=<%= $cgi->param('showdisabled') ? 1 : 2 %>>#</TH> + <TH COLSPAN=<% $cgi->param('showdisabled') ? 1 : 2 %>>#</TH> <TH>Gateway</TH> <TH>Username</TH> <TH>Password</TH> <TH>Action</TH> <TH>Options</TH> </TR> +% foreach my $payment_gateway ( qsearch( 'payment_gateway', \%search ) ) { -<% foreach my $payment_gateway ( qsearch( 'payment_gateway', \%search ) ) { %> <TR> - <TD><%= $payment_gateway->gatewaynum %></TD> - <% if ( !$cgi->param('showdisabled') ) { %> - <TD><%= $payment_gateway->disabled ? 'DISABLED' : '' %></TD> - <% } %> - <TD><%= $payment_gateway->gateway_module %> + <TD><% $payment_gateway->gatewaynum %></TD> +% if ( !$cgi->param('showdisabled') ) { + + <TD><% $payment_gateway->disabled ? 'DISABLED' : '' %></TD> +% } + + <TD><% $payment_gateway->gateway_module %> <FONT SIZE="-1"> - <A HREF="<%=$p%>edit/payment_gateway.html?<%= $payment_gateway->gatewaynum %>">(edit)</A> - <%= !$payment_gateway->disabled + <A HREF="<%$p%>edit/payment_gateway.html?<% $payment_gateway->gatewaynum %>">(edit)</A> + <% !$payment_gateway->disabled ? '<A HREF="'. $p. 'misc/disable-payment_gateway.cgi?'. $payment_gateway->gatewaynum.'">(disable)</A>' : '' %> </FONT> </TD> - <TD><%= $payment_gateway->gateway_username %></TD> + <TD><% $payment_gateway->gateway_username %></TD> <TD> - </TD> - <TD><%= $payment_gateway->gateway_action %></TD> + <TD><% $payment_gateway->gateway_action %></TD> <TD> <TABLE CELLSPACING=0 CELLPADDING=0> - <% my %options = $payment_gateway->options; - foreach my $option ( keys %options ) { - %> +% my %options = $payment_gateway->options; +% foreach my $option ( keys %options ) { +% + <TR> - <TH><%= $option %>:</TH> - <TD><%= $options{$option} %></TD> + <TH><% $option %>:</TH> + <TD><% $options{$option} %></TD> </TR> - <% } %> +% } + </TABLE> </TD> </TR> +% } -<% } %> </TABLE> </BODY> diff --git a/httemplate/browse/pkg_class.html b/httemplate/browse/pkg_class.html index d4f8f02a9..3ec5e559b 100644 --- a/httemplate/browse/pkg_class.html +++ b/httemplate/browse/pkg_class.html @@ -1,15 +1,16 @@ -<% - -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' ]; - -%><%= include( 'elements/browse.html', +% +% +%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' ]; +% +% +<% include( 'elements/browse.html', 'title' => 'Package classes', 'menubar' => [ 'Main menu' => $p, ], 'html_init' => $html_init, diff --git a/httemplate/browse/rate.cgi b/httemplate/browse/rate.cgi index c4ae2f081..9bdbe2d0c 100644 --- a/httemplate/browse/rate.cgi +++ b/httemplate/browse/rate.cgi @@ -1,22 +1,23 @@ -<% - -my $html_init = - 'Rate plans, regions and prefixes for VoIP and call billing.<BR><BR>'. - qq!<A HREF="${p}edit/rate.cgi"><I>Add a rate plan</I></A>!. - qq! | <A HREF="${p}edit/rate_region.cgi"><I>Add a region</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' ]; - -%><%= include( 'elements/browse.html', +% +% +%my $html_init = +% 'Rate plans, regions and prefixes for VoIP and call billing.<BR><BR>'. +% qq!<A HREF="${p}edit/rate.cgi"><I>Add a rate plan</I></A>!. +% qq! | <A HREF="${p}edit/rate_region.cgi"><I>Add a region</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' ]; +% +% +<% include( 'elements/browse.html', 'title' => 'Rate plans', 'menubar' => [ 'Main menu' => $p, ], 'html_init' => $html_init, diff --git a/httemplate/browse/router.cgi b/httemplate/browse/router.cgi index 410037d41..7309388c6 100644 --- a/httemplate/browse/router.cgi +++ b/httemplate/browse/router.cgi @@ -1,56 +1,60 @@ -<%= include("/elements/header.html",'Routers', menubar('Main Menu' => $p)) %> -<% +<% include("/elements/header.html",'Routers', menubar('Main Menu' => $p)) %> +% +% +%my @router = qsearch('router', {}); +%my $p2 = popurl(2); +% +% +% if ($cgi->param('error')) { -my @router = qsearch('router', {}); -my $p2 = popurl(2); + <FONT SIZE="+1" COLOR="#ff0000">Error: <%$cgi->param('error')%></FONT> + <BR><BR> +% } +% +%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>'; +%} +% -%> -<% if ($cgi->param('error')) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%=$cgi->param('error')%></FONT> - <BR><BR> -<% } %> - -<% -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()%> +<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, ' '; - } -%> +% 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 ROWSPAN="<%scalar(@addr_block)+1%>"> + <A HREF="<%$p2%>edit/router.cgi?<%$router->routernum%>"><%$router->routername%></A> </TD> </TR> - <% foreach my $block ( @addr_block ) { %> +% foreach my $block ( @addr_block ) { + <TR> - <TD><%=UNIVERSAL::isa($block, 'FS::addr_block') ? $block->NetAddr : ' '%></TD> + <TD><%UNIVERSAL::isa($block, 'FS::addr_block') ? $block->NetAddr : ' '%></TD> </TR> - <% } %> +% } + </TR> -<% } %> +% } + </TABLE> </BODY> </HTML> diff --git a/httemplate/browse/svc_acct_pop.cgi b/httemplate/browse/svc_acct_pop.cgi index 73de6accc..949bfa790 100755 --- a/httemplate/browse/svc_acct_pop.cgi +++ b/httemplate/browse/svc_acct_pop.cgi @@ -1,13 +1,14 @@ <!-- mason kludge --> -<% - my $accounts_sth = dbh->prepare("SELECT COUNT(*) FROM svc_acct - WHERE popnum = ? ") - or die dbh->errstr; -%> -<%= include("/elements/header.html",'Access Number Listing', menubar( 'Main Menu' => $p )) %> +% +% my $accounts_sth = dbh->prepare("SELECT COUNT(*) FROM svc_acct +% WHERE popnum = ? ") +% or die dbh->errstr; +% + +<% include("/elements/header.html",'Access Number Listing', menubar( 'Main Menu' => $p )) %> Points of Presence<BR><BR> -<A HREF="<%= $p %>edit/svc_acct_pop.cgi"><I>Add new Access Number</I></A><BR><BR> -<%= table() %> +<A HREF="<% $p %>edit/svc_acct_pop.cgi"><I>Add new Access Number</I></A><BR><BR> +<% table() %> <TR> <TH></TH> <TH>City</TH> @@ -17,43 +18,50 @@ Points of Presence<BR><BR> <TH>Local</TH> <TH>Accounts</TH> </TR> +% +%foreach my $svc_acct_pop ( sort { +% #$a->getfield('popnum') <=> $b->getfield('popnum') +% $a->state cmp $b->state || $a->city cmp $b->city +% || $a->ac <=> $b->ac || $a->exch <=> $b->exch || $a->loc <=> $b->loc +%} qsearch('svc_acct_pop',{}) ) { +% +% my $svc_acct_pop_link = $p . 'edit/svc_acct_pop.cgi?'. $svc_acct_pop->popnum; +% +% $accounts_sth->execute($svc_acct_pop->popnum) or die $accounts_sth->errstr; +% my $num_accounts = $accounts_sth->fetchrow_arrayref->[0]; +% +% my $svc_acct_link = $p. 'search/svc_acct.cgi?popnum='. $svc_acct_pop->popnum; +% +% -<% -foreach my $svc_acct_pop ( sort { - #$a->getfield('popnum') <=> $b->getfield('popnum') - $a->state cmp $b->state || $a->city cmp $b->city - || $a->ac <=> $b->ac || $a->exch <=> $b->exch || $a->loc <=> $b->loc -} qsearch('svc_acct_pop',{}) ) { - - my $svc_acct_pop_link = $p . 'edit/svc_acct_pop.cgi?'. $svc_acct_pop->popnum; - - $accounts_sth->execute($svc_acct_pop->popnum) or die $accounts_sth->errstr; - my $num_accounts = $accounts_sth->fetchrow_arrayref->[0]; - - my $svc_acct_link = $p. 'search/svc_acct.cgi?popnum='. $svc_acct_pop->popnum; - -%> <TR> - <TD><A HREF="<%= $svc_acct_pop_link %>"> - <%= $svc_acct_pop->popnum %></A></TD> - <TD><A HREF="<%= $svc_acct_pop_link %>"> - <%= $svc_acct_pop->city %></A></TD> - <TD><A HREF="<%= $svc_acct_pop_link %>"> - <%= $svc_acct_pop->state %></A></TD> - <TD><A HREF="<%= $svc_acct_pop_link %>"> - <%= $svc_acct_pop->ac %></A></TD> - <TD><A HREF="<%= $svc_acct_pop_link %>"> - <%= $svc_acct_pop->exch %></A></TD> - <TD><A HREF="<%= $svc_acct_pop_link %>"> - <%= $svc_acct_pop->loc %></A></TD> + <TD><A HREF="<% $svc_acct_pop_link %>"> + <% $svc_acct_pop->popnum %></A></TD> + <TD><A HREF="<% $svc_acct_pop_link %>"> + <% $svc_acct_pop->city %></A></TD> + <TD><A HREF="<% $svc_acct_pop_link %>"> + <% $svc_acct_pop->state %></A></TD> + <TD><A HREF="<% $svc_acct_pop_link %>"> + <% $svc_acct_pop->ac %></A></TD> + <TD><A HREF="<% $svc_acct_pop_link %>"> + <% $svc_acct_pop->exch %></A></TD> + <TD><A HREF="<% $svc_acct_pop_link %>"> + <% $svc_acct_pop->loc %></A></TD> <TD> - <FONT COLOR="#00CC00"><B><%= $num_accounts %></B></FONT> - <% if ( $num_accounts ) { %><A HREF="<%= $svc_acct_link %>"><% } %> + <FONT COLOR="#00CC00"><B><% $num_accounts %></B></FONT> +% if ( $num_accounts ) { +<A HREF="<% $svc_acct_link %>"> +% } + active - <% if ( $num_accounts ) { %></A><% } %> +% if ( $num_accounts ) { +</A> +% } + </TD> </TR> -<% } %> +% } + <TR> </TR> diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index 259713260..fe04b324c 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -1,51 +1,52 @@ -<% - my $conf = new FS::Conf; - $FS::Conf::DEBUG = 1; - my @config_items = $conf->config_items; +% +% my $conf = new FS::Conf; +% $FS::Conf::DEBUG = 1; +% my @config_items = $conf->config_items; +% +% foreach my $i ( @config_items ) { +% my @touch = (); +% my @delete = (); +% my $n = 0; +% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { +% if ( $type eq '' ) { +% } elsif ( $type eq 'textarea' ) { +% if ( $cgi->param($i->key. $n) ne '' ) { +% my $value = $cgi->param($i->key. $n); +% $value =~ s/\r\n/\n/g; #browsers? +% $conf->set($i->key, $value); +% } else { +% $conf->delete($i->key); +% } +% } elsif ( $type eq 'checkbox' ) { +%# if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) { +% if ( defined $cgi->param($i->key. $n) ) { +% #$conf->touch($i->key); +% push @touch, $i->key; +% } else { +% #$conf->delete($i->key); +% push @delete, $i->key; +% } +% } elsif ( $type eq 'text' || $type eq 'select' ) { +% if ( $cgi->param($i->key. $n) ne '' ) { +% $conf->set($i->key, $cgi->param($i->key. $n)); +% } else { +% $conf->delete($i->key); +% } +% } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) { +% if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) { +% $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} )); +% } else { +% $conf->delete($i->key); +% } +% } else { +% } +% $n++; +% } +% # warn @touch; +% $conf->touch($_) foreach @touch; +% $conf->delete($_) foreach @delete; +% } +% +% - foreach my $i ( @config_items ) { - my @touch = (); - my @delete = (); - my $n = 0; - foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { - if ( $type eq '' ) { - } elsif ( $type eq 'textarea' ) { - if ( $cgi->param($i->key. $n) ne '' ) { - my $value = $cgi->param($i->key. $n); - $value =~ s/\r\n/\n/g; #browsers? - $conf->set($i->key, $value); - } else { - $conf->delete($i->key); - } - } elsif ( $type eq 'checkbox' ) { -# if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) { - if ( defined $cgi->param($i->key. $n) ) { - #$conf->touch($i->key); - push @touch, $i->key; - } else { - #$conf->delete($i->key); - push @delete, $i->key; - } - } elsif ( $type eq 'text' || $type eq 'select' ) { - if ( $cgi->param($i->key. $n) ne '' ) { - $conf->set($i->key, $cgi->param($i->key. $n)); - } else { - $conf->delete($i->key); - } - } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) { - if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) { - $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} )); - } else { - $conf->delete($i->key); - } - } else { - } - $n++; - } - # warn @touch; - $conf->touch($_) foreach @touch; - $conf->delete($_) foreach @delete; - } - -%> -<%= $cgi->redirect("config-view.cgi") %> +<% $cgi->redirect("config-view.cgi") %> diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index bf51f1509..ff7913d78 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -1,80 +1,92 @@ <!-- mason kludge --> -<%= include("/elements/header.html",'View Configuration', menubar( 'Main Menu' => $p, +<% include("/elements/header.html",'View Configuration', menubar( 'Main Menu' => $p, 'Edit Configuration' => 'config.cgi' ) ) %> +% my $conf = new FS::Conf; my @config_items = $conf->config_items; +% foreach my $section ( qw(required billing username password UI session +% shell BIND +% ), +% '', 'deprecated') { -<% my $conf = new FS::Conf; my @config_items = $conf->config_items; %> - -<% foreach my $section ( qw(required billing username password UI session - shell BIND - ), - '', 'deprecated') { %> - <A NAME="<%= $section || 'unclassified' %>"></A> + <A NAME="<% $section || 'unclassified' %>"></A> <FONT SIZE="-2"> - <% foreach my $nav_section ( qw(required billing username password UI session - shell BIND - ), - '', 'deprecated') { %> - <% if ( $section eq $nav_section ) { %> - [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>] - <% } else { %> - [<A HREF="#<%= $nav_section || 'unclassified' %>"><%= ucfirst($nav_section || 'unclassified') %></A>] - <% } %> - <% } %> +% foreach my $nav_section ( qw(required billing username password UI session +% shell BIND +% ), +% '', 'deprecated') { +% if ( $section eq $nav_section ) { + + [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>] +% } else { + + [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>] +% } +% } + </FONT><BR> - <%= table("#cccccc", 2) %> + <% table("#cccccc", 2) %> <tr> <th colspan="2" bgcolor="#dcdcdc"> - <%= ucfirst($section || 'unclassified') %> configuration options + <% ucfirst($section || 'unclassified') %> configuration options </th> </tr> - <% foreach my $i (grep $_->section eq $section, @config_items) { %> +% foreach my $i (grep $_->section eq $section, @config_items) { + <tr> - <td><a name="<%= $i->key %>"> - <b><%= $i->key %></b> - <%= $i->description %> + <td><a name="<% $i->key %>"> + <b><% $i->key %></b> - <% $i->description %> </a></td> <td><table border=0> - <% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { - my $n = 0; %> - <% if ( $type eq '' ) { %> +% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { +% my $n = 0; +% if ( $type eq '' ) { + <tr> <td><font color="#ff0000">no type</font></td> </tr> - <% } elsif ( $type eq 'textarea' - || $type eq 'editlist' - || $type eq 'selectmultiple' ) { %> +% } elsif ( $type eq 'textarea' +% || $type eq 'editlist' +% || $type eq 'selectmultiple' ) { + <tr> <td bgcolor="#ffffff"> <pre> -<%= encode_entities(join("\n", $conf->config($i->key) ) ) %> +<% encode_entities(join("\n", $conf->config($i->key) ) ) %> </pre> </td> </tr> - <% } elsif ( $type eq 'checkbox' ) { %> +% } elsif ( $type eq 'checkbox' ) { + <tr> - <td bgcolor="#<%= $conf->exists($i->key) ? '00ff00">YES' : 'ff0000">NO' %></td> + <td bgcolor="#<% $conf->exists($i->key) ? '00ff00">YES' : 'ff0000">NO' %></td> </tr> - <% } elsif ( $type eq 'text' || $type eq 'select' ) { %> +% } elsif ( $type eq 'text' || $type eq 'select' ) { + <tr> <td bgcolor="#ffffff"> - <%= $conf->exists($i->key) ? $conf->config($i->key) : '' %> + <% $conf->exists($i->key) ? $conf->config($i->key) : '' %> </td></tr> - <% } elsif ( $type eq 'select-sub' ) { %> +% } elsif ( $type eq 'select-sub' ) { + <tr> <td bgcolor="#ffffff"> - <%= $conf->config($i->key) %>: - <%= &{ $i->option_sub }( $conf->config($i->key) ) %> + <% $conf->config($i->key) %>: + <% &{ $i->option_sub }( $conf->config($i->key) ) %> </td> </tr> - <% } else { %> +% } else { + <tr><td> - <font color="#ff0000">unknown type <%= $type %></font> + <font color="#ff0000">unknown type <% $type %></font> </td></tr> - <% } %> - <% $n++; } %> +% } +% $n++; } + </table></td> </tr> - <% } %> +% } + </table><br><br> -<% } %> +% } + </body></html> diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi index cf228dba5..369314d98 100644 --- a/httemplate/config/config.cgi +++ b/httemplate/config/config.cgi @@ -1,5 +1,5 @@ <!-- mason kludge --> -<%= include("/elements/header.html",'Edit Configuration', menubar( 'Main Menu' => $p ) ) %> +<% include("/elements/header.html",'Edit Configuration', menubar( 'Main Menu' => $p ) ) %> <SCRIPT> var gSafeOnload = new Array(); var gSafeOnsubmit = new Array(); @@ -19,218 +19,241 @@ function SafeOnsubmit() { gSafeOnsubmit[i](); } </SCRIPT> +% my $conf = new FS::Conf; my @config_items = $conf->config_items; -<% my $conf = new FS::Conf; my @config_items = $conf->config_items; %> <form name="OneTrueForm" action="config-process.cgi" METHOD="POST" onSubmit="SafeOnsubmit()"> +% foreach my $section ( qw(required billing username password UI session +% shell BIND +% ), +% '', 'deprecated') { -<% foreach my $section ( qw(required billing username password UI session - shell BIND - ), - '', 'deprecated') { %> - <A NAME="<%= $section || 'unclassified' %>"></A> + <A NAME="<% $section || 'unclassified' %>"></A> <FONT SIZE="-2"> - <% foreach my $nav_section ( qw(required billing username password UI session - shell BIND - ), - '', 'deprecated') { %> - <% if ( $section eq $nav_section ) { %> - [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>] - <% } else { %> - [<A HREF="#<%= $nav_section || 'unclassified' %>"><%= ucfirst($nav_section || 'unclassified') %></A>] - <% } %> - <% } %> +% foreach my $nav_section ( qw(required billing username password UI session +% shell BIND +% ), +% '', 'deprecated') { +% if ( $section eq $nav_section ) { + + [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>] +% } else { + + [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>] +% } +% } + </FONT><BR> - <%= table("#cccccc", 2) %> + <% table("#cccccc", 2) %> <tr> <th colspan="2" bgcolor="#dcdcdc"> - <%= ucfirst($section || 'unclassified') %> configuration options + <% ucfirst($section || 'unclassified') %> configuration options </th> </tr> - <% foreach my $i (grep $_->section eq $section, @config_items) { %> +% foreach my $i (grep $_->section eq $section, @config_items) { + <tr> <td> - <% my $n = 0; - foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { - #warn $i->key unless defined($type); - %> - <% if ( $type eq '' ) { %> +% my $n = 0; +% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { +% #warn $i->key unless defined($type); +% +% if ( $type eq '' ) { + <font color="#ff0000">no type</font> +% } elsif ( $type eq 'textarea' ) { - <% } elsif ( $type eq 'textarea' ) { %> - <textarea name="<%= $i->key. $n %>" rows=5><%= "\n". join("\n", $conf->config($i->key) ) %></textarea> + <textarea name="<% $i->key. $n %>" rows=5><% "\n". join("\n", $conf->config($i->key) ) %></textarea> +% } elsif ( $type eq 'checkbox' ) { - <% } elsif ( $type eq 'checkbox' ) { %> - <input name="<%= $i->key. $n %>" type="checkbox" value="1"<%= $conf->exists($i->key) ? ' CHECKED' : '' %>> + <input name="<% $i->key. $n %>" type="checkbox" value="1"<% $conf->exists($i->key) ? ' CHECKED' : '' %>> +% } elsif ( $type eq 'text' ) { - <% } elsif ( $type eq 'text' ) { %> - <input name="<%= $i->key. $n %>" type="<%= $type %>" value="<%= $conf->exists($i->key) ? $conf->config($i->key) : '' %>"> + <input name="<% $i->key. $n %>" type="<% $type %>" value="<% $conf->exists($i->key) ? $conf->config($i->key) : '' %>"> +% } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) { - <% } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) { %> - <select name="<%= $i->key. $n %>" <%= $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>> - <% - my %hash = (); - if ( $i->select_enum ) { - tie %hash, 'Tie::IxHash', - '' => '', map { $_ => $_ } @{ $i->select_enum }; - } elsif ( $i->select_hash ) { - if ( ref($i->select_hash) eq 'ARRAY' ) { - tie %hash, 'Tie::IxHash', - '' => '', @{ $i->select_hash }; - } else { - tie %hash, 'Tie::IxHash', - '' => '', %{ $i->select_hash }; - } - } else { - %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $i->key. '"' ); - } - - my %saw = (); - foreach my $value ( keys %hash ) { - local($^W)=0; next if $saw{$value}++; - my $label = $hash{$value}; - %> - - <option value="<%= $value %>"<%= $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><%= $label %> - - <% } %> - - <% my $curvalue = $conf->config($i->key); - if ( $conf->exists($i->key) && $curvalue - && ! $hash{$curvalue} - ) { - %> + <select name="<% $i->key. $n %>" <% $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>> +% +% my %hash = (); +% if ( $i->select_enum ) { +% tie %hash, 'Tie::IxHash', +% '' => '', map { $_ => $_ } @{ $i->select_enum }; +% } elsif ( $i->select_hash ) { +% if ( ref($i->select_hash) eq 'ARRAY' ) { +% tie %hash, 'Tie::IxHash', +% '' => '', @{ $i->select_hash }; +% } else { +% tie %hash, 'Tie::IxHash', +% '' => '', %{ $i->select_hash }; +% } +% } else { +% %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $i->key. '"' ); +% } +% +% my %saw = (); +% foreach my $value ( keys %hash ) { +% local($^W)=0; next if $saw{$value}++; +% my $label = $hash{$value}; +% + + + <option value="<% $value %>"<% $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><% $label %> +% } +% my $curvalue = $conf->config($i->key); +% if ( $conf->exists($i->key) && $curvalue +% && ! $hash{$curvalue} +% ) { +% + - <option value="<%= $conf->config($i->key) %>" SELECTED><%= exists( $hash{ $conf->config($i->key) } ) ? $hash{ $conf->config($i->key) } : $conf->config($i->key) %> + <option value="<% $conf->config($i->key) %>" SELECTED><% exists( $hash{ $conf->config($i->key) } ) ? $hash{ $conf->config($i->key) } : $conf->config($i->key) %> +% } - <% } %> </select> +% } elsif ( $type eq 'select-sub' ) { - <% } elsif ( $type eq 'select-sub' ) { %> - <select name="<%= $i->key. $n %>"> + <select name="<% $i->key. $n %>"> <option value=""> - <% my %options = &{$i->options_sub}; - my @options = sort { $a <=> $b } keys %options; - my %saw; - foreach my $value ( @options ) { - local($^W)=0; next if $saw{$value}++; - %> - <option value="<%= $value %>"<%= $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><%= $value %>: <%= $options{$value} %> - <% } %> - <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! exists $options{$conf->config($i->key)} ) { %> - <option value=<%= $conf->config($i->key) %> SELECTED><%= $conf->config($i->key) %>: <%= &{ $i->option_sub }( $conf->config($i->key) ) %> - <% } %> +% my %options = &{$i->options_sub}; +% my @options = sort { $a <=> $b } keys %options; +% my %saw; +% foreach my $value ( @options ) { +% local($^W)=0; next if $saw{$value}++; +% + + <option value="<% $value %>"<% $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><% $value %>: <% $options{$value} %> +% } +% if ( $conf->exists($i->key) && $conf->config($i->key) && ! exists $options{$conf->config($i->key)} ) { + + <option value=<% $conf->config($i->key) %> SELECTED><% $conf->config($i->key) %>: <% &{ $i->option_sub }( $conf->config($i->key) ) %> +% } + </select> +% } elsif ( $type eq 'editlist' ) { - <% } elsif ( $type eq 'editlist' ) { %> <script> - function doremove<%= $i->key. $n %>() { - fromObject = document.OneTrueForm.<%= $i->key. $n %>; + function doremove<% $i->key. $n %>() { + fromObject = document.OneTrueForm.<% $i->key. $n %>; for (var i=fromObject.options.length-1;i>-1;i--) { if (fromObject.options[i].selected) - deleteOption<%= $i->key. $n %>(fromObject,i); + deleteOption<% $i->key. $n %>(fromObject,i); } } - function deleteOption<%= $i->key. $n %>(object,index) { + function deleteOption<% $i->key. $n %>(object,index) { object.options[index] = null; } - function selectall<%= $i->key. $n %>() { - fromObject = document.OneTrueForm.<%= $i->key. $n %>; + function selectall<% $i->key. $n %>() { + fromObject = document.OneTrueForm.<% $i->key. $n %>; for (var i=fromObject.options.length-1;i>-1;i--) { fromObject.options[i].selected = true; } } - function doadd<%= $i->key. $n %>(object) { + function doadd<% $i->key. $n %>(object) { var myvalue = ""; - <% if ( defined($i->editlist_parts) ) { %> +% if ( defined($i->editlist_parts) ) { +% foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) { - <% foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) { %> if ( myvalue != "" ) { myvalue = myvalue + " "; } - <% if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) { %> - myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.options[object.add<%= $i->key. $n . "_$pnum" %>.selectedIndex].value; +% if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) { + + myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.options[object.add<% $i->key. $n . "_$pnum" %>.selectedIndex].value; <!-- #RESET SELECT?? maybe not... --> - <% } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) { %> - myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value; - <% } else { %> - myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value; - object.add<%= $i->key. $n. "_$pnum" %>.value = ""; - <% } %> - - - <% } %> - <% } else { %> - myvalue = object.add<%= $i->key. $n. "_1" %>.value; - <% } %> +% } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) { + + myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.value; +% } else { + + myvalue = myvalue + object.add<% $i->key. $n . "_$pnum" %>.value; + object.add<% $i->key. $n. "_$pnum" %>.value = ""; +% } +% } +% } else { + + myvalue = object.add<% $i->key. $n. "_1" %>.value; +% } + var optionName = new Option(myvalue, myvalue); - var length = object.<%= $i->key. $n %>.length; - object.<%= $i->key. $n %>.options[length] = optionName; + var length = object.<% $i->key. $n %>.length; + object.<% $i->key. $n %>.options[length] = optionName; } </script> - <select multiple size=5 name="<%= $i->key. $n %>"> + <select multiple size=5 name="<% $i->key. $n %>"> <option selected>----------------------------------------------------------------</option> - <% foreach my $line ( $conf->config($i->key) ) { %> - <option value="<%= $line %>"><%= $line %></option> - <% } %> +% foreach my $line ( $conf->config($i->key) ) { + + <option value="<% $line %>"><% $line %></option> +% } + </select><br> - <input type="button" value="remove selected" onClick="doremove<%= $i->key. $n %>()"> - <script>SafeAddOnLoad(doremove<%= $i->key. $n %>); - SafeAddOnSubmit(selectall<%= $i->key. $n %>);</script> + <input type="button" value="remove selected" onClick="doremove<% $i->key. $n %>()"> + <script>SafeAddOnLoad(doremove<% $i->key. $n %>); + SafeAddOnSubmit(selectall<% $i->key. $n %>);</script> <br> - <%= itable() %><tr> - <% if ( defined $i->editlist_parts ) { %> - <% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { %> + <% itable() %><tr> +% if ( defined $i->editlist_parts ) { +% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { + <td> - <% if ( $part->{type} eq 'text' ) { %> - <input type="text" name="add<%= $i->key. $n."_$pnum" %>"> - <% } elsif ( $part->{type} eq 'immutable' ) { %> - <%= $part->{value} %><input type="hidden" name="add<%= $i->key. $n. "_$pnum" %>" value="<%= $part->{value} %>"> - <% } elsif ( $part->{type} eq 'select' ) { %> - <select name="add<%= $i->key. $n. "_$pnum" %>"> - <% foreach my $key ( keys %{$part->{select_enum}} ) { %> - <option value="<%= $key %>"><%= $part->{select_enum}{$key} %></option> - <% } %> +% if ( $part->{type} eq 'text' ) { + + <input type="text" name="add<% $i->key. $n."_$pnum" %>"> +% } elsif ( $part->{type} eq 'immutable' ) { + + <% $part->{value} %><input type="hidden" name="add<% $i->key. $n. "_$pnum" %>" value="<% $part->{value} %>"> +% } elsif ( $part->{type} eq 'select' ) { + + <select name="add<% $i->key. $n. "_$pnum" %>"> +% foreach my $key ( keys %{$part->{select_enum}} ) { + + <option value="<% $key %>"><% $part->{select_enum}{$key} %></option> +% } + </select> - <% } else { %> - <font color="#ff0000">unknown type <%= $part->type %></font> - <% } %> +% } else { + + <font color="#ff0000">unknown type <% $part->type %></font> +% } + </td> - <% $pnum++; } %> - <% } else { %> - <td><input type="text" name="add<%= $i->key. $n %>_0"></td> - <% } %> - <td><input type="button" value="add" onClick="doadd<%= $i->key. $n %>(this.form)"></td> - </tr></table> +% $pnum++; } +% } else { - <% } else { %> + <td><input type="text" name="add<% $i->key. $n %>_0"></td> +% } + + <td><input type="button" value="add" onClick="doadd<% $i->key. $n %>(this.form)"></td> + </tr></table> +% } else { - <font color="#ff0000">unknown type <%= $type %></font> - <% } %> + <font color="#ff0000">unknown type <% $type %></font> +% } +% $n++; } - <% $n++; } %> </td> - <td><a name="<%= $i->key %>"> - <b><%= $i->key %></b> - <%= $i->description %> + <td><a name="<% $i->key %>"> + <b><% $i->key %></b> - <% $i->description %> </a></td> </tr> - <% } %> +% } + </table><br> You may need to restart Apache and/or freeside-queued for configuration changes to take effect.<br> <input type="submit" value="Apply changes"><br><br> +% } -<% } %> </form> diff --git a/httemplate/docs/trouble.html b/httemplate/docs/trouble.html deleted file mode 100755 index fce743928..000000000 --- a/httemplate/docs/trouble.html +++ /dev/null @@ -1,26 +0,0 @@ -<head> - <title>Troubleshooting</title> -</head> -<body> - <h1>Troubleshooting</h1> - <ul> - <li>When troubleshooting the web interface, helpful information is often in your web server's error log. - <li>If bin/svc_acct.import fails with an "Out of memory!" error using MySQL, upgrede MySQL and recompile the Perl DBD. There was a memory leak in some older versions of MySQL. - <li>If you get tons of errors in your web server's error log like this: -<pre> -Ambiguous use of value => resolved to "value" => -at /usr/lib/perl5/site_perl/File/CounterFile.pm line 132. -</pre> - This clutters up your log files but is otherwise harmless. Upgrade to the latest File::CounterFile. - <li>If you get errors like this: -<pre> -UID.pm: Can't open /var/spool/freeside/conf/secrets: Permission denied -at <i>/your/path</i>/site_perl/FS/UID.pm line 26. -BEGIN failed--compilation aborted at -<i>/your/path</i>/edit/process/part_svc.cgi line 15. -</pre> - Then the scripts are not running as the freeside freeside user. See -the <a href="install.html">New Installation</a> section of the documentation. - <li>If you receive `can not connect to server' errors using MySQL on a system that doesn't support native threading, you may need to specify the full hostname in your DBI datasource. See the <a href="http://www.mysql.com/Manual_chapter/manual_Problems.html#Can_not_connect_to_server">MySQL documentation</a>, DBI manpage and the DBD::mysql manpage for details. - </ul> -</body> diff --git a/httemplate/edit/REAL_cust_pkg.cgi b/httemplate/edit/REAL_cust_pkg.cgi index 1eefcfea0..69bbb9b22 100755 --- a/httemplate/edit/REAL_cust_pkg.cgi +++ b/httemplate/edit/REAL_cust_pkg.cgi @@ -1,177 +1,183 @@ -<% - -my $error =''; -my $pkgnum = ''; -if ( $cgi->param('error') ) { - $error = $cgi->param('error'); - $pkgnum = $cgi->param('pkgnum'); - if ( $error eq '_bill_areyousure' ) { - my $bill = $cgi->param('bill'); - $error = "You are attempting to set the next bill date to $bill, which is - in the past. This will charge the customer for the interval - from $bill until now. Are you sure you want to do this? ". - '<INPUT TYPE="checkbox" NAME="bill_areyousure" VALUE="1">'; - } -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/ or die "no pkgnum"; - $pkgnum = $1; -} - -#get package record -my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); -die "No package!" unless $cust_pkg; -my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')}); - -if ( $error ) { - #$cust_pkg->$_(str2time($cgi->param($_)) foreach qw(setup bill); - $cust_pkg->setup(str2time($cgi->param('setup'))); - $cust_pkg->bill(str2time($cgi->param('bill'))); - $cust_pkg->last_bill(str2time($cgi->param('last_bill'))); -} - -#my $custnum = $cust_pkg->getfield('custnum'); -%> - -<%= include("/elements/header.html",'Customer package - Edit dates') %> -<% -#, menubar( -# "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum", -# 'Main Menu' => popurl(2) -#)); -%> +% +% +%my $error =''; +%my $pkgnum = ''; +%if ( $cgi->param('error') ) { +% $error = $cgi->param('error'); +% $pkgnum = $cgi->param('pkgnum'); +% if ( $error eq '_bill_areyousure' ) { +% my $bill = $cgi->param('bill'); +% $error = "You are attempting to set the next bill date to $bill, which is +% in the past. This will charge the customer for the interval +% from $bill until now. Are you sure you want to do this? ". +% '<INPUT TYPE="checkbox" NAME="bill_areyousure" VALUE="1">'; +% } +%} else { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/ or die "no pkgnum"; +% $pkgnum = $1; +%} +% +%#get package record +%my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +%die "No package!" unless $cust_pkg; +%my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')}); +% +%if ( $error ) { +% #$cust_pkg->$_(str2time($cgi->param($_)) foreach qw(setup bill); +% $cust_pkg->setup(str2time($cgi->param('setup'))); +% $cust_pkg->bill(str2time($cgi->param('bill'))); +% $cust_pkg->last_bill(str2time($cgi->param('last_bill'))); +%} +% +%#my $custnum = $cust_pkg->getfield('custnum'); +% + + +<% include("/elements/header.html",'Customer package - Edit dates') %> +% +%#, menubar( +%# "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum", +%# 'Main Menu' => popurl(2) +%#)); +% + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> +% +% +%#print info +%my($susp,$cancel,$expire)=( +% $cust_pkg->getfield('susp'), +% $cust_pkg->getfield('cancel'), +% $cust_pkg->getfield('expire'), +%); +%my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment')); +%my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill')); +%my $otaker = $cust_pkg->getfield('otaker'); +% +% -<% - -#print info -my($susp,$cancel,$expire)=( - $cust_pkg->getfield('susp'), - $cust_pkg->getfield('cancel'), - $cust_pkg->getfield('expire'), -); -my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment')); -my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill')); -my $otaker = $cust_pkg->getfield('otaker'); - -%> <FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> - -<% if ( $error ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $error %></FONT> -<% } %> - -<% - -#my $format = "%c %z (%Z)"; -my $format = "%m/%d/%Y %T %z (%Z)"; - -#false laziness w/view/cust_main/packages.html -#my( $billed_or_prepaid, -my( $last_bill_or_renewed, $next_bill_or_prepaid_until ); -unless ( $part_pkg->is_prepaid ) { - #$billed_or_prepaid = 'billed'; - $last_bill_or_renewed = 'Last bill'; - $next_bill_or_prepaid_until = 'Next bill'; -} else { - #$billed_or_prepaid = 'prepaid'; - $last_bill_or_renewed = 'Renewed'; - $next_bill_or_prepaid_until = 'Prepaid until'; -} - -%> - -<%= ntable("#cccccc",2) %> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>"> +% if ( $error ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT> +% } +% +% +%#my $format = "%c %z (%Z)"; +%my $format = "%m/%d/%Y %T %z (%Z)"; +% +%#false laziness w/view/cust_main/packages.html +%#my( $billed_or_prepaid, +%my( $last_bill_or_renewed, $next_bill_or_prepaid_until ); +%unless ( $part_pkg->is_prepaid ) { +% #$billed_or_prepaid = 'billed'; +% $last_bill_or_renewed = 'Last bill'; +% $next_bill_or_prepaid_until = 'Next bill'; +%} else { +% #$billed_or_prepaid = 'prepaid'; +% $last_bill_or_renewed = 'Renewed'; +% $next_bill_or_prepaid_until = 'Prepaid until'; +%} +% +% + + +<% ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Package number</TD> - <TD BGCOLOR="#ffffff"><%= $pkgnum %></TD> + <TD BGCOLOR="#ffffff"><% $pkgnum %></TD> </TR> <TR> <TD ALIGN="right">Package</TD> - <TD BGCOLOR="#ffffff"><%= $pkg %></TD> + <TD BGCOLOR="#ffffff"><% $pkg %></TD> </TR> <TR> <TD ALIGN="right">Comment</TD> - <TD BGCOLOR="#ffffff"><%= $comment %></TD> + <TD BGCOLOR="#ffffff"><% $comment %></TD> </TR> <TR> <TD ALIGN="right">Order taker</TD> - <TD BGCOLOR="#ffffff"><%= $otaker %></TD> + <TD BGCOLOR="#ffffff"><% $otaker %></TD> </TR> <TR> <TD ALIGN="right">Setup date</TD> <TD> - <INPUT TYPE="text" NAME="setup" SIZE=32 ID="setup_text" VALUE="<%= ( $setup ? time2str($format, $setup) : "" ) %>"> + <INPUT TYPE="text" NAME="setup" SIZE=32 ID="setup_text" VALUE="<% ( $setup ? time2str($format, $setup) : "" ) %>"> <IMG SRC="../images/calendar.png" ID="setup_button" STYLE="cursor: pointer" TITLE="Select date"> </TD> </TR> <TR> - <TD ALIGN="right"><%= $last_bill_or_renewed %> date</TD> + <TD ALIGN="right"><% $last_bill_or_renewed %> date</TD> <TD> - <INPUT TYPE="text" NAME="last_bill" SIZE=32 ID="last_bill_text" VALUE="<%= ( $cust_pkg->last_bill ? time2str($format, $cust_pkg->last_bill) : "" ) %>"> + <INPUT TYPE="text" NAME="last_bill" SIZE=32 ID="last_bill_text" VALUE="<% ( $cust_pkg->last_bill ? time2str($format, $cust_pkg->last_bill) : "" ) %>"> <IMG SRC="../images/calendar.png" ID="last_bill_button" STYLE="cursor: pointer" TITLE="Select date"> </TD> </TR> <TR> - <TD ALIGN="right"><%= $next_bill_or_prepaid_until %> date</TD> + <TD ALIGN="right"><% $next_bill_or_prepaid_until %> date</TD> <TD> - <INPUT TYPE="text" NAME="bill" SIZE=32 ID="bill_text" VALUE="<%= ( $bill ? time2str($format, $bill) : "" ) %>"> + <INPUT TYPE="text" NAME="bill" SIZE=32 ID="bill_text" VALUE="<% ( $bill ? time2str($format, $bill) : "" ) %>"> <IMG SRC="../images/calendar.png" ID="bill_button" STYLE="cursor: pointer" TITLE="Select date"> </TD> </TR> +% if ( $susp ) { - <% if ( $susp ) { %> <TR> <TD ALIGN="right">Suspension date</TD> - <TD BGCOLOR="#ffffff"><%= time2str($format, $susp) %></TD> + <TD BGCOLOR="#ffffff"><% time2str($format, $susp) %></TD> </TR> - <% } %> +% } + <TR> <TD ALIGN="right">Expiration date</TD> <TD> - <INPUT TYPE="text" NAME="expire" SIZE=32 ID="expire_text" VALUE="<%= ( $expire ? time2str($format, $expire) : "" ) %>"> + <INPUT TYPE="text" NAME="expire" SIZE=32 ID="expire_text" VALUE="<% ( $expire ? time2str($format, $expire) : "" ) %>"> <IMG SRC="../images/calendar.png" ID="expire_button" STYLE="cursor: pointer" TITLE="Select date"> <BR><FONT SIZE=-1>(will <b>cancel</b> this package when the date is reached)</FONT> </TD> </TR> +% if ( $cancel ) { - <% if ( $cancel ) { %> <TR> <TD ALIGN="right">Cancellation date</TD> - <TD BGCOLOR="#ffffff"><%= time2str($format, $cancel) %></TD> + <TD BGCOLOR="#ffffff"><% time2str($format, $cancel) %></TD> </TR> - <% } %> +% } + </TABLE> <SCRIPT TYPE="text/javascript"> -<% - my @cal = qw( setup bill expire ); - push @cal, 'last_bill' - if $cust_pkg->dbdef_table->column('last_bill'); - foreach my $cal (@cal) { -%> +% +% my @cal = qw( setup bill expire ); +% push @cal, 'last_bill' +% if $cust_pkg->dbdef_table->column('last_bill'); +% foreach my $cal (@cal) { +% + Calendar.setup({ - inputField: "<%= $cal %>_text", + inputField: "<% $cal %>_text", ifFormat: "%m/%d/%Y", - button: "<%= $cal %>_button", + button: "<% $cal %>_button", align: "BR" }); -<% } %> +% } + </SCRIPT> <BR><INPUT TYPE="submit" VALUE="Apply Changes"> </FORM> diff --git a/httemplate/edit/access_group.html b/httemplate/edit/access_group.html index d7f7667f4..d447512c2 100644 --- a/httemplate/edit/access_group.html +++ b/httemplate/edit/access_group.html @@ -1,4 +1,4 @@ -<%= include( 'elements/edit.html', +<% include( 'elements/edit.html', 'name' => 'Internal Access Group', 'table' => 'access_group', 'labels' => { diff --git a/httemplate/edit/access_user.html b/httemplate/edit/access_user.html index fb2a97196..df580a20d 100644 --- a/httemplate/edit/access_user.html +++ b/httemplate/edit/access_user.html @@ -1,4 +1,4 @@ -<%= include( 'elements/edit.html', +<% include( 'elements/edit.html', 'name' => 'Internal User', 'table' => 'access_user', 'fields' => [ diff --git a/httemplate/edit/agent.cgi b/httemplate/edit/agent.cgi index 40115a932..ce514a680 100755 --- a/httemplate/edit/agent.cgi +++ b/httemplate/edit/agent.cgi @@ -1,109 +1,115 @@ -<% - -my $agent; -if ( $cgi->param('error') ) { - $agent = new FS::agent ( { - map { $_, scalar($cgi->param($_)) } fields('agent') - } ); -} elsif ( $cgi->keywords ) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $agent = qsearchs( 'agent', { 'agentnum' => $1 } ); -} else { #adding - $agent = new FS::agent {}; -} -my $action = $agent->agentnum ? 'Edit' : 'Add'; -my $hashref = $agent->hashref; - -my $conf = new FS::Conf; - -%> - -<%= include("/elements/header.html","$action Agent", menubar( +% +% +%my $agent; +%if ( $cgi->param('error') ) { +% $agent = new FS::agent ( { +% map { $_, scalar($cgi->param($_)) } fields('agent') +% } ); +%} elsif ( $cgi->keywords ) { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $agent = qsearchs( 'agent', { 'agentnum' => $1 } ); +%} else { #adding +% $agent = new FS::agent {}; +%} +%my $action = $agent->agentnum ? 'Edit' : 'Add'; +%my $hashref = $agent->hashref; +% +%my $conf = new FS::Conf; +% +% + + +<% include("/elements/header.html","$action Agent", menubar( 'Main Menu' => $p, 'View all agents' => $p. 'browse/agent.cgi', )) %> +% if ( $cgi->param('error') ) { + +<FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> +% } -<% if ( $cgi->param('error') ) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> -<FORM ACTION="<%=popurl(1)%>process/agent.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $hashref->{agentnum} %>"> -Agent #<%= $hashref->{agentnum} ? $hashref->{agentnum} : "(NEW)" %> +<FORM ACTION="<%popurl(1)%>process/agent.cgi" METHOD=POST> +<INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $hashref->{agentnum} %>"> +Agent #<% $hashref->{agentnum} ? $hashref->{agentnum} : "(NEW)" %> -<%= &ntable("#cccccc", 2, '') %> +<% &ntable("#cccccc", 2, '') %> <TR> <TH ALIGN="right">Agent</TH> - <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<%= $hashref->{agent} %>"></TD> + <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<% $hashref->{agent} %>"></TD> </TR> <TR> <TH ALIGN="right">Agent type</TH> <TD><SELECT NAME="typenum" SIZE=1> - - <% foreach my $agent_type (qsearch('agent_type',{})) { %> - <OPTION VALUE="<%= $agent_type->typenum %>"<%= ( $hashref->{typenum} && ( $hashref->{typenum} == $agent_type->typenum ) ) ? ' SELECTED' : '' %>> - <%= $agent_type->getfield('typenum') %>: <%= $agent_type->getfield('atype') %> - <% } %> +% foreach my $agent_type (qsearch('agent_type',{})) { + + <OPTION VALUE="<% $agent_type->typenum %>"<% ( $hashref->{typenum} && ( $hashref->{typenum} == $agent_type->typenum ) ) ? ' SELECTED' : '' %>> + <% $agent_type->getfield('typenum') %>: <% $agent_type->getfield('atype') %> +% } + </SELECT></TD> </TR> <TR> <TD ALIGN="right">Disable</TD> - <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>></TD> + <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>></TD> </TR> <TR> <TD ALIGN="right"><!--Frequency--></TD> - <TD><INPUT TYPE="hidden" NAME="freq" VALUE="<%= $hashref->{freq} %>"></TD> + <TD><INPUT TYPE="hidden" NAME="freq" VALUE="<% $hashref->{freq} %>"></TD> </TR> <TR> <TD ALIGN="right"><!--Program--></TD> - <TD><INPUT TYPE="hidden" NAME="prog" VALUE="<%= $hashref->{prog} %>"></TD> + <TD><INPUT TYPE="hidden" NAME="prog" VALUE="<% $hashref->{prog} %>"></TD> </TR> +% if ( $conf->config('ticket_system') ) { +% my $default_queueid = $conf->config('ticket_system-default_queueid'); +% my $default_queue = FS::TicketSystem->queue($default_queueid); +% $default_queue = "(default) $default_queueid: $default_queue" +% if $default_queueid; +% my %queues = FS::TicketSystem->queues(); +% my @queueids = sort { $a <=> $b } keys %queues; +% - <% if ( $conf->config('ticket_system') ) { - my $default_queueid = $conf->config('ticket_system-default_queueid'); - my $default_queue = FS::TicketSystem->queue($default_queueid); - $default_queue = "(default) $default_queueid: $default_queue" - if $default_queueid; - my %queues = FS::TicketSystem->queues(); - my @queueids = sort { $a <=> $b } keys %queues; - %> <TR> <TD ALIGN="right">Ticketing queue</TD> <TD> <SELECT NAME="ticketing_queueid"> - <OPTION VALUE=""><%= $default_queue %> - <% foreach my $queueid ( @queueids ) { %> - <OPTION VALUE="<%= $queueid %>" <%= $agent->ticketing_queueid == $queueid ? ' SELECTED' : '' %>><%= $queueid %>: <%= $queues{$queueid} %> - <% } %> + <OPTION VALUE=""><% $default_queue %> +% foreach my $queueid ( @queueids ) { + + <OPTION VALUE="<% $queueid %>" <% $agent->ticketing_queueid == $queueid ? ' SELECTED' : '' %>><% $queueid %>: <% $queues{$queueid} %> +% } + </SELECT> </TD> </TR> - <% } %> +% } + <TR> <TD ALIGN="right">Agent interface username</TD> <TD> - <INPUT TYPE="text" NAME="username" VALUE="<%= $hashref->{username} %>"> + <INPUT TYPE="text" NAME="username" VALUE="<% $hashref->{username} %>"> </TD> </TR> <TR> <TD ALIGN="right">Agent interface password</TD> <TD> - <INPUT TYPE="text" NAME="_password" VALUE="<%= $hashref->{_password} %>"> + <INPUT TYPE="text" NAME="_password" VALUE="<% $hashref->{_password} %>"> </TD> </TR> </TABLE> -<BR><INPUT TYPE="submit" VALUE="<%= $hashref->{agentnum} ? "Apply changes" : "Add agent" %>"> +<BR><INPUT TYPE="submit" VALUE="<% $hashref->{agentnum} ? "Apply changes" : "Add agent" %>"> </FORM> </BODY> </HTML> diff --git a/httemplate/edit/agent_payment_gateway.html b/httemplate/edit/agent_payment_gateway.html index db4331b84..08a2fa6bf 100644 --- a/httemplate/edit/agent_payment_gateway.html +++ b/httemplate/edit/agent_payment_gateway.html @@ -1,57 +1,63 @@ -<% +% +% +%$cgi->param('agentnum') =~ /(\d+)$/ or die "illegal agentnum"; +%my $agent = qsearchs('agent', { 'agentnum' => $1 } ); +%die "agentnum $1 not found" unless $agent; +% +%#my @agent_payment_gateway; +%if ( $cgi->param('error') ) { +%} +% +%my $action = 'Add'; +% +% -$cgi->param('agentnum') =~ /(\d+)$/ or die "illegal agentnum"; -my $agent = qsearchs('agent', { 'agentnum' => $1 } ); -die "agentnum $1 not found" unless $agent; -#my @agent_payment_gateway; -if ( $cgi->param('error') ) { -} - -my $action = 'Add'; - -%> - -<%= include("/elements/header.html","$action payment gateway override for ". $agent->agent, menubar( +<% include("/elements/header.html","$action payment gateway override for ". $agent->agent, menubar( 'Main Menu' => $p, #'View all payment gateways' => $p. 'browse/payment_gateway.html', 'View all agents' => $p. 'browse/agent.html', )) %> +% if ( $cgi->param('error') ) { + +<FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> +% } -<% if ( $cgi->param('error') ) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> -<FORM ACTION="<%=popurl(1)%>process/agent_payment_gateway.html" METHOD=POST> -<INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agent->agentnum %>"> +<FORM ACTION="<%popurl(1)%>process/agent_payment_gateway.html" METHOD=POST> +<INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agent->agentnum %>"> Use gateway <SELECT NAME="gatewaynum"> -<% foreach my $payment_gateway ( - qsearch('payment_gateway', { 'disabled' => '' } ) - ) { -%> - <OPTION VALUE="<%= $payment_gateway->gatewaynum %>"><%= $payment_gateway->gateway_module %> (<%= $payment_gateway->gateway_username %>) -<% } %> +% foreach my $payment_gateway ( +% qsearch('payment_gateway', { 'disabled' => '' } ) +% ) { +% + + <OPTION VALUE="<% $payment_gateway->gatewaynum %>"><% $payment_gateway->gateway_module %> (<% $payment_gateway->gateway_username %>) +% } + </SELECT> <BR><BR> for <SELECT NAME="cardtype" MULTIPLE> -<% foreach my $cardtype ( - "", - "VISA card", - "MasterCard", - "Discover card", - "American Express card", - "Diner's Club/Carte Blanche", - "enRoute", - "JCB", - "BankCard", - "Switch", - "Solo", - 'ACH', -) { %> - <OPTION VALUE="<%= $cardtype %>"><%= $cardtype || '(Default fallback)' %> -<% } %> +% foreach my $cardtype ( +% "", +% "VISA card", +% "MasterCard", +% "Discover card", +% "American Express card", +% "Diner's Club/Carte Blanche", +% "enRoute", +% "JCB", +% "BankCard", +% "Switch", +% "Solo", +% 'ACH', +%) { + + <OPTION VALUE="<% $cardtype %>"><% $cardtype || '(Default fallback)' %> +% } + </SELECT> <BR><BR> diff --git a/httemplate/edit/agent_type.cgi b/httemplate/edit/agent_type.cgi index f5afd3a96..5438e5c3b 100755 --- a/httemplate/edit/agent_type.cgi +++ b/httemplate/edit/agent_type.cgi @@ -1,41 +1,43 @@ -<% - -my($agent_type); -if ( $cgi->param('error') ) { - $agent_type = new FS::agent_type ( { - map { $_, scalar($cgi->param($_)) } fields('agent') - } ); -} elsif ( $cgi->keywords ) { #editing - my( $query ) = $cgi->keywords; - $query =~ /^(\d+)$/; - $agent_type=qsearchs('agent_type',{'typenum'=>$1}); -} else { #adding - $agent_type = new FS::agent_type {}; -} -my $action = $agent_type->typenum ? 'Edit' : 'Add'; - -%><%= include("/elements/header.html","$action Agent Type", menubar( +% +% +%my($agent_type); +%if ( $cgi->param('error') ) { +% $agent_type = new FS::agent_type ( { +% map { $_, scalar($cgi->param($_)) } fields('agent') +% } ); +%} elsif ( $cgi->keywords ) { #editing +% my( $query ) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $agent_type=qsearchs('agent_type',{'typenum'=>$1}); +%} else { #adding +% $agent_type = new FS::agent_type {}; +%} +%my $action = $agent_type->typenum ? 'Edit' : 'Add'; +% +% +<% include("/elements/header.html","$action Agent Type", menubar( 'Main Menu' => "$p", 'View all agent types' => "${p}browse/agent_type.cgi", )) %> +% if ( $cgi->param('error') ) { -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> +% } -<FORM ACTION="<%= popurl(1) %>process/agent_type.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="typenum" VALUE="<%= $agent_type->typenum %>"> -Agent Type #<%= $agent_type->typenum || "(NEW)" %> + +<FORM ACTION="<% popurl(1) %>process/agent_type.cgi" METHOD=POST> +<INPUT TYPE="hidden" NAME="typenum" VALUE="<% $agent_type->typenum %>"> +Agent Type #<% $agent_type->typenum || "(NEW)" %> <BR> Agent Type -<INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<%= $agent_type->atype %>"> +<INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<% $agent_type->atype %>"> <BR><BR> Select which packages agents of this type may sell to customers<BR> -<%= ntable("#cccccc", 2) %><TR><TD> -<%= include('/elements/checkboxes-table.html', +<% ntable("#cccccc", 2) %><TR><TD> +<% include('/elements/checkboxes-table.html', 'source_obj' => $agent_type, 'link_table' => 'type_pkgs', 'target_table' => 'part_pkg', @@ -48,8 +50,8 @@ Select which packages agents of this type may sell to customers<BR> </TD></TR></TABLE> <BR> -<INPUT TYPE="submit" VALUE="<%= $agent_type->typenum ? "Apply changes" : "Add agent type" %>"> +<INPUT TYPE="submit" VALUE="<% $agent_type->typenum ? "Apply changes" : "Add agent type" %>"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/edit/bulk-cust_svc.html b/httemplate/edit/bulk-cust_svc.html index be247ba4e..f2efc3ff9 100644 --- a/httemplate/edit/bulk-cust_svc.html +++ b/httemplate/edit/bulk-cust_svc.html @@ -1,4 +1,4 @@ -<%= include("/elements/header.html", 'Bulk customer service change', +<% include("/elements/header.html", 'Bulk customer service change', menubar( 'Main Menu' => $p, ), @@ -9,7 +9,7 @@ <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT> -<%= include('/elements/progress-init.html', +<% include('/elements/progress-init.html', 'OneTrueForm', [qw( old_svcpart new_svcpart pkgpart )], 'process/bulk-cust_svc.cgi', @@ -18,65 +18,67 @@ %> <FORM NAME="OneTrueForm"> +% +% $cgi->param('svcpart') =~ /^(\d+)$/ +% or die "illegal svcpart: ". $cgi->param('svcpart'); +% +% my $old_svcpart = $1; +% my $src_part_svc = qsearchs('part_svc', { 'svcpart' => $old_svcpart } ) +% or die "unknown svcpart: $old_svcpart"; +% -<% - $cgi->param('svcpart') =~ /^(\d+)$/ - or die "illegal svcpart: ". $cgi->param('svcpart'); - my $old_svcpart = $1; - my $src_part_svc = qsearchs('part_svc', { 'svcpart' => $old_svcpart } ) - or die "unknown svcpart: $old_svcpart"; -%> - -<INPUT NAME="old_svcpart" TYPE="hidden" VALUE="<%= $old_svcpart %>"> +<INPUT NAME="old_svcpart" TYPE="hidden" VALUE="<% $old_svcpart %>"> Change <!-- customer -<B><%= $src_part_svc->svcpart %>: <%= $src_part_svc->svc %></B> services +<B><% $src_part_svc->svcpart %>: <% $src_part_svc->svc %></B> services <BR> --> <SELECT NAME="pkgpart"> +% my $num_cust_svc = $src_part_svc->num_cust_svc; +% if ( $num_cust_svc > 1 ) { + + <OPTION VALUE="">all <% $num_cust_svc %> <% $src_part_svc->svc %> services +% } else { + + <OPTION VALUE="">the <% $num_cust_svc %> <% $src_part_svc->svc %> service +% } +% +% my $num_unlinked = $src_part_svc->num_cust_svc(0); +% if ( $num_unlinked ) { +% + + <OPTION VALUE="0">the <% $num_unlinked %> unlinked <% $src_part_svc->svc %> services +% } +% foreach my $schwartz ( +% grep { $_->[1] } +% map { [ $_, $src_part_svc->num_cust_svc($_->pkgpart) ] } +% qsearch('part_pkg', {} ) +% ) { +% my( $part_pkg, $num_cust_svc ) = @$schwartz; +% + + <OPTION VALUE="<% $part_pkg->pkgpart %>">the <% $num_cust_svc %> + <% $src_part_svc->svc %> service<% $num_cust_svc > 1 ? 's in' : ' in a' %> + <% $part_pkg->pkg %> package<% $num_cust_svc > 1 ? 's' : '' %> +% } -<% my $num_cust_svc = $src_part_svc->num_cust_svc; %> -<% if ( $num_cust_svc > 1 ) { %> - <OPTION VALUE="">all <%= $num_cust_svc %> <%= $src_part_svc->svc %> services -<% } else { %> - <OPTION VALUE="">the <%= $num_cust_svc %> <%= $src_part_svc->svc %> service -<% } %> - -<% - my $num_unlinked = $src_part_svc->num_cust_svc(0); - if ( $num_unlinked ) { -%> - <OPTION VALUE="0">the <%= $num_unlinked %> unlinked <%= $src_part_svc->svc %> services - -<% } %> - -<% foreach my $schwartz ( - grep { $_->[1] } - map { [ $_, $src_part_svc->num_cust_svc($_->pkgpart) ] } - qsearch('part_pkg', {} ) - ) { - my( $part_pkg, $num_cust_svc ) = @$schwartz; -%> - <OPTION VALUE="<%= $part_pkg->pkgpart %>">the <%= $num_cust_svc %> - <%= $src_part_svc->svc %> service<%= $num_cust_svc > 1 ? 's in' : ' in a' %> - <%= $part_pkg->pkg %> package<%= $num_cust_svc > 1 ? 's' : '' %> -<% } %> </SELECT> <BR> to new service definition <SELECT NAME="new_svcpart"> -<% foreach my $dest_part_svc ( - grep { $_->svcpart != $old_svcpart - && $_->svcdb eq $src_part_svc->svcdb - } - qsearch('part_svc', { 'disabled' => '' } ) - ) { -%> - <OPTION VALUE="<%= $dest_part_svc->svcpart %>"><%= $dest_part_svc->svcpart %>: <%= $dest_part_svc->svc %> +% foreach my $dest_part_svc ( +% grep { $_->svcpart != $old_svcpart +% && $_->svcdb eq $src_part_svc->svcdb +% } +% qsearch('part_svc', { 'disabled' => '' } ) +% ) { +% + + <OPTION VALUE="<% $dest_part_svc->svcpart %>"><% $dest_part_svc->svcpart %>: <% $dest_part_svc->svc %> +% } -<% } %> </SELECT> <BR> diff --git a/httemplate/edit/cust_bill_pay.cgi b/httemplate/edit/cust_bill_pay.cgi index 9d3bdd8cb..2035e4b64 100755 --- a/httemplate/edit/cust_bill_pay.cgi +++ b/httemplate/edit/cust_bill_pay.cgi @@ -1,87 +1,90 @@ -<% - -my($paynum, $amount, $invnum); -if ( $cgi->param('error') ) { - $paynum = $cgi->param('paynum'); - $amount = $cgi->param('amount'); - $invnum = $cgi->param('invnum'); -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $paynum = $1; - $amount = ''; - $invnum = ''; -} - -my $otaker = getotaker; - -my $p1 = popurl(1); - -%><%= header("Apply Payment", '') %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> +% +% +%my($paynum, $amount, $invnum); +%if ( $cgi->param('error') ) { +% $paynum = $cgi->param('paynum'); +% $amount = $cgi->param('amount'); +% $invnum = $cgi->param('invnum'); +%} else { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $paynum = $1; +% $amount = ''; +% $invnum = ''; +%} +% +%my $otaker = getotaker; +% +%my $p1 = popurl(1); +% +% +<% header("Apply Payment", '') %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> - -<FORM ACTION="<%= $p1 %>process/cust_bill_pay.cgi" METHOD=POST> +% } -<% -my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ); -die "payment $paynum not found!" unless $cust_pay; -my $unapplied = $cust_pay->unapplied; -%> +<FORM ACTION="<% $p1 %>process/cust_bill_pay.cgi" METHOD=POST> +% +%my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ); +%die "payment $paynum not found!" unless $cust_pay; +% +%my $unapplied = $cust_pay->unapplied; +% -Payment #<B><%= $paynum %></B> -<INPUT TYPE="hidden" NAME="paynum" VALUE="<%= $paynum %>"> -<BR>Date: <B><%= time2str("%D", $cust_pay->_date) %></B> +Payment #<B><% $paynum %></B> +<INPUT TYPE="hidden" NAME="paynum" VALUE="<% $paynum %>"> -<BR>Amount: $<B><%= $cust_pay->paid %></B> +<BR>Date: <B><% time2str("%D", $cust_pay->_date) %></B> -<BR>Unapplied amount: $<B><%= $unapplied %></B> +<BR>Amount: $<B><% $cust_pay->paid %></B> -<% -my @cust_bill = grep $_->owed != 0, - qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } ); +<BR>Unapplied amount: $<B><% $unapplied %></B> +% +%my @cust_bill = grep $_->owed != 0, +% qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } ); +% +% -%> <SCRIPT> function changed(what) { cust_bill = what.options[what.selectedIndex].value; +% foreach my $cust_bill ( @cust_bill ) { +% my $invnum = $cust_bill->invnum; +% my $changeto = $cust_bill->owed < $unapplied +% ? $cust_bill->owed +% : $unapplied; +% -<% foreach my $cust_bill ( @cust_bill ) { - my $invnum = $cust_bill->invnum; - my $changeto = $cust_bill->owed < $unapplied - ? $cust_bill->owed - : $unapplied; -%> if ( cust_bill == $invnum ) { - what.form.amount.value = "<%= $changeto %>"; + what.form.amount.value = "<% $changeto %>"; } -<% } %> +% } + if ( cust_bill == "Refund" ) { - what.form.amount.value = "<%= $unapplied %>"; + what.form.amount.value = "<% $unapplied %>"; } } </SCRIPT> <BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)"> <OPTION VALUE=""> +% foreach my $cust_bill ( @cust_bill ) { -<% foreach my $cust_bill ( @cust_bill ) { %> - <OPTION<%= $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<%= $cust_bill->invnum %>"><%= $cust_bill->invnum %> - <%= time2str("%D", $cust_bill->_date) %> - $<%= $cust_bill->owed %> + <OPTION<% $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<% $cust_bill->invnum %>"><% $cust_bill->invnum %> - <% time2str("%D", $cust_bill->_date) %> - $<% $cust_bill->owed %> +% } -<% } %> <OPTION VALUE="Refund">Refund </SELECT> -<BR>Amount $<INPUT TYPE="text" NAME="amount" VALUE="<%= $amount %>" SIZE=8 MAXLENGTH=8> +<BR>Amount $<INPUT TYPE="text" NAME="amount" VALUE="<% $amount %>" SIZE=8 MAXLENGTH=8> <BR> <CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER> diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi index 8de627d20..c54fb8147 100755 --- a/httemplate/edit/cust_credit.cgi +++ b/httemplate/edit/cust_credit.cgi @@ -1,67 +1,69 @@ -<% - -my $conf = new FS::Conf; -my($custnum, $amount, $reason); -if ( $cgi->param('error') ) { - #$cust_credit = new FS::cust_credit ( { - # map { $_, scalar($cgi->param($_)) } fields('cust_credit') - #} ); - $custnum = $cgi->param('custnum'); - $amount = $cgi->param('amount'); - #$refund = $cgi->param('refund'); - $reason = $cgi->param('reason'); -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $custnum = $1; - $amount = ''; - #$refund = 'yes'; - $reason = ''; -} -my $_date = time; - -my $otaker = getotaker; - -my $p1 = popurl(1); - -%><%= include('/elements/header-popup.html', 'Enter Credit') %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> +% +% +%my $conf = new FS::Conf; +%my($custnum, $amount, $reason); +%if ( $cgi->param('error') ) { +% #$cust_credit = new FS::cust_credit ( { +% # map { $_, scalar($cgi->param($_)) } fields('cust_credit') +% #} ); +% $custnum = $cgi->param('custnum'); +% $amount = $cgi->param('amount'); +% #$refund = $cgi->param('refund'); +% $reason = $cgi->param('reason'); +%} else { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $custnum = $1; +% $amount = ''; +% #$refund = 'yes'; +% $reason = ''; +%} +%my $_date = time; +% +%my $otaker = getotaker; +% +%my $p1 = popurl(1); +% +% +<% include('/elements/header-popup.html', 'Enter Credit') %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> +% } + -<!-- <%= small_custview($custnum, $conf->config('countrydefault')) %> --> +<!-- <% small_custview($custnum, $conf->config('countrydefault')) %> --> -<FORM ACTION="<%= $p1 %>process/cust_credit.cgi" METHOD=POST> +<FORM ACTION="<% $p1 %>process/cust_credit.cgi" METHOD=POST> <INPUT TYPE="hidden" NAME="crednum" VALUE=""> -<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>"> +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> <INPUT TYPE="hidden" NAME="paybatch" VALUE=""> -<INPUT TYPE="hidden" NAME="_date" VALUE="<%= $_date %>"> +<INPUT TYPE="hidden" NAME="_date" VALUE="<% $_date %>"> <INPUT TYPE="hidden" NAME="credited" VALUE=""> -<INPUT TYPE="hidden" NAME="otaker" VALUE="<%= $otaker %>"> +<INPUT TYPE="hidden" NAME="otaker" VALUE="<% $otaker %>"> Credit -<%= ntable("#cccccc", 2) %> +<% ntable("#cccccc", 2) %> <TR> <TD ALIGN="right">Date</TD> - <TD BGCOLOR="#ffffff"><%= time2str("%D",$_date) %></TD> + <TD BGCOLOR="#ffffff"><% time2str("%D",$_date) %></TD> </TR> <TR> <TD ALIGN="right">Amount</TD> - <TD BGCOLOR="#ffffff">$<INPUT TYPE="text" NAME="amount" VALUE="<%= $amount %>" SIZE=8 MAXLENGTH=8></TD> + <TD BGCOLOR="#ffffff">$<INPUT TYPE="text" NAME="amount" VALUE="<% $amount %>" SIZE=8 MAXLENGTH=8></TD> </TR> +% +%#print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="$refund">Also post refund!; +% -<% -#print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="$refund">Also post refund!; -%> <TR> <TD ALIGN="right">Reason</TD> - <TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="<%= $reason %>" SIZE=32></TD> + <TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="<% $reason %>" SIZE=32></TD> </TR> <TR> diff --git a/httemplate/edit/cust_credit_bill.cgi b/httemplate/edit/cust_credit_bill.cgi index 409ea3c25..5fdc0ba18 100755 --- a/httemplate/edit/cust_credit_bill.cgi +++ b/httemplate/edit/cust_credit_bill.cgi @@ -1,94 +1,97 @@ -<% - -my($crednum, $amount, $invnum); -if ( $cgi->param('error') ) { - #$cust_credit_bill = new FS::cust_credit_bill ( { - # map { $_, scalar($cgi->param($_)) } fields('cust_credit_bill') - #} ); - $crednum = $cgi->param('crednum'); - $amount = $cgi->param('amount'); - #$refund = $cgi->param('refund'); - $invnum = $cgi->param('invnum'); -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $crednum = $1; - $amount = ''; - #$refund = 'yes'; - $invnum = ''; -} - -my $otaker = getotaker; - -my $p1 = popurl(1); - -%><%= header("Apply Credit", '') %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> +% +% +%my($crednum, $amount, $invnum); +%if ( $cgi->param('error') ) { +% #$cust_credit_bill = new FS::cust_credit_bill ( { +% # map { $_, scalar($cgi->param($_)) } fields('cust_credit_bill') +% #} ); +% $crednum = $cgi->param('crednum'); +% $amount = $cgi->param('amount'); +% #$refund = $cgi->param('refund'); +% $invnum = $cgi->param('invnum'); +%} else { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $crednum = $1; +% $amount = ''; +% #$refund = 'yes'; +% $invnum = ''; +%} +% +%my $otaker = getotaker; +% +%my $p1 = popurl(1); +% +% +<% header("Apply Credit", '') %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> - -<FORM ACTION="<%= $p1 %>process/cust_credit_bill.cgi" METHOD=POST> +% } -<% -my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } ); -die "credit $crednum not found!" unless $cust_credit; -my $credited = $cust_credit->credited; -%> +<FORM ACTION="<% $p1 %>process/cust_credit_bill.cgi" METHOD=POST> +% +%my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } ); +%die "credit $crednum not found!" unless $cust_credit; +% +%my $credited = $cust_credit->credited; +% -Credit #<B><%= $crednum %></B> -<INPUT TYPE="hidden" NAME="crednum" VALUE="<%= $crednum %>"> -<BR>Date: <B><%= time2str("%D", $cust_credit->_date) %></B> +Credit #<B><% $crednum %></B> +<INPUT TYPE="hidden" NAME="crednum" VALUE="<% $crednum %>"> -<BR>Amount: $<B><%= $cust_credit->amount %></B> +<BR>Date: <B><% time2str("%D", $cust_credit->_date) %></B> -<BR>Unapplied amount: $<B><%= $credited %></B> +<BR>Amount: $<B><% $cust_credit->amount %></B> -<BR>Reason: <B><%= $cust_credit->reason %></B> +<BR>Unapplied amount: $<B><% $credited %></B> -<% -my @cust_bill = grep $_->owed != 0, - qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } ); +<BR>Reason: <B><% $cust_credit->reason %></B> +% +%my @cust_bill = grep $_->owed != 0, +% qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } ); +% +% -%> <SCRIPT> function changed(what) { cust_bill = what.options[what.selectedIndex].value; +% foreach my $cust_bill ( @cust_bill ) { +% my $invnum = $cust_bill->invnum; +% my $changeto = $cust_bill->owed < $cust_credit->credited +% ? $cust_bill->owed +% : $cust_credit->credited; +% -<% foreach my $cust_bill ( @cust_bill ) { - my $invnum = $cust_bill->invnum; - my $changeto = $cust_bill->owed < $cust_credit->credited - ? $cust_bill->owed - : $cust_credit->credited; -%> if ( cust_bill == $invnum ) { - what.form.amount.value = "<%= $changeto %>"; + what.form.amount.value = "<% $changeto %>"; } -<% } %> +% } + if ( cust_bill == "Refund" ) { - what.form.amount.value = "<%= $credited %>"; + what.form.amount.value = "<% $credited %>"; } } </SCRIPT> <BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)"> <OPTION VALUE=""> +% foreach my $cust_bill ( @cust_bill ) { -<% foreach my $cust_bill ( @cust_bill ) { %> -<OPTION<%= $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<%= $cust_bill->invnum %>"><%= $cust_bill->invnum %> - <%= time2str("%D",$cust_bill->_date) %> - $<%= $cust_bill->owed %> +<OPTION<% $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<% $cust_bill->invnum %>"><% $cust_bill->invnum %> - <% time2str("%D",$cust_bill->_date) %> - $<% $cust_bill->owed %> +% } -<% } %> <OPTION VALUE="Refund">Refund </SELECT> -<BR>Amount $<INPUT TYPE="text" NAME="amount" VALUE="<%= $amount %>" SIZE=8 MAXLENGTH=8> +<BR>Amount $<INPUT TYPE="text" NAME="amount" VALUE="<% $amount %>" SIZE=8 MAXLENGTH=8> <BR> <CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER> diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index c3d1804bc..dfcd0401f 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -1,160 +1,164 @@ -<% - - #for misplaced logic below - #use FS::part_pkg; - - #for false laziness below (now more properly lazy) - #use FS::svc_acct_pop; - - #for (other) false laziness below - #use FS::agent; - #use FS::type_pkgs; - -my $conf = new FS::Conf; - -#get record - -my $error = ''; -my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart); -my(@invoicing_list); -my $same = ''; -if ( $cgi->param('error') ) { - $error = $cgi->param('error'); - $cust_main = new FS::cust_main ( { - map { $_, scalar($cgi->param($_)) } fields('cust_main') - } ); - $custnum = $cust_main->custnum; - $saved_pkgpart = $cgi->param('pkgpart_svcpart') || ''; - if ( $saved_pkgpart =~ /^(\d+)_/ ) { - $saved_pkgpart = $1; - } else { - $saved_pkgpart = ''; - } - $username = $cgi->param('username'); - $password = $cgi->param('_password'); - $popnum = $cgi->param('popnum'); - @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); - $same = $cgi->param('same'); - $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid'); -} elsif ( $cgi->keywords ) { #editing - my( $query ) = $cgi->keywords; - $query =~ /^(\d+)$/; - $custnum=$1; - $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); - if ( $cust_main->dbdef_table->column('paycvv') - && length($cust_main->paycvv) ) { - my $paycvv = $cust_main->paycvv; - $paycvv =~ s/./*/g; - $cust_main->paycvv($paycvv); - } - $saved_pkgpart = 0; - $username = ''; - $password = ''; - $popnum = 0; - @invoicing_list = $cust_main->invoicing_list; -} else { - $custnum=''; - $cust_main = new FS::cust_main ( {} ); - $cust_main->otaker( &getotaker ); - $cust_main->referral_custnum( $cgi->param('referral_custnum') ); - $saved_pkgpart = 0; - $username = ''; - $password = ''; - $popnum = 0; - @invoicing_list = (); -} -$cgi->delete_all(); - -my $action = $custnum ? 'Edit' : 'Add'; -$action .= ": ". $cust_main->name if $custnum; +% +% +% #for misplaced logic below +% #use FS::part_pkg; +% +% #for false laziness below (now more properly lazy) +% #use FS::svc_acct_pop; +% +% #for (other) false laziness below +% #use FS::agent; +% #use FS::type_pkgs; +% +%my $conf = new FS::Conf; +% +%#get record +% +%my $error = ''; +%my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart); +%my(@invoicing_list); +%my $same = ''; +%if ( $cgi->param('error') ) { +% $error = $cgi->param('error'); +% $cust_main = new FS::cust_main ( { +% map { $_, scalar($cgi->param($_)) } fields('cust_main') +% } ); +% $custnum = $cust_main->custnum; +% $saved_pkgpart = $cgi->param('pkgpart_svcpart') || ''; +% if ( $saved_pkgpart =~ /^(\d+)_/ ) { +% $saved_pkgpart = $1; +% } else { +% $saved_pkgpart = ''; +% } +% $username = $cgi->param('username'); +% $password = $cgi->param('_password'); +% $popnum = $cgi->param('popnum'); +% @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); +% $same = $cgi->param('same'); +% $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid'); +%} elsif ( $cgi->keywords ) { #editing +% my( $query ) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $custnum=$1; +% $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); +% if ( $cust_main->dbdef_table->column('paycvv') +% && length($cust_main->paycvv) ) { +% my $paycvv = $cust_main->paycvv; +% $paycvv =~ s/./*/g; +% $cust_main->paycvv($paycvv); +% } +% $saved_pkgpart = 0; +% $username = ''; +% $password = ''; +% $popnum = 0; +% @invoicing_list = $cust_main->invoicing_list; +%} else { +% $custnum=''; +% $cust_main = new FS::cust_main ( {} ); +% $cust_main->otaker( &getotaker ); +% $cust_main->referral_custnum( $cgi->param('referral_custnum') ); +% $saved_pkgpart = 0; +% $username = ''; +% $password = ''; +% $popnum = 0; +% @invoicing_list = (); +%} +%$cgi->delete_all(); +% +%my $action = $custnum ? 'Edit' : 'Add'; +%$action .= ": ". $cust_main->name if $custnum; +% +%my $r = qq!<font color="#ff0000">*</font> !; +% +% -my $r = qq!<font color="#ff0000">*</font> !; - -%> <!-- top --> -<%= include('/elements/header.html', +<% include('/elements/header.html', "Customer $action", '', ' onUnload="myclose()"' ) %> +% if ( $error ) { + +<FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT><BR><BR> +% } -<% if ( $error ) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $error %></FONT><BR><BR> -<% } %> <FORM NAME="topform" STYLE="margin-bottom: 0"> -<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>"> -<% if ( $custnum ) { %> - Customer #<B><%= $custnum %></B> - - <B><FONT COLOR="<%= $cust_main->statuscolor %>"> - <%= ucfirst($cust_main->status) %> +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> +% if ( $custnum ) { + + Customer #<B><% $custnum %></B> - + <B><FONT COLOR="<% $cust_main->statuscolor %>"> + <% ucfirst($cust_main->status) %> </FONT></B> <BR><BR> -<% } %> +% } + -<%= &ntable("#cccccc") %> +<% &ntable("#cccccc") %> <!-- agent --> -<%= include('/elements/tr-select-agent.html', $cust_main->agentnum, +<% include('/elements/tr-select-agent.html', $cust_main->agentnum, 'label' => "<B>${r}Agent</B>", 'empty_label' => 'Select agent', ) %> <!-- referral (advertising source) --> +% +%my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; +%if ( $custnum && ! $conf->exists('editreferrals') ) { +% -<% -my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; -if ( $custnum && ! $conf->exists('editreferrals') ) { -%> - <INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $refnum %>"> + <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>"> +% } else { -<% } else { %> - <%= include('/elements/tr-select-part_referral.html') %> + <% include('/elements/tr-select-part_referral.html') %> +% } -<% } %> <!-- referring customer --> +% +%my $referring_cust_main = ''; +%if ( $cust_main->referral_custnum +% and $referring_cust_main = +% qsearchs('cust_main', { custnum => $cust_main->referral_custnum } ) +%) { +% -<% -my $referring_cust_main = ''; -if ( $cust_main->referral_custnum - and $referring_cust_main = - qsearchs('cust_main', { custnum => $cust_main->referral_custnum } ) -) { -%> <TR> <TD ALIGN="right">Referring customer</TD> <TD> - <A HREF="<%= popurl(1) %>/cust_main.cgi?<%= $cust_main->referral_custnum %>"><%= $cust_main->referral_custnum %>: <%= $referring_cust_main->name %></A> + <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name %></A> </TD> </TR> - <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<%= $cust_main->referral_custnum %>"> + <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>"> +% } elsif ( ! $conf->exists('disable_customer_referrals') ) { -<% } elsif ( ! $conf->exists('disable_customer_referrals') ) { %> <TR> <TD ALIGN="right">Referring customer</TD> <TD> <!-- <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> --> - <%= include('/elements/search-cust_main.html', + <% include('/elements/search-cust_main.html', 'field_name' => 'referral_custnum', ) %> </TD> </TR> +% } else { -<% } else { %> <INPUT TYPE="hidden" NAME="referral_custnum" VALUE=""> +% } -<% } %> </TABLE> @@ -162,18 +166,20 @@ if ( $cust_main->referral_custnum <BR><BR> Billing address -<%= include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %> +<% include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %> <!-- service address --> +% if ( defined $cust_main->dbdef_table->column('ship_last') ) { -<% if ( defined $cust_main->dbdef_table->column('ship_last') ) { %> <SCRIPT> function bill_changed(what) { if ( what.form.same.checked ) { -<% for (qw( last first company address1 address2 city zip daytime night fax )) { %> - what.form.ship_<%=$_%>.value = what.form.<%=$_%>.value; -<% } %> +% for (qw( last first company address1 address2 city zip daytime night fax )) { + + what.form.ship_<%$_%>.value = what.form.<%$_%>.value; +% } + what.form.ship_country.selectedIndex = what.form.country.selectedIndex; function fix_ship_state() { @@ -190,45 +196,49 @@ function bill_changed(what) { function samechanged(what) { if ( what.checked ) { bill_changed(what); -<% for (qw( last first company address1 address2 city county state zip country daytime night fax )) { %> - what.form.ship_<%=$_%>.disabled = true; - what.form.ship_<%=$_%>.style.backgroundColor = '#dddddd'; -<% } %> +% for (qw( last first company address1 address2 city county state zip country daytime night fax )) { + + what.form.ship_<%$_%>.disabled = true; + what.form.ship_<%$_%>.style.backgroundColor = '#dddddd'; +% } + } else { -<% for (qw( last first company address1 address2 city county state zip country daytime night fax )) { %> - what.form.ship_<%=$_%>.disabled = false; - what.form.ship_<%=$_%>.style.backgroundColor = '#ffffff'; -<% } %> +% for (qw( last first company address1 address2 city county state zip country daytime night fax )) { + + what.form.ship_<%$_%>.disabled = false; + what.form.ship_<%$_%>.style.backgroundColor = '#ffffff'; +% } + } } </SCRIPT> +% +% my $checked = ''; +% my $disabled = ''; +% my $disabledselect = ''; +% unless ( $cust_main->ship_last && $same ne 'Y' ) { +% $checked = 'CHECKED'; +% $disabled = 'DISABLED style="background-color: #dddddd"'; +% foreach ( +% qw( last first company address1 address2 city county state zip country +% daytime night fax ) +% ) { +% $cust_main->set("ship_$_", $cust_main->get($_) ); +% } +% } +% -<% - my $checked = ''; - my $disabled = ''; - my $disabledselect = ''; - unless ( $cust_main->ship_last && $same ne 'Y' ) { - $checked = 'CHECKED'; - $disabled = 'DISABLED style="background-color: #dddddd"'; - foreach ( - qw( last first company address1 address2 city county state zip country - daytime night fax ) - ) { - $cust_main->set("ship_$_", $cust_main->get($_) ); - } - } -%> <BR> Service address -(<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%=$checked%>>same as billing address) -<%= include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %> +(<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)" <%$checked%>>same as billing address) +<% include('cust_main/contact.html', $cust_main, 'ship_', '', $disabled ) %> +% } -<% } %> <!-- billing info --> -<%= include( 'cust_main/billing.html', $cust_main, +<% include( 'cust_main/billing.html', $cust_main, 'invoicing_list' => \@invoicing_list, ) %> @@ -317,136 +327,136 @@ function copyelement(from, to) { </SCRIPT> -<FORM ACTION="<%= popurl(1) %>process/cust_main.cgi" METHOD=POST NAME="bottomform" onSubmit="document.bottomform.submit.disabled=true; bottomfixup(this.form);" STYLE="margin-top: 0; margin-bottom: 0"> - -<% foreach my $hidden ( - 'custnum', 'agentnum', 'refnum', 'referral_custnum', - 'last', 'first', 'ss', 'company', - 'address1', 'address2', 'city', - 'county', 'state', 'zip', 'country', - 'daytime', 'night', 'fax', - - 'same', - - 'ship_last', 'ship_first', 'ship_company', - 'ship_address1', 'ship_address2', 'ship_city', - 'ship_county', 'ship_state', 'ship_zip', 'ship_country', - 'ship_daytime','ship_night', 'ship_fax', - - 'select', #XXX key - - 'payauto', - 'payinfo', 'payinfo1', 'payinfo2', - 'payname', 'exp_month', 'exp_year', 'paycvv', - 'paystart_month', 'paystart_year', 'payissue', - 'payip', - 'paid', - - 'tax', - 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX', - 'spool_cdr' - ) { -%> - <INPUT TYPE="hidden" NAME="<%= $hidden %>" VALUE=""> -<% } %> +<FORM ACTION="<% popurl(1) %>process/cust_main.cgi" METHOD=POST NAME="bottomform" onSubmit="document.bottomform.submit.disabled=true; bottomfixup(this.form);" STYLE="margin-top: 0; margin-bottom: 0"> +% foreach my $hidden ( +% 'custnum', 'agentnum', 'refnum', 'referral_custnum', +% 'last', 'first', 'ss', 'company', +% 'address1', 'address2', 'city', +% 'county', 'state', 'zip', 'country', +% 'daytime', 'night', 'fax', +% +% 'same', +% +% 'ship_last', 'ship_first', 'ship_company', +% 'ship_address1', 'ship_address2', 'ship_city', +% 'ship_county', 'ship_state', 'ship_zip', 'ship_country', +% 'ship_daytime','ship_night', 'ship_fax', +% +% 'select', #XXX key +% +% 'payauto', +% 'payinfo', 'payinfo1', 'payinfo2', +% 'payname', 'exp_month', 'exp_year', 'paycvv', +% 'paystart_month', 'paystart_year', 'payissue', +% 'payip', +% 'paid', +% +% 'tax', +% 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX', +% 'spool_cdr' +% ) { +% + + <INPUT TYPE="hidden" NAME="<% $hidden %>" VALUE=""> +% } + <BR>Comments -<%= &ntable("#cccccc") %> +<% &ntable("#cccccc") %> <TR> <TD> - <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments"><%= $cust_main->comments %></TEXTAREA> + <TEXTAREA COLS=80 ROWS=5 WRAP="HARD" NAME="comments"><% $cust_main->comments %></TEXTAREA> </TD> </TR> </TABLE> +% +% +%unless ( $custnum ) { +% # pry the wrong place for this logic. also pretty expensive +% #use FS::part_pkg; +% +% #false laziness, copied from FS::cust_pkg::order +% my $pkgpart; +% my @agents = $FS::CurrentUser::CurrentUser->agents; +% if ( scalar(@agents) == 1 ) { +% # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART +% $pkgpart = $agents[0]->pkgpart_hashref; +% } else { +% #can't know (agent not chosen), so, allow all +% my %typenum; +% foreach my $agent ( @agents ) { +% next if $typenum{$agent->typenum}++; +% #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref } +% foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; } #5.004_04 workaround +% } +% } +% #eslaf +% +% my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } } +% qsearch( 'part_pkg', { 'disabled' => '' } ); +% +% if ( @part_pkg ) { +% +% # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"), +% #apiabuse & undesirable wrapping +% +% -<% - -unless ( $custnum ) { - # pry the wrong place for this logic. also pretty expensive - #use FS::part_pkg; - - #false laziness, copied from FS::cust_pkg::order - my $pkgpart; - my @agents = $FS::CurrentUser::CurrentUser->agents; - if ( scalar(@agents) == 1 ) { - # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART - $pkgpart = $agents[0]->pkgpart_hashref; - } else { - #can't know (agent not chosen), so, allow all - my %typenum; - foreach my $agent ( @agents ) { - next if $typenum{$agent->typenum}++; - #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref } - foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; } #5.004_04 workaround - } - } - #eslaf - - my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } } - qsearch( 'part_pkg', { 'disabled' => '' } ); - - if ( @part_pkg ) { - - # print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"), - #apiabuse & undesirable wrapping - - %> <BR>First package - <%= ntable("#cccccc") %> + <% ntable("#cccccc") %> <TR> <TD COLSPAN=2> <SELECT NAME="pkgpart_svcpart"> <OPTION VALUE="">(none) +% foreach my $part_pkg ( @part_pkg ) { + - <% foreach my $part_pkg ( @part_pkg ) { %> - - <OPTION VALUE="<%= $part_pkg->pkgpart. "_". $part_pkg->svcpart('svc_acct') %>"<%= ( $saved_pkgpart && $part_pkg->pkgpart == $saved_pkgpart ) ? ' SELECTED' : '' %>><%= $part_pkg->pkg. " - ". $part_pkg->comment %> - - <% } %> + <OPTION VALUE="<% $part_pkg->pkgpart. "_". $part_pkg->svcpart('svc_acct') %>"<% ( $saved_pkgpart && $part_pkg->pkgpart == $saved_pkgpart ) ? ' SELECTED' : '' %>><% $part_pkg->pkg. " - ". $part_pkg->comment %> +% } + </SELECT> </TD> </TR> - - <% - #false laziness: (mostly) copied from edit/svc_acct.cgi - #$ulen = $svc_acct->dbdef_table->column('username')->length; - my $ulen = dbdef->table('svc_acct')->column('username')->length; - my $ulen2 = $ulen+2; - my $passwordmax = $conf->config('passwordmax') || 8; - my $pmax2 = $passwordmax + 2; - %> +% +% #false laziness: (mostly) copied from edit/svc_acct.cgi +% #$ulen = $svc_acct->dbdef_table->column('username')->length; +% my $ulen = dbdef->table('svc_acct')->column('username')->length; +% my $ulen2 = $ulen+2; +% my $passwordmax = $conf->config('passwordmax') || 8; +% my $pmax2 = $passwordmax + 2; +% + <TR> <TD ALIGN="right">Username</TD> <TD> - <INPUT TYPE="text" NAME="username" VALUE="<%= $username %>" SIZE=<%= $ulen2 %> MAXLENGTH=<%= $ulen %>> + <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>> </TD> </TR> <TR> <TD ALIGN="right">Password</TD> <TD> - <INPUT TYPE="text" NAME="_password" VALUE="<%= $password %>" SIZE=<%= $pmax2 %> MAXLENGTH=<%= $passwordmax %>> + <INPUT TYPE="text" NAME="_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $passwordmax %>> (blank to generate) </TD> </TR> <TR> <TD ALIGN="right">Access number</TD> - <TD><%= FS::svc_acct_pop::popselector($popnum) %></TD> + <TD><% FS::svc_acct_pop::popselector($popnum) %></TD> </TR> </TABLE> - - <% } %> +% } +% } -<% } %> -<INPUT TYPE="hidden" NAME="otaker" VALUE="<%= $cust_main->otaker %>"> +<INPUT TYPE="hidden" NAME="otaker" VALUE="<% $cust_main->otaker %>"> <BR> -<INPUT TYPE="submit" NAME="submit" VALUE="<%= $custnum ? "Apply Changes" : "Add Customer" %>"> +<INPUT TYPE="submit" NAME="submit" VALUE="<% $custnum ? "Apply Changes" : "Add Customer" %>"> <BR> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index 790f41f00..78a2002a4 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -1,70 +1,71 @@ -<% - -my( $cust_main, %options ) = @_; -my @invoicing_list = @{ $options{'invoicing_list'} }; -my $conf = new FS::Conf; -my $payby_default = $conf->config('payby-default'); - -my @payby = grep /\w/, $conf->config('payby'); -#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) -@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) - unless @payby; - -if ( $payby_default eq 'HIDE' ) { - - $cust_main->payby('BILL') unless $cust_main->payby; - -%> - - <INPUT TYPE="hidden" NAME="select" VALUE="<%= $cust_main->payby %>"> +% +% +%my( $cust_main, %options ) = @_; +%my @invoicing_list = @{ $options{'invoicing_list'} }; +%my $conf = new FS::Conf; +%my $payby_default = $conf->config('payby-default'); +% +%my @payby = grep /\w/, $conf->config('payby'); +%#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) +%@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) +% unless @payby; +% +%if ( $payby_default eq 'HIDE' ) { +% +% $cust_main->payby('BILL') unless $cust_main->payby; +% +% + + + <INPUT TYPE="hidden" NAME="select" VALUE="<% $cust_main->payby %>"> </FORM> - <FORM NAME="<%= $cust_main->payby %>" STYLE="margin-top: 0; margin-bottom: 0"> <% # XXX key %> - - <% foreach my $field (qw( payinfo payname paycvv paystart_month paystart_year payissue payip )) { %> + <FORM NAME="<% $cust_main->payby %>" STYLE="margin-top: 0; margin-bottom: 0"> +% # XXX key +% foreach my $field (qw( payinfo payname paycvv paystart_month paystart_year payissue payip )) { - <INPUT TYPE="hidden" NAME="<%= $field %>" VALUE="<%= $cust_main->getfield($field) %>"> - <% } %> + <INPUT TYPE="hidden" NAME="<% $field %>" VALUE="<% $cust_main->getfield($field) %>"> +% } +% +% #false laziness w/elements/select-month_year.html & view/cust_main/billing.html +% my( $mon, $year ); +% my $date = $cust_main->paydate || '12-2037'; +% if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format +% ( $mon, $year ) = ( $2, $1 ); +% } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { +% ( $mon, $year ) = ( $1, $3 ); +% } else { +% die "unrecognized expiration date format: $date"; +% } +% - <% - #false laziness w/elements/select-month_year.html & view/cust_main/billing.html - my( $mon, $year ); - my $date = $cust_main->paydate || '12-2037'; - if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); - } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); - } else { - die "unrecognized expiration date format: $date"; - } - %> - <INPUT TYPE="hidden" NAME="exp_month" VALUE="<%= $mon %>"> - <INPUT TYPE="hidden" NAME="exp_year" VALUE="<%= $year %>"> + <INPUT TYPE="hidden" NAME="exp_month" VALUE="<% $mon %>"> + <INPUT TYPE="hidden" NAME="exp_year" VALUE="<% $year %>"> </FORM> <FORM NAME="billing_bottomform" STYLE="margin-top: 0; margin-bottom: 0"> - <INPUT TYPE="hidden" NAME="tax" VALUE="<%= $cust_main->tax %>"> + <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax %>"> - <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<%= join(', ', @invoicing_list) %>"> + <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<% join(', ', @invoicing_list) %>"> </FORM> +% } else { +% +% my $r = qq!<font color="#ff0000">*</font> !; +% +% -<% } else { - - my $r = qq!<font color="#ff0000">*</font> !; - -%> <BR>Billing information - <%= &ntable("#cccccc") %> + <% &ntable("#cccccc") %> <TR> - <TD ALIGN="right" WIDTH="200"><%=$r%>Billing type</TD> + <TD ALIGN="right" WIDTH="200"><%$r%>Billing type</TD> <SCRIPT> @@ -133,274 +134,274 @@ if ( $payby_default eq 'HIDE' ) { +'<div>[iframe not supported]</div></iframe>'); } </SCRIPT> - - <% - - my($payby, $payinfo, $payname)=( - $cust_main->payby, - $cust_main->payinfo, - $cust_main->payname, - ); - my( $account, $aba ) = split('@', $payinfo); - - my $disabled = 'DISABLED style="background-color: #dddddd"'; - my $text_disabled = 'style="color: #999999"'; - if ( $payby =~ /^(CARD|DCRD)$/ && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) { - $disabled = 'style="background-color: #ffffff"'; - $text_disabled = 'style="color: #000000";' - } - - my %payby = ( - - 'CARD' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Card number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $payinfo : '' ). qq!" MAXLENGTH=19 onChange="card_changed(this)" onKeyUp="card_changed(this)"></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'exp', - 'selected_date' => - ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paydate : '' ), - ). - - '</TD></TR>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">CVV2 !. - - qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!. - qq!</TD>!. - '<TD WIDTH="408"><INPUT TYPE="text" NAME="paycvv" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paycvv : '' ). '" SIZE=4 MAXLENGTH=4>'. - - - qq!<TR><TD ALIGN="right" WIDTH="200"><SPAN ID="paystart_label" $text_disabled>Start date </SPAN></TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'paystart', - 'disabled' => $disabled, - 'empty_option' => 1, - 'start_year' => 2000, - 'end_year' => (localtime())[5] + 1900, - 'selected_date' => ( - ( $payby =~ /^(CARD|DCRD)$/ - && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) - ? $cust_main->paystart_month. '-'. - $cust_main->paystart_year - : '' - ) - ). - - qq!<SPAN ID="payissue_label" $text_disabled> or Issue number </SPAN>!. - '<INPUT TYPE="text" NAME="payissue" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payissue : '' ). qq!" SIZE=3 MAXLENGTH=2 $disabled></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Exact name on card </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCRD' ? '' : 'CHECKED' ). '> Charge future payments to this card automatically</TD></TR>'. - - '</TABLE>', - - 'CHEK' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Account number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD></TR>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}ABA/Routing number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $aba : '' ). qq!" SIZE=10 MAXLENGTH=9> !. - qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!. - qq!</TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Bank name </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCHK' ? '' : 'CHECKED' ). '> Charge future payments to this electronic check automatically</TD></TR>'. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'LECB' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Phone number </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'LECB' ? $cust_main->payinfo : '' ). qq!" MAXLENGTH=15 SIZE=16></TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - qq!<INPUT TYPE="hidden" NAME="payname" VALUE="">!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'BILL' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">P.O. </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payinfo : '' ). qq!"></TD></TR>!. - - qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. - qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. - - qq!<TR><TD ALIGN="right" WIDTH="200">Attention </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payname : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'COMP' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Approved by </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE=""></TD></TR>!. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!. - '<TD WIDTH="408">'. - - include('/elements/select-month_year.html', - 'prefix' => 'exp', - 'selected_date' => - ( $payby eq 'COMP' ? $cust_main->paydate : '' ), - ). - - '</TD></TR>'. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'CASH' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'CASH' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'WEST' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'WEST' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - 'MCRD' => - - '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. - - qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. - qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'MCRD' ? $cust_main->paid : '' ). qq!"></TD></TR>!. - - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - '<TR><TD> </TD></TR>'. - - '</TABLE>', - - ); - - #this should use FS::payby - my %allopt = ( - 'CARD' => 'Credit card', - 'CHEK' => 'Electronic check', - 'LECB' => 'Phone bill billing', - 'BILL' => 'Billing', - 'CASH' => 'Cash', # initial payment, then billing', - 'WEST' => 'Western Union', # initial payment, then billing', - 'MCRD' => 'Manual credit card', # initial payment, then billing', - 'COMP' => 'Complimentary', - ); - if ( $cust_main->custnum ) { #don't offer CASH/WEST/MCRD initial payment types - # when editing customer - delete $allopt{$_} for qw(CASH WEST MCRD); - } - - tie my %options, 'Tie::IxHash', - map { $_ => $allopt{$_} } - grep { exists $allopt{$_} } - @payby; - - my %payby2option = ( - ( map { $_ => $_ } keys %options ), - 'DCRD' => 'CARD', - 'DCHK' => 'CHEK', - ); - - my $widget = new HTML::Widgets::SelectLayers( - 'options' => \%options, - #'form_name' => 'dummy', - #'form_action' => 'nothingyet', - #chops bottom of page in IE# 'under_position' => 'absolute', - 'html_between' => '</TD></TR></TABLE>', - 'selected_layer' => $payby2option{$payby || $payby_default || $payby[0] }, - 'layer_callback' => sub { my $layer = shift; $payby{$layer}; }, - ); - - %> - - <TD WIDTH="408"><%= $widget->html %> +% +% +% my($payby, $payinfo, $payname)=( +% $cust_main->payby, +% $cust_main->payinfo, +% $cust_main->payname, +% ); +% my( $account, $aba ) = split('@', $payinfo); +% +% my $disabled = 'DISABLED style="background-color: #dddddd"'; +% my $text_disabled = 'style="color: #999999"'; +% if ( $payby =~ /^(CARD|DCRD)$/ && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) { +% $disabled = 'style="background-color: #ffffff"'; +% $text_disabled = 'style="color: #000000";' +% } +% +% my %payby = ( +% +% 'CARD' => +% +% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Card number </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $payinfo : '' ). qq!" MAXLENGTH=19 onChange="card_changed(this)" onKeyUp="card_changed(this)"></TD></TR>!. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!. +% '<TD WIDTH="408">'. +% +% include('/elements/select-month_year.html', +% 'prefix' => 'exp', +% 'selected_date' => +% ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paydate : '' ), +% ). +% +% '</TD></TR>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">CVV2 !. +% +% qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!. +% qq!</TD>!. +% '<TD WIDTH="408"><INPUT TYPE="text" NAME="paycvv" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paycvv : '' ). '" SIZE=4 MAXLENGTH=4>'. +% +% +% qq!<TR><TD ALIGN="right" WIDTH="200"><SPAN ID="paystart_label" $text_disabled>Start date </SPAN></TD>!. +% '<TD WIDTH="408">'. +% +% include('/elements/select-month_year.html', +% 'prefix' => 'paystart', +% 'disabled' => $disabled, +% 'empty_option' => 1, +% 'start_year' => 2000, +% 'end_year' => (localtime())[5] + 1900, +% 'selected_date' => ( +% ( $payby =~ /^(CARD|DCRD)$/ +% && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) +% ? $cust_main->paystart_month. '-'. +% $cust_main->paystart_year +% : '' +% ) +% ). +% +% qq!<SPAN ID="payissue_label" $text_disabled> or Issue number </SPAN>!. +% '<INPUT TYPE="text" NAME="payissue" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payissue : '' ). qq!" SIZE=3 MAXLENGTH=2 $disabled></TD></TR>!. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Exact name on card </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!. +% +% qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCRD' ? '' : 'CHECKED' ). '> Charge future payments to this card automatically</TD></TR>'. +% +% '</TABLE>', +% +% 'CHEK' => +% +% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Account number </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD></TR>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}ABA/Routing number </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $aba : '' ). qq!" SIZE=10 MAXLENGTH=9> !. +% qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!. +% qq!</TD></TR>!. +% +% qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. +% qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Bank name </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!. +% +% qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCHK' ? '' : 'CHECKED' ). '> Charge future payments to this electronic check automatically</TD></TR>'. +% +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% +% '</TABLE>', +% +% 'LECB' => +% +% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Phone number </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'LECB' ? $cust_main->payinfo : '' ). qq!" MAXLENGTH=15 SIZE=16></TD></TR>!. +% +% qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. +% qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. +% qq!<INPUT TYPE="hidden" NAME="payname" VALUE="">!. +% +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% +% '</TABLE>', +% +% 'BILL' => +% +% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">P.O. </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payinfo : '' ). qq!"></TD></TR>!. +% +% qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!. +% qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">Attention </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payname : '' ). qq!"></TD></TR>!. +% +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% +% '</TABLE>', +% +% 'COMP' => +% +% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Approved by </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE=""></TD></TR>!. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!. +% '<TD WIDTH="408">'. +% +% include('/elements/select-month_year.html', +% 'prefix' => 'exp', +% 'selected_date' => +% ( $payby eq 'COMP' ? $cust_main->paydate : '' ), +% ). +% +% '</TD></TR>'. +% +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% +% '</TABLE>', +% +% 'CASH' => +% +% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'CASH' ? $cust_main->paid : '' ). qq!"></TD></TR>!. +% +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% +% '</TABLE>', +% +% 'WEST' => +% +% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'WEST' ? $cust_main->paid : '' ). qq!"></TD></TR>!. +% +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% +% '</TABLE>', +% +% 'MCRD' => +% +% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'. +% +% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!. +% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="paid" VALUE="!. ( $payby eq 'MCRD' ? $cust_main->paid : '' ). qq!"></TD></TR>!. +% +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% '<TR><TD> </TD></TR>'. +% +% '</TABLE>', +% +% ); +% +% #this should use FS::payby +% my %allopt = ( +% 'CARD' => 'Credit card', +% 'CHEK' => 'Electronic check', +% 'LECB' => 'Phone bill billing', +% 'BILL' => 'Billing', +% 'CASH' => 'Cash', # initial payment, then billing', +% 'WEST' => 'Western Union', # initial payment, then billing', +% 'MCRD' => 'Manual credit card', # initial payment, then billing', +% 'COMP' => 'Complimentary', +% ); +% if ( $cust_main->custnum ) { #don't offer CASH/WEST/MCRD initial payment types +% # when editing customer +% delete $allopt{$_} for qw(CASH WEST MCRD); +% } +% +% tie my %options, 'Tie::IxHash', +% map { $_ => $allopt{$_} } +% grep { exists $allopt{$_} } +% @payby; +% +% my %payby2option = ( +% ( map { $_ => $_ } keys %options ), +% 'DCRD' => 'CARD', +% 'DCHK' => 'CHEK', +% ); +% +% my $widget = new HTML::Widgets::SelectLayers( +% 'options' => \%options, +% #'form_name' => 'dummy', +% #'form_action' => 'nothingyet', +% #chops bottom of page in IE# 'under_position' => 'absolute', +% 'html_between' => '</TD></TR></TABLE>', +% 'selected_layer' => $payby2option{$payby || $payby_default || $payby[0] }, +% 'layer_callback' => sub { my $layer = shift; $payby{$layer}; }, +% ); +% +% + + + <TD WIDTH="408"><% $widget->html %> <FORM NAME="billing_bottomform" STYLE="margin-top: 0; margin-bottom: 0"> - <%= &ntable("#cccccc") %> + <% &ntable("#cccccc") %> <TR><TD> </TD></TR> <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <%= $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt</TD> + <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <% $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt</TD> </TR> <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST" <%= + <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST" <% ( ( ! @invoicing_list && ! $conf->exists('disablepostalinvoicedefault') @@ -417,7 +418,7 @@ if ( $payby_default eq 'HIDE' ) { </TR> <TR> - <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <%= + <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'CHECKED' @@ -430,22 +431,24 @@ if ( $payby_default eq 'HIDE' ) { <TR> <TD ALIGN="right" WIDTH="200">Email invoice </TD> - <TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<%= join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></TD> + <TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></TD> </TR> +% if ( $conf->exists('voip-cust_cdr_spools') ) { - <% if ( $conf->exists('voip-cust_cdr_spools') ) { %> <TR> - <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="spool_cdr" VALUE="Y" <%= $cust_main->spool_cdr eq "Y" ? 'CHECKED' : '' %>> Spool CDRs</TD> + <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="spool_cdr" VALUE="Y" <% $cust_main->spool_cdr eq "Y" ? 'CHECKED' : '' %>> Spool CDRs</TD> </TR> - <% } else { %> - <INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<%= $cust_main->spool_cdr %>"> - <% } %> +% } else { + + <INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>"> +% } + </TABLE> </FORM> - <%= $r %> required fields + <% $r %> required fields +% } -<% } %> diff --git a/httemplate/edit/cust_main/contact.html b/httemplate/edit/cust_main/contact.html index 6e4f08957..a001634a2 100644 --- a/httemplate/edit/cust_main/contact.html +++ b/httemplate/edit/cust_main/contact.html @@ -1,125 +1,128 @@ -<% - -my( $cust_main, $pre, $onchange, $disabled ) = @_; -my $conf = new FS::Conf; - -#false laziness with ship state -my $countrydefault = $conf->config('countrydefault') || 'US'; -$cust_main->set($pre.'country', $countrydefault ) - unless $cust_main->get($pre.'country'); - -my $statedefault = $conf->config('statedefault') - || ($countrydefault eq 'US' ? 'CA' : ''); -$cust_main->set($pre.'state', $statedefault ) - unless $cust_main->get($pre.'state') - || $cust_main->get($pre.'country') ne $countrydefault; - -#my($county_html, $state_html, $country_html) = -# FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), -# $cust_main->get($pre.'state'), -# $cust_main->get($pre.'country'), -# $pre, -# $onchange, -# $disabled, -# ); - -my %select_hash = ( - 'county' => $cust_main->get($pre.'county'), - 'state' => $cust_main->get($pre.'state'), - 'country' => $cust_main->get($pre.'country'), - 'prefix' => $pre, - 'onchange' => $onchange, - 'disabled' => $disabled, -); - -my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; -my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; - -my $r = qq!<font color="#ff0000">*</font> !; - -%> - -<%= &ntable("#cccccc") %> +% +% +%my( $cust_main, $pre, $onchange, $disabled ) = @_; +%my $conf = new FS::Conf; +% +%#false laziness with ship state +%my $countrydefault = $conf->config('countrydefault') || 'US'; +%$cust_main->set($pre.'country', $countrydefault ) +% unless $cust_main->get($pre.'country'); +% +%my $statedefault = $conf->config('statedefault') +% || ($countrydefault eq 'US' ? 'CA' : ''); +%$cust_main->set($pre.'state', $statedefault ) +% unless $cust_main->get($pre.'state') +% || $cust_main->get($pre.'country') ne $countrydefault; +% +%#my($county_html, $state_html, $country_html) = +%# FS::cust_main_county::regionselector( $cust_main->get($pre.'county'), +%# $cust_main->get($pre.'state'), +%# $cust_main->get($pre.'country'), +%# $pre, +%# $onchange, +%# $disabled, +%# ); +% +%my %select_hash = ( +% 'county' => $cust_main->get($pre.'county'), +% 'state' => $cust_main->get($pre.'state'), +% 'country' => $cust_main->get($pre.'country'), +% 'prefix' => $pre, +% 'onchange' => $onchange, +% 'disabled' => $disabled, +%); +% +%my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; +%my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; +% +%my $r = qq!<font color="#ff0000">*</font> !; +% +% + + +<% &ntable("#cccccc") %> <TR> - <TH ALIGN="right"><%=$r%>Contact name<BR>(last, first)</TH> + <TH ALIGN="right"><%$r%>Contact name<BR>(last, first)</TH> <TD COLSPAN=3> - <INPUT TYPE="text" NAME="<%=$pre%>last" VALUE="<%= $cust_main->get($pre.'last') %>" onChange="<%= $onchange %>" <%=$disabled%>> , - <INPUT TYPE="text" NAME="<%=$pre%>first" VALUE="<%= $cust_main->get($pre.'first') %>" onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>last" VALUE="<% $cust_main->get($pre.'last') %>" onChange="<% $onchange %>" <%$disabled%>> , + <INPUT TYPE="text" NAME="<%$pre%>first" VALUE="<% $cust_main->get($pre.'first') %>" onChange="<% $onchange %>" <%$disabled%>> </TD> +% if ( $conf->exists('show_ss') && !$pre ) { -<% if ( $conf->exists('show_ss') && !$pre ) { %> <TD ALIGN="right">SS#</TD> - <TD><INPUT TYPE="text" NAME="ss" VALUE="<%= $cust_main->ss %>" SIZE=11></TD> -<% } elsif ( !$pre ) { %> - <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<%= $cust_main->ss %>"></TD> -<% } %> + <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $cust_main->ss %>" SIZE=11></TD> +% } elsif ( !$pre ) { + + <TD><INPUT TYPE="hidden" NAME="ss" VALUE="<% $cust_main->ss %>"></TD> +% } + </TR> <TR> <TD ALIGN="right">Company</TD> <TD COLSPAN=5> - <INPUT TYPE="text" NAME="<%=$pre%>company" VALUE="<%= $cust_main->get($pre.'company') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>company" VALUE="<% $cust_main->get($pre.'company') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> <TR> - <TH ALIGN="right"><%=$r%>Address</TH> + <TH ALIGN="right"><%$r%>Address</TH> <TD COLSPAN=5> - <INPUT TYPE="text" NAME="<%=$pre%>address1" VALUE="<%= $cust_main->get($pre.'address1') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>address1" VALUE="<% $cust_main->get($pre.'address1') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> <TR> <TD ALIGN="right"> </TD> <TD COLSPAN=5> - <INPUT TYPE="text" NAME="<%=$pre%>address2" VALUE="<%= $cust_main->get($pre.'address2') %>" SIZE=70 onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>address2" VALUE="<% $cust_main->get($pre.'address2') %>" SIZE=70 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> <TR> - <TH ALIGN="right"><%=$r%>City</TH> + <TH ALIGN="right"><%$r%>City</TH> <TD> - <INPUT TYPE="text" NAME="<%=$pre%>city" VALUE="<%= $cust_main->get($pre.'city') %>" onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>city" VALUE="<% $cust_main->get($pre.'city') %>" onChange="<% $onchange %>" <%$disabled%>> </TD> - <TH ALIGN="right"><%=$r%>State</TH> + <TH ALIGN="right"><%$r%>State</TH> <TD> - <%= include('select-county.html', %select_hash ) %> - <%= include('select-state.html', %select_hash ) %> + <% include('select-county.html', %select_hash ) %> + <% include('select-state.html', %select_hash ) %> </TD> - <TH><%=$r%>Zip</TH> + <TH><%$r%>Zip</TH> <TD> - <INPUT TYPE="text" NAME="<%=$pre%>zip" VALUE="<%= $cust_main->get($pre.'zip') %>" SIZE=10 onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>zip" VALUE="<% $cust_main->get($pre.'zip') %>" SIZE=10 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> <TR> - <TH ALIGN="right"><%=$r%>Country</TH> - <TD COLSPAN=5><%= include('select-country.html', %select_hash ) %></TD> + <TH ALIGN="right"><%$r%>Country</TH> + <TD COLSPAN=5><% include('select-country.html', %select_hash ) %></TD> </TR> <TR> - <TD ALIGN="right"><%= $daytime_label %></TD> + <TD ALIGN="right"><% $daytime_label %></TD> <TD COLSPAN=5> - <INPUT TYPE="text" NAME="<%=$pre%>daytime" VALUE="<%= $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>daytime" VALUE="<% $cust_main->get($pre.'daytime') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> <TR> - <TD ALIGN="right"><%= $night_label %></TD> + <TD ALIGN="right"><% $night_label %></TD> <TD COLSPAN=5> - <INPUT TYPE="text" NAME="<%=$pre%>night" VALUE="<%= $cust_main->get($pre.'night') %>" SIZE=18 onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>night" VALUE="<% $cust_main->get($pre.'night') %>" SIZE=18 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> <TR> <TD ALIGN="right">Fax</TD> <TD COLSPAN=5> - <INPUT TYPE="text" NAME="<%=$pre%>fax" VALUE="<%= $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<%= $onchange %>" <%=$disabled%>> + <INPUT TYPE="text" NAME="<%$pre%>fax" VALUE="<% $cust_main->get($pre.'fax') %>" SIZE=12 onChange="<% $onchange %>" <%$disabled%>> </TD> </TR> </TABLE> -<%=$r%>required fields<BR> +<%$r%>required fields<BR> diff --git a/httemplate/edit/cust_main/select-country.html b/httemplate/edit/cust_main/select-country.html index 3941f2f93..5467f26e9 100644 --- a/httemplate/edit/cust_main/select-country.html +++ b/httemplate/edit/cust_main/select-country.html @@ -1,16 +1,17 @@ -<% - - my %opt = @_; - foreach my $opt (qw( county state country prefix onchange disabled )) { - $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); - } - - my $conf = new FS::Conf; - my $countrydefault = $conf->config('countrydefault') || 'US'; - -%> - -<%= include('/elements/xmlhttp.html', +% +% +% my %opt = @_; +% foreach my $opt (qw( county state country prefix onchange disabled )) { +% $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); +% } +% +% my $conf = new FS::Conf; +% my $countrydefault = $conf->config('countrydefault') || 'US'; +% +% + + +<% include('/elements/xmlhttp.html', 'url' => $p.'misc/states.cgi', 'subs' => [ $opt{'prefix'}. 'get_states' ], ) @@ -24,15 +25,15 @@ what.options[length] = optionName; } - function <%= $opt{'prefix'} %>country_changed(what, callback) { + function <% $opt{'prefix'} %>country_changed(what, callback) { country = what.options[what.selectedIndex].value; - function <%= $opt{'prefix'} %>update_states(states) { + function <% $opt{'prefix'} %>update_states(states) { // blank the current state list - for ( var i = what.form.<%= $opt{'prefix'} %>state.length; i >= 0; i-- ) - what.form.<%= $opt{'prefix'} %>state.options[i] = null; + for ( var i = what.form.<% $opt{'prefix'} %>state.length; i >= 0; i-- ) + what.form.<% $opt{'prefix'} %>state.options[i] = null; // add the new states var statesArray = eval('(' + states + ')' ); @@ -40,7 +41,7 @@ var stateLabel = statesArray[s+1]; if ( stateLabel == "" ) stateLabel = '(n/a)'; - opt(what.form.<%= $opt{'prefix'} %>state, statesArray[s], stateLabel); + opt(what.form.<% $opt{'prefix'} %>state, statesArray[s], stateLabel); } //run the callback @@ -49,25 +50,25 @@ } // go get the new states - <%= $opt{'prefix'} %>get_states( country, <%= $opt{'prefix'} %>update_states ); + <% $opt{'prefix'} %>get_states( country, <% $opt{'prefix'} %>update_states ); } </SCRIPT> -<SELECT NAME="<%= $opt{'prefix'} %>country" onChange="<%= $opt{'prefix'} %>country_changed(this); <%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>> +<SELECT NAME="<% $opt{'prefix'} %>country" onChange="<% $opt{'prefix'} %>country_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>> +% foreach my $country ( +% sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) +% or code2country($a) cmp code2country($b) } +% map { $_->country } +% qsearch( 'cust_main_county',{}, 'DISTINCT ON ( country ) *', ) +% ) { +% -<% foreach my $country ( - sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) - or code2country($a) cmp code2country($b) } - map { $_->country } - qsearch( 'cust_main_county',{}, 'DISTINCT ON ( country ) *', ) - ) { -%> - <OPTION VALUE="<%= $country %>"<%= $country eq $opt{'country'} ? ' SELECTED' : '' %>><%= code2country($country). " ($country)" %> + <OPTION VALUE="<% $country %>"<% $country eq $opt{'country'} ? ' SELECTED' : '' %>><% code2country($country). " ($country)" %> +% } -<% } %> </SELECT> diff --git a/httemplate/edit/cust_main/select-county.html b/httemplate/edit/cust_main/select-county.html index 3de380b31..70939fca5 100644 --- a/httemplate/edit/cust_main/select-county.html +++ b/httemplate/edit/cust_main/select-county.html @@ -1,21 +1,21 @@ -<% - - my %opt = @_; - foreach my $opt (qw( county state country prefix onchange disabled )) { - $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); - } - - my $sql = "SELECT COUNT(*) FROM cust_main_county". - " WHERE county IS NOT NULL AND county != ''"; - my $sth = dbh->prepare($sql) or die dbh->errstr; - $sth->execute or die $sth->errstr; - my $countyflag = $sth->fetchrow_arrayref->[0]; - -%> - -<% if ( $countyflag ) { %> - - <%= include('/elements/xmlhttp.html', +% +% +% my %opt = @_; +% foreach my $opt (qw( county state country prefix onchange disabled )) { +% $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); +% } +% +% my $sql = "SELECT COUNT(*) FROM cust_main_county". +% " WHERE county IS NOT NULL AND county != ''"; +% my $sth = dbh->prepare($sql) or die dbh->errstr; +% $sth->execute or die $sth->errstr; +% my $countyflag = $sth->fetchrow_arrayref->[0]; +% +% +% if ( $countyflag ) { + + + <% include('/elements/xmlhttp.html', 'url' => $p.'misc/counties.cgi', 'subs' => [ $opt{'prefix'}. 'get_counties' ], ) @@ -29,16 +29,16 @@ what.options[length] = optionName; } - function <%= $opt{'prefix'} %>state_changed(what, callback) { + function <% $opt{'prefix'} %>state_changed(what, callback) { state = what.options[what.selectedIndex].text; - country = what.form.<%= $opt{'prefix'} %>country.options[what.form.<%= $opt{'prefix'} %>country.selectedIndex].text; + country = what.form.<% $opt{'prefix'} %>country.options[what.form.<% $opt{'prefix'} %>country.selectedIndex].text; - function <%= $opt{'prefix'} %>update_counties(counties) { + function <% $opt{'prefix'} %>update_counties(counties) { // blank the current county list - for ( var i = what.form.<%= $opt{'prefix'} %>county.length; i >= 0; i-- ) - what.form.<%= $opt{'prefix'} %>county.options[i] = null; + for ( var i = what.form.<% $opt{'prefix'} %>county.length; i >= 0; i-- ) + what.form.<% $opt{'prefix'} %>county.options[i] = null; // add the new counties var countiesArray = eval('(' + counties + ')' ); @@ -46,7 +46,7 @@ var countyLabel = countiesArray[s]; if ( countyLabel == "" ) countyLabel = '(n/a)'; - opt(what.form.<%= $opt{'prefix'} %>county, countiesArray[s], countyLabel); + opt(what.form.<% $opt{'prefix'} %>county, countiesArray[s], countyLabel); } //run the callback @@ -55,37 +55,37 @@ } // go get the new counties - <%= $opt{'prefix'} %>get_counties( state, country, <%= $opt{'prefix'} %>update_counties ); + <% $opt{'prefix'} %>get_counties( state, country, <% $opt{'prefix'} %>update_counties ); } </SCRIPT> - <SELECT NAME="<%= $opt{'prefix'} %>county" onChange="<%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>> + <SELECT NAME="<% $opt{'prefix'} %>county" onChange="<% $opt{'onchange'} %>" <% $opt{'disabled'} %>> +% foreach my $county ( +% sort +% map { $_->county } +% qsearch('cust_main_county', { 'state' => $opt{'state'}, +% 'country' => $opt{'country'}, +% } +% ) +% ) { +% - <% foreach my $county ( - sort - map { $_->county } - qsearch('cust_main_county', { 'state' => $opt{'state'}, - 'country' => $opt{'country'}, - } - ) - ) { - %> - <OPTION VALUE="<%= $county %>"<%= $county eq $opt{'county'} ? ' SELECTED' : '' %>><%= $county %> + <OPTION VALUE="<% $county %>"<% $county eq $opt{'county'} ? ' SELECTED' : '' %>><% $county %> +% } - <% } %> </SELECT> +% } else { -<% } else { %> <SCRIPT TYPE="text/javascript"> - function <%= $opt{'prefix'} %>state_changed(what) { + function <% $opt{'prefix'} %>state_changed(what) { } </SCRIPT> - <INPUT TYPE="hidden" NAME="<%= $opt{'prefix'} %>county" VALUE="<%= $opt{'county'} %>"> + <INPUT TYPE="hidden" NAME="<% $opt{'prefix'} %>county" VALUE="<% $opt{'county'} %>"> +% } -<% } %> diff --git a/httemplate/edit/cust_main/select-state.html b/httemplate/edit/cust_main/select-state.html index 64da36ba7..a7e56e78f 100644 --- a/httemplate/edit/cust_main/select-state.html +++ b/httemplate/edit/cust_main/select-state.html @@ -1,20 +1,21 @@ -<% +% +% +% my %opt = @_; +% foreach my $opt (qw( county state country prefix onchange disabled )) { +% $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); +% } +% +% - my %opt = @_; - foreach my $opt (qw( county state country prefix onchange disabled )) { - $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); - } -%> +<SELECT NAME="<% $opt{'prefix'} %>state" onChange="<% $opt{'prefix'} %>state_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>> +% tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); +% foreach my $state ( keys %states ) { -<SELECT NAME="<%= $opt{'prefix'} %>state" onChange="<%= $opt{'prefix'} %>state_changed(this); <%= $opt{'onchange'} %>" <%= $opt{'disabled'} %>> -<% tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); %> -<% foreach my $state ( keys %states ) { %> + <OPTION VALUE="<% $state %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' %> +% } - <OPTION VALUE="<%= $state %>"<%= $state eq $opt{'state'} ? ' SELECTED' : '' %>><%= $states{$state} || '(n/a)' %> - -<% } %> </SELECT> diff --git a/httemplate/edit/cust_main_county-expand.cgi b/httemplate/edit/cust_main_county-expand.cgi index 9f314a457..01f0c1e0c 100755 --- a/httemplate/edit/cust_main_county-expand.cgi +++ b/httemplate/edit/cust_main_county-expand.cgi @@ -1,54 +1,55 @@ <!-- mason kludge --> -<% +% +% +%my($taxnum, $delim, $expansion, $taxclass ); +%my($query) = $cgi->keywords; +%if ( $cgi->param('error') ) { +% $taxnum = $cgi->param('taxnum'); +% $delim = $cgi->param('delim'); +% $expansion = $cgi->param('expansion'); +% $taxclass = $cgi->param('taxclass'); +%} else { +% $query =~ /^(taxclass)?(\d+)$/ +% or die "Illegal taxnum (query $query)"; +% $taxclass = $1 ? 'taxclass' : ''; +% $taxnum = $2; +% $delim = 'n'; +% $expansion = ''; +%} +% +%my $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum}) +% or die "cust_main_county.taxnum $taxnum not found"; +%die "Can't expand entry!" if $cust_main_county->getfield('county'); +% +%my $p1 = popurl(1); +%print header("Tax Rate (expand)", menubar( +% 'Main Menu' => popurl(2), +%)); +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT>" +% if $cgi->param('error'); +% +%print <<END; +% <FORM ACTION="${p1}process/cust_main_county-expand.cgi" METHOD=POST> +% <INPUT TYPE="hidden" NAME="taxnum" VALUE="$taxnum"> +% <INPUT TYPE="hidden" NAME="taxclass" VALUE="$taxclass"> +% Separate by +%END +%print '<INPUT TYPE="radio" NAME="delim" VALUE="n"'; +%print ' CHECKED' if $delim eq 'n'; +%print '>line (broken on some browsers) or', +% '<INPUT TYPE="radio" NAME="delim" VALUE="s"'; +%print ' CHECKED' if $delim eq 's'; +%print '>whitespace.'; +%print <<END; +% <BR><INPUT TYPE="submit" VALUE="Submit"> +% <BR><TEXTAREA NAME="expansion" ROWS=100>$expansion</TEXTAREA> +% </FORM> +% </CENTER> +% </BODY> +%</HTML> +%END +% +% -my($taxnum, $delim, $expansion, $taxclass ); -my($query) = $cgi->keywords; -if ( $cgi->param('error') ) { - $taxnum = $cgi->param('taxnum'); - $delim = $cgi->param('delim'); - $expansion = $cgi->param('expansion'); - $taxclass = $cgi->param('taxclass'); -} else { - $query =~ /^(taxclass)?(\d+)$/ - or die "Illegal taxnum (query $query)"; - $taxclass = $1 ? 'taxclass' : ''; - $taxnum = $2; - $delim = 'n'; - $expansion = ''; -} - -my $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum}) - or die "cust_main_county.taxnum $taxnum not found"; -die "Can't expand entry!" if $cust_main_county->getfield('county'); - -my $p1 = popurl(1); -print header("Tax Rate (expand)", menubar( - 'Main Menu' => popurl(2), -)); - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); - -print <<END; - <FORM ACTION="${p1}process/cust_main_county-expand.cgi" METHOD=POST> - <INPUT TYPE="hidden" NAME="taxnum" VALUE="$taxnum"> - <INPUT TYPE="hidden" NAME="taxclass" VALUE="$taxclass"> - Separate by -END -print '<INPUT TYPE="radio" NAME="delim" VALUE="n"'; -print ' CHECKED' if $delim eq 'n'; -print '>line (broken on some browsers) or', - '<INPUT TYPE="radio" NAME="delim" VALUE="s"'; -print ' CHECKED' if $delim eq 's'; -print '>whitespace.'; -print <<END; - <BR><INPUT TYPE="submit" VALUE="Submit"> - <BR><TEXTAREA NAME="expansion" ROWS=100>$expansion</TEXTAREA> - </FORM> - </CENTER> - </BODY> -</HTML> -END - -%> diff --git a/httemplate/edit/cust_main_county.cgi b/httemplate/edit/cust_main_county.cgi index 4bcfcbe9b..7d1354d3e 100755 --- a/httemplate/edit/cust_main_county.cgi +++ b/httemplate/edit/cust_main_county.cgi @@ -1,98 +1,99 @@ <!-- mason kludge --> -<% +% +% +%print header("Edit tax rates", menubar( +% 'Main Menu' => popurl(2), +%)); +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT>" +% if $cgi->param('error'); +% +%print qq!<FORM ACTION="!, popurl(1), +% qq!process/cust_main_county.cgi" METHOD=POST>!, &table(), <<END; +% <TR> +% <TH><FONT SIZE=-1>Country</FONT></TH> +% <TH><FONT SIZE=-1>State</FONT></TH> +% <TH><FONT SIZE=-1>County</FONT></TH> +% <TH><FONT SIZE=-1>Taxclass</FONT><BR><FONT SIZE=-2>(per-package classification)</FONT></TH> +%END +% +%if ( dbdef->table('cust_main_county')->column('taxname') ) { +% print '<TH><FONT SIZE=-1>Tax name</FONT><BR><FONT SIZE=-2>(printed on invoices)</FONT></TH>'; +%} +% +%print <<END; +% <TH><FONT SIZE=-1>Tax</FONT></TH> +% <TH><FONT SIZE=-1>Exempt<BR>per<BR>month</TH> +%END +% +%if ( dbdef->table('cust_main_county')->column('setuptax') ) { +% print '<TH><FONT SIZE=-1>Setup<BR>fee<BR>exempt</TH>'; +%} +%if ( dbdef->table('cust_main_county')->column('recurtax') ) { +% print '<TH><FONT SIZE=-1>Recurring<BR>fee<BR>exempt</TH>'; +%} +% +%print '</TR>'; +% +%foreach my $cust_main_county ( sort { $a->country cmp $b->country +% or $a->state cmp $b->state +% or $a->county cmp $b->county +% } qsearch('cust_main_county',{}) ) { +% my($hashref)=$cust_main_county->hashref; +% print <<END; +% <TR> +% <TD BGCOLOR="#ffffff">$hashref->{country}</TD> +%END +% +% print "<TD", $hashref->{state} +% ? ' BGCOLOR="#ffffff">'.$hashref->{state} +% : ' BGCOLOR="#cccccc">(ALL)' +% , "</TD>"; +% +% print "<TD", $hashref->{county} +% ? ' BGCOLOR="#ffffff">'. $hashref->{county} +% : ' BGCOLOR="#cccccc">(ALL)' +% , "</TD>"; +% +% print "<TD", $hashref->{taxclass} +% ? ' BGCOLOR="#ffffff">'. $hashref->{taxclass} +% : ' BGCOLOR="#cccccc">(ALL)' +% , "</TD>"; +% +% print qq!<TD><INPUT TYPE="text" NAME="taxname!, $hashref->{taxnum}, +% qq!" VALUE="!, $hashref->{taxname}, qq!"></TD>! +% if dbdef->table('cust_main_county')->column('taxname'); +% +% print qq!<TD><TABLE><TR><TD><INPUT TYPE="text" NAME="tax!, $hashref->{taxnum}, +% qq!" VALUE="!, $hashref->{tax}, qq!" SIZE=6 MAXLENGTH=6></TD><TD>%</TD></TR></TABLE></TD>!; +% print qq!<TD><TABLE><TR><TD>\$</TD><TD><INPUT TYPE="text" NAME="exempt_amount!, $hashref->{taxnum}, +% qq!" VALUE="!, $hashref->{exempt_amount}||0, qq!" SIZE=6></TD></TR></TABLE></TD>!; +% +% print qq!<TD><INPUT TYPE="checkbox" NAME="setuptax!. $hashref->{taxnum}. +% '" VALUE="Y"'. +% ( $hashref->{setuptax} =~ /^Y$/i ? ' CHECKED' : '' ). +% '></TD>' +% if dbdef->table('cust_main_county')->column('setuptax'); +% +% print qq!<TD><INPUT TYPE="checkbox" NAME="recurtax!. $hashref->{taxnum}. +% '" VALUE="Y"'. +% ( $hashref->{recurtax} =~ /^Y$/i ? ' CHECKED' : '' ). +% '></TD>' +% if dbdef->table('cust_main_county')->column('recurtax'); +% +% print '</TR>'; +% +%} +% +%print <<END; +% </TABLE> +% <INPUT TYPE="submit" VALUE="Apply changes"> +% </FORM> +% </CENTER> +% </BODY> +%</HTML> +%END +% +% -print header("Edit tax rates", menubar( - 'Main Menu' => popurl(2), -)); - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); - -print qq!<FORM ACTION="!, popurl(1), - qq!process/cust_main_county.cgi" METHOD=POST>!, &table(), <<END; - <TR> - <TH><FONT SIZE=-1>Country</FONT></TH> - <TH><FONT SIZE=-1>State</FONT></TH> - <TH><FONT SIZE=-1>County</FONT></TH> - <TH><FONT SIZE=-1>Taxclass</FONT><BR><FONT SIZE=-2>(per-package classification)</FONT></TH> -END - -if ( dbdef->table('cust_main_county')->column('taxname') ) { - print '<TH><FONT SIZE=-1>Tax name</FONT><BR><FONT SIZE=-2>(printed on invoices)</FONT></TH>'; -} - -print <<END; - <TH><FONT SIZE=-1>Tax</FONT></TH> - <TH><FONT SIZE=-1>Exempt<BR>per<BR>month</TH> -END - -if ( dbdef->table('cust_main_county')->column('setuptax') ) { - print '<TH><FONT SIZE=-1>Setup<BR>fee<BR>exempt</TH>'; -} -if ( dbdef->table('cust_main_county')->column('recurtax') ) { - print '<TH><FONT SIZE=-1>Recurring<BR>fee<BR>exempt</TH>'; -} - -print '</TR>'; - -foreach my $cust_main_county ( sort { $a->country cmp $b->country - or $a->state cmp $b->state - or $a->county cmp $b->county - } qsearch('cust_main_county',{}) ) { - my($hashref)=$cust_main_county->hashref; - print <<END; - <TR> - <TD BGCOLOR="#ffffff">$hashref->{country}</TD> -END - - print "<TD", $hashref->{state} - ? ' BGCOLOR="#ffffff">'.$hashref->{state} - : ' BGCOLOR="#cccccc">(ALL)' - , "</TD>"; - - print "<TD", $hashref->{county} - ? ' BGCOLOR="#ffffff">'. $hashref->{county} - : ' BGCOLOR="#cccccc">(ALL)' - , "</TD>"; - - print "<TD", $hashref->{taxclass} - ? ' BGCOLOR="#ffffff">'. $hashref->{taxclass} - : ' BGCOLOR="#cccccc">(ALL)' - , "</TD>"; - - print qq!<TD><INPUT TYPE="text" NAME="taxname!, $hashref->{taxnum}, - qq!" VALUE="!, $hashref->{taxname}, qq!"></TD>! - if dbdef->table('cust_main_county')->column('taxname'); - - print qq!<TD><TABLE><TR><TD><INPUT TYPE="text" NAME="tax!, $hashref->{taxnum}, - qq!" VALUE="!, $hashref->{tax}, qq!" SIZE=6 MAXLENGTH=6></TD><TD>%</TD></TR></TABLE></TD>!; - print qq!<TD><TABLE><TR><TD>\$</TD><TD><INPUT TYPE="text" NAME="exempt_amount!, $hashref->{taxnum}, - qq!" VALUE="!, $hashref->{exempt_amount}||0, qq!" SIZE=6></TD></TR></TABLE></TD>!; - - print qq!<TD><INPUT TYPE="checkbox" NAME="setuptax!. $hashref->{taxnum}. - '" VALUE="Y"'. - ( $hashref->{setuptax} =~ /^Y$/i ? ' CHECKED' : '' ). - '></TD>' - if dbdef->table('cust_main_county')->column('setuptax'); - - print qq!<TD><INPUT TYPE="checkbox" NAME="recurtax!. $hashref->{taxnum}. - '" VALUE="Y"'. - ( $hashref->{recurtax} =~ /^Y$/i ? ' CHECKED' : '' ). - '></TD>' - if dbdef->table('cust_main_county')->column('recurtax'); - - print '</TR>'; - -} - -print <<END; - </TABLE> - <INPUT TYPE="submit" VALUE="Apply changes"> - </FORM> - </CENTER> - </BODY> -</HTML> -END - -%> diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index e7734c1fc..83e4e82ea 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -1,94 +1,95 @@ -<% - -my $conf = new FS::Conf; - -my %payby = ( - 'BILL' => 'Check', - 'CASH' => 'Cash', - 'WEST' => 'Western Union', - 'MCRD' => 'Manual credit card', -); - -my($link, $linknum, $paid, $payby, $payinfo, $_date); -if ( $cgi->param('error') ) { - $link = $cgi->param('link'); - $linknum = $cgi->param('linknum'); - $paid = $cgi->param('paid'); - $payby = $cgi->param('payby'); - $payinfo = $cgi->param('payinfo'); - $_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time; -} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { - $link = $cgi->param('popup') ? 'popup' : 'custnum'; - $linknum = $1; - $paid = ''; - $payby = $cgi->param('payby') || 'BILL'; - $payinfo = ''; - $_date = time; -} elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) { - $link = 'invnum'; - $linknum = $1; - $paid = ''; - $payby = $cgi->param('payby') || 'BILL'; - $payinfo = ""; - $_date = time; -} else { - die "illegal query ". $cgi->keywords; -} - -my $paybatch = "webui-$_date-$$-". rand() * 2**32; - -my $title = 'Post '. $payby{$payby}. ' payment'; -$title .= " against Invoice #$linknum" if $link eq 'invnum'; - -if ( $link eq 'popup' ) { - -%><%= include('/elements/header-popup.html', $title ) %> - -<% } else { %> - -<%= include("/elements/header.html", $title, '') %> - -<% } %> - -<% if ( $cgi->param('error') ) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> +% +% +%my $conf = new FS::Conf; +% +%my %payby = ( +% 'BILL' => 'Check', +% 'CASH' => 'Cash', +% 'WEST' => 'Western Union', +% 'MCRD' => 'Manual credit card', +%); +% +%my($link, $linknum, $paid, $payby, $payinfo, $_date); +%if ( $cgi->param('error') ) { +% $link = $cgi->param('link'); +% $linknum = $cgi->param('linknum'); +% $paid = $cgi->param('paid'); +% $payby = $cgi->param('payby'); +% $payinfo = $cgi->param('payinfo'); +% $_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time; +%} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { +% $link = $cgi->param('popup') ? 'popup' : 'custnum'; +% $linknum = $1; +% $paid = ''; +% $payby = $cgi->param('payby') || 'BILL'; +% $payinfo = ''; +% $_date = time; +%} elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) { +% $link = 'invnum'; +% $linknum = $1; +% $paid = ''; +% $payby = $cgi->param('payby') || 'BILL'; +% $payinfo = ""; +% $_date = time; +%} else { +% die "illegal query ". $cgi->keywords; +%} +% +%my $paybatch = "webui-$_date-$$-". rand() * 2**32; +% +%my $title = 'Post '. $payby{$payby}. ' payment'; +%$title .= " against Invoice #$linknum" if $link eq 'invnum'; +% +%if ( $link eq 'popup' ) { +% +% +<% include('/elements/header-popup.html', $title ) %> +% } else { + + +<% include("/elements/header.html", $title, '') %> +% } +% if ( $cgi->param('error') ) { + +<FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> +% } + <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> -<FORM ACTION="<%= popurl(1) %>process/cust_pay.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="link" VALUE="<%= $link %>"> -<INPUT TYPE="hidden" NAME="linknum" VALUE="<%= $linknum %>"> +<FORM ACTION="<% popurl(1) %>process/cust_pay.cgi" METHOD=POST> +<INPUT TYPE="hidden" NAME="link" VALUE="<% $link %>"> +<INPUT TYPE="hidden" NAME="linknum" VALUE="<% $linknum %>"> +% +%my $money_char = $conf->config('money_char') || '$'; +%my $custnum; +%if ( $link eq 'invnum' ) { +% my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } ) +% or die "unknown invnum $linknum"; +% $custnum = $cust_bill->custnum; +%} elsif ( $link eq 'custnum' ) { +% $custnum = $linknum; +%} +% +% unless ( $link eq 'popup' ) { -<% -my $money_char = $conf->config('money_char') || '$'; -my $custnum; -if ( $link eq 'invnum' ) { - my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } ) - or die "unknown invnum $linknum"; - $custnum = $cust_bill->custnum; -} elsif ( $link eq 'custnum' ) { - $custnum = $linknum; -} -%> +<% small_custview($custnum, $conf->config('countrydefault')) %> +% } -<% unless ( $link eq 'popup' ) { %> -<%= small_custview($custnum, $conf->config('countrydefault')) %> -<% } %> -<INPUT TYPE="hidden" NAME="payby" VALUE="<%= $payby %>"> +<INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>"> <BR><BR> Payment -<%= ntable("#cccccc", 2) %> +<% ntable("#cccccc", 2) %> <TR> <TD ALIGN="right">Date</TD> <TD COLSPAN=2> - <INPUT TYPE="text" NAME="_date" ID="_date_text" VALUE="<%= time2str("%m/%d/%Y %r",$_date) %>"> + <INPUT TYPE="text" NAME="_date" ID="_date_text" VALUE="<% time2str("%m/%d/%Y %r",$_date) %>"> <IMG SRC="../images/calendar.png" ID="_date_button" STYLE="cursor: pointer" TITLE="Select date"> </TD> </TR> @@ -102,33 +103,36 @@ Payment </SCRIPT> <TR> <TD ALIGN="right">Amount</TD> - <TD BGCOLOR="#ffffff" ALIGN="right"><%= $money_char %></TD> - <TD><INPUT TYPE="text" NAME="paid" VALUE="<%= $paid %>" SIZE=8 MAXLENGTH=8> by <B><%= $payby{$payby} %></B></TD> + <TD BGCOLOR="#ffffff" ALIGN="right"><% $money_char %></TD> + <TD><INPUT TYPE="text" NAME="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=8> by <B><% $payby{$payby} %></B></TD> </TR> +% if ( $payby eq 'BILL' ) { -<% if ( $payby eq 'BILL' ) { %> <TR> <TD ALIGN="right">Check #</TD> - <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<%= $payinfo %>" SIZE=10></TD> + <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD> </TR> +% } -<% } %> <TR> -<% if ( $link eq 'custnum' ) { %> +% if ( $link eq 'custnum' ) { + <TD ALIGN="right">Auto-apply<BR>to invoices</TD> <TD COLSPAN=2><SELECT NAME="apply"><OPTION VALUE="yes" SELECTED>yes<OPTION>no</SELECT></TD> -<% } elsif ( $link eq 'invnum' ) { %> +% } elsif ( $link eq 'invnum' ) { + <TD ALIGN="right">Apply to</TD> - <TD COLSPAN=2 BGCOLOR="#ffffff">Invoice #<B><%= $linknum %></B> only</TD> + <TD COLSPAN=2 BGCOLOR="#ffffff">Invoice #<B><% $linknum %></B> only</TD> <INPUT TYPE="hidden" NAME="apply" VALUE="no"> -<% } %> +% } + </TR> </TABLE> -<INPUT TYPE="hidden" NAME="paybatch" VALUE="<%= $paybatch %>"> +<INPUT TYPE="hidden" NAME="paybatch" VALUE="<% $paybatch %>"> <BR> <INPUT TYPE="submit" VALUE="Post payment"> diff --git a/httemplate/edit/cust_pkg.cgi b/httemplate/edit/cust_pkg.cgi index 174d4dde1..7a0432c5d 100755 --- a/httemplate/edit/cust_pkg.cgi +++ b/httemplate/edit/cust_pkg.cgi @@ -1,50 +1,52 @@ -<% - -my %pkg = (); -my %comment = (); -my %all_pkg = (); -my %all_comment = (); -#foreach (qsearch('part_pkg', { 'disabled' => '' })) { -# $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); -# $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); -#} -foreach (qsearch('part_pkg', {} )) { - $all_pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); - $all_comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); - next if $_->disabled; - $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); - $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); -} - -my($custnum, %remove_pkg); -if ( $cgi->param('error') ) { - $custnum = $cgi->param('custnum'); - %remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg'); -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $custnum = $1; - %remove_pkg = (); -} - -my $p1 = popurl(1); - -%><%= include('/elements/header.html', "Add/Edit Packages", '') %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> - -<FORM ACTION="<%= $p1 %>process/cust_pkg.cgi" METHOD=POST> - -<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>"> - -<% -#current packages -my @cust_pkg = qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ); - -if (@cust_pkg) { -%> +% +% +%my %pkg = (); +%my %comment = (); +%my %all_pkg = (); +%my %all_comment = (); +%#foreach (qsearch('part_pkg', { 'disabled' => '' })) { +%# $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); +%# $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); +%#} +%foreach (qsearch('part_pkg', {} )) { +% $all_pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); +% $all_comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); +% next if $_->disabled; +% $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); +% $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); +%} +% +%my($custnum, %remove_pkg); +%if ( $cgi->param('error') ) { +% $custnum = $cgi->param('custnum'); +% %remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg'); +%} else { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $custnum = $1; +% %remove_pkg = (); +%} +% +%my $p1 = popurl(1); +% +% +<% include('/elements/header.html', "Add/Edit Packages", '') %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> +% } + + +<FORM ACTION="<% $p1 %>process/cust_pkg.cgi" METHOD=POST> + +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> +% +%#current packages +%my @cust_pkg = qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ); +% +%if (@cust_pkg) { +% + Current packages - select to remove (services are moved to a new package below) <TABLE> @@ -53,98 +55,98 @@ if (@cust_pkg) { <TH>Package description</TH> </TR> <BR><BR> +% +% +% foreach ( sort { $all_pkg{ $a->getfield('pkgpart') } +% cmp $all_pkg{ $b->getfield('pkgpart') } +% } +% @cust_pkg +% ) +% { +% my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') ); +% my $checked = $remove_pkg{$pkgnum} ? ' CHECKED' : ''; +% +% - <% - - foreach ( sort { $all_pkg{ $a->getfield('pkgpart') } - cmp $all_pkg{ $b->getfield('pkgpart') } - } - @cust_pkg - ) - { - my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') ); - my $checked = $remove_pkg{$pkgnum} ? ' CHECKED' : ''; - - %> <TR> - <TD><INPUT TYPE="checkbox" NAME="remove_pkg" VALUE="<%= $pkgnum %>"<%= $checked %>></TD> - <TD ALIGN="right"><%= $pkgnum %>:</TD> - <TD><%= $all_pkg{$pkgpart} %> - <%= $all_comment{$pkgpart} %></TD> + <TD><INPUT TYPE="checkbox" NAME="remove_pkg" VALUE="<% $pkgnum %>"<% $checked %>></TD> + <TD ALIGN="right"><% $pkgnum %>:</TD> + <TD><% $all_pkg{$pkgpart} %> - <% $all_comment{$pkgpart} %></TD> </TR> +% } - <% } %> </TABLE> <BR><BR> +% } -<% } %> Order new packages <BR><BR> +% +%my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); +%my $agent = qsearchs('agent',{'agentnum'=> $cust_main->agentnum }); +% +%my %agent_pkgs = map { ( $_->pkgpart , $all_pkg{$_->pkgpart} ) } +% qsearch('type_pkgs',{'typenum'=> $agent->typenum }); +% +%my $count = 0; +%my $pkgparts = 0; +% -<% -my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); -my $agent = qsearchs('agent',{'agentnum'=> $cust_main->agentnum }); - -my %agent_pkgs = map { ( $_->pkgpart , $all_pkg{$_->pkgpart} ) } - qsearch('type_pkgs',{'typenum'=> $agent->typenum }); - -my $count = 0; -my $pkgparts = 0; -%> <TABLE> <TR STYLE="background-color: #cccccc;"> <TH>Qty.</TH> <TH COLSPAN="2">Package Description</TH> </TR> +% +%#foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { +%foreach my $pkgpart ( sort { $agent_pkgs{$a} cmp $agent_pkgs{$b} } +% keys(%agent_pkgs) ) { +% $pkgparts++; +% next unless exists $pkg{$pkgpart}; #skip disabled ones +% #print qq!<TR>! if ( $count == 0 ); +% my $value = $cgi->param("pkg$pkgpart") || 0; +% -<% -#foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { -foreach my $pkgpart ( sort { $agent_pkgs{$a} cmp $agent_pkgs{$b} } - keys(%agent_pkgs) ) { - $pkgparts++; - next unless exists $pkg{$pkgpart}; #skip disabled ones - #print qq!<TR>! if ( $count == 0 ); - my $value = $cgi->param("pkg$pkgpart") || 0; -%> <TR> <TD> - <INPUT TYPE="text" NAME="<%= "pkg$pkgpart" %>" VALUE="<%= $value %>" SIZE="2" MAXLENGTH="2"> + <INPUT TYPE="text" NAME="<% "pkg$pkgpart" %>" VALUE="<% $value %>" SIZE="2" MAXLENGTH="2"> </TD> - <TD ALIGN="right"><%= $pkgpart %>:</TD> - <TD><%= $pkg{$pkgpart} %> - <%= $comment{$pkgpart}%></TD> + <TD ALIGN="right"><% $pkgpart %>:</TD> + <TD><% $pkg{$pkgpart} %> - <% $comment{$pkgpart}%></TD> </TR> +% +% $count ++ ; +% #if ( $count == 2 ) { +% # print qq!</TR>\n! ; +% # $count = 0; +% #} +%} +% -<% - $count ++ ; - #if ( $count == 2 ) { - # print qq!</TR>\n! ; - # $count = 0; - #} -} -%> </TABLE> +% unless ( $pkgparts ) { +% my $p2 = popurl(2); +% my $typenum = $agent->typenum; +% my $agent_type = qsearchs( 'agent_type', { 'typenum' => $typenum } ); +% my $atype = $agent_type->atype; +% -<% unless ( $pkgparts ) { - my $p2 = popurl(2); - my $typenum = $agent->typenum; - my $agent_type = qsearchs( 'agent_type', { 'typenum' => $typenum } ); - my $atype = $agent_type->atype; -%> - (No <A HREF="<%= $p2 %>browse/part_pkg.cgi">package definitions</A>, + (No <A HREF="<% $p2 %>browse/part_pkg.cgi">package definitions</A>, or agent type - <A HREF="<%= $p2 %>edit/agent_type.cgi?<%= $typenum %>"><%= $atype %></a> + <A HREF="<% $p2 %>edit/agent_type.cgi?<% $typenum %>"><% $atype %></a> is not allowed to purchase any packages.) +% } -<% } %> <P><INPUT TYPE="submit" VALUE="Order"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/edit/cust_refund.cgi b/httemplate/edit/cust_refund.cgi index 8955c7cee..2b3e02614 100755 --- a/httemplate/edit/cust_refund.cgi +++ b/httemplate/edit/cust_refund.cgi @@ -1,94 +1,95 @@ <!-- mason kludge --> -<% +% +% +%my $conf = new FS::Conf; +%my $custnum = $cgi->param('custnum'); +%my $refund = $cgi->param('refund'); +%my $payby = $cgi->param('payby'); +%my $reason = $cgi->param('reason'); +% +%my( $paynum, $cust_pay ) = ( '', '' ); +%if ( $cgi->param('paynum') =~ /^(\d+)$/ ) { +% $paynum = $1; +% $cust_pay = qsearchs('cust_pay', { paynum=>$paynum } ) +% or die "unknown payment # $paynum"; +% $refund ||= $cust_pay->unrefunded; +% if ( $custnum ) { +% die "payment # $paynum is not for specified customer # $custnum" +% unless $custnum == $cust_pay->custnum; +% } else { +% $custnum = $cust_pay->custnum; +% } +%} +%die "no custnum or paynum specified!" unless $custnum; +% +%my $_date = time; +% +%my $p1 = popurl(1); +% +%print header('Refund '. ucfirst(lc($payby)). ' payment', ''); +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT>" +% if $cgi->param('error'); +%print <<END, small_custview($custnum, $conf->config('countrydefault')); +% <FORM ACTION="${p1}process/cust_refund.cgi" METHOD=POST> +% <INPUT TYPE="hidden" NAME="refundnum" VALUE=""> +% <INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum"> +% <INPUT TYPE="hidden" NAME="paynum" VALUE="$paynum"> +% <INPUT TYPE="hidden" NAME="_date" VALUE="$_date"> +% <INPUT TYPE="hidden" NAME="payby" VALUE="$payby"> +% <INPUT TYPE="hidden" NAME="payinfo" VALUE=""> +% <INPUT TYPE="hidden" NAME="paybatch" VALUE=""> +% <INPUT TYPE="hidden" NAME="credited" VALUE=""> +% <BR> +%END +% +%if ( $cust_pay ) { +% +% #false laziness w/FS/FS/cust_pay.pm +% my $payby = $cust_pay->payby; +% my $payinfo = $cust_pay->payinfo; +% $payby =~ s/^BILL$/Check/ if $payinfo; +% $payby =~ s/^CHEK$/Electronic check/; +% $payinfo = $cust_pay->payinfo_masked if $payby eq 'CARD'; +% +% print '<BR>Payment'. ntable("#cccccc", 2). +% '<TR><TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">$'. +% $cust_pay->paid. '</TD></TR>'. +% '<TR><TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff">'. +% time2str("%D",$cust_pay->_date). '</TD></TR>'. +% '<TR><TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff">'. +% ucfirst(lc($payby)). ' # '. $payinfo. '</TD></TR>'; +% #false laziness w/FS/FS/cust_main::realtime_refund_bop +% if ( $cust_pay->paybatch =~ /^(\w+):(\w+)(:(\w+))?$/ ) { +% my ( $processor, $auth, $order_number ) = ( $1, $2, $4 ); +% print '<TR><TD ALIGN="right">Processor</TD><TD BGCOLOR="#ffffff">'. +% $processor. '</TD></TR>'; +% print '<TR><TD ALIGN="right">Authorization</TD><TD BGCOLOR="#ffffff">'. +% $auth. '</TD></TR>' +% if length($auth); +% print '<TR><TD ALIGN="right">Order number</TD><TD BGCOLOR="#ffffff">'. +% $order_number. '</TD></TR>' +% if length($order_number); +% } +% print '</TABLE>'; +%} +% +%print '<BR>Refund'. ntable("#cccccc", 2). +% '<TR><TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff">'. +% time2str("%D",$_date). '</TD></TR>'; +% +%print qq!<TR><TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">\$<INPUT TYPE="text" NAME="refund" VALUE="$refund" SIZE=8 MAXLENGTH=8></TD></TR>!; +% +%print qq!<TR><TD ALIGN="right">Reason</TD><TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="$reason"></TD></TR>!; +% +%print <<END; +%</TABLE> +%<BR> +%<INPUT TYPE="submit" VALUE="Post refund"> +% </FORM> +% </BODY> +%</HTML> +%END +% +% -my $conf = new FS::Conf; -my $custnum = $cgi->param('custnum'); -my $refund = $cgi->param('refund'); -my $payby = $cgi->param('payby'); -my $reason = $cgi->param('reason'); - -my( $paynum, $cust_pay ) = ( '', '' ); -if ( $cgi->param('paynum') =~ /^(\d+)$/ ) { - $paynum = $1; - $cust_pay = qsearchs('cust_pay', { paynum=>$paynum } ) - or die "unknown payment # $paynum"; - $refund ||= $cust_pay->unrefunded; - if ( $custnum ) { - die "payment # $paynum is not for specified customer # $custnum" - unless $custnum == $cust_pay->custnum; - } else { - $custnum = $cust_pay->custnum; - } -} -die "no custnum or paynum specified!" unless $custnum; - -my $_date = time; - -my $p1 = popurl(1); - -print header('Refund '. ucfirst(lc($payby)). ' payment', ''); -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); -print <<END, small_custview($custnum, $conf->config('countrydefault')); - <FORM ACTION="${p1}process/cust_refund.cgi" METHOD=POST> - <INPUT TYPE="hidden" NAME="refundnum" VALUE=""> - <INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum"> - <INPUT TYPE="hidden" NAME="paynum" VALUE="$paynum"> - <INPUT TYPE="hidden" NAME="_date" VALUE="$_date"> - <INPUT TYPE="hidden" NAME="payby" VALUE="$payby"> - <INPUT TYPE="hidden" NAME="payinfo" VALUE=""> - <INPUT TYPE="hidden" NAME="paybatch" VALUE=""> - <INPUT TYPE="hidden" NAME="credited" VALUE=""> - <BR> -END - -if ( $cust_pay ) { - - #false laziness w/FS/FS/cust_pay.pm - my $payby = $cust_pay->payby; - my $payinfo = $cust_pay->payinfo; - $payby =~ s/^BILL$/Check/ if $payinfo; - $payby =~ s/^CHEK$/Electronic check/; - $payinfo = $cust_pay->payinfo_masked if $payby eq 'CARD'; - - print '<BR>Payment'. ntable("#cccccc", 2). - '<TR><TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">$'. - $cust_pay->paid. '</TD></TR>'. - '<TR><TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff">'. - time2str("%D",$cust_pay->_date). '</TD></TR>'. - '<TR><TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff">'. - ucfirst(lc($payby)). ' # '. $payinfo. '</TD></TR>'; - #false laziness w/FS/FS/cust_main::realtime_refund_bop - if ( $cust_pay->paybatch =~ /^(\w+):(\w+)(:(\w+))?$/ ) { - my ( $processor, $auth, $order_number ) = ( $1, $2, $4 ); - print '<TR><TD ALIGN="right">Processor</TD><TD BGCOLOR="#ffffff">'. - $processor. '</TD></TR>'; - print '<TR><TD ALIGN="right">Authorization</TD><TD BGCOLOR="#ffffff">'. - $auth. '</TD></TR>' - if length($auth); - print '<TR><TD ALIGN="right">Order number</TD><TD BGCOLOR="#ffffff">'. - $order_number. '</TD></TR>' - if length($order_number); - } - print '</TABLE>'; -} - -print '<BR>Refund'. ntable("#cccccc", 2). - '<TR><TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff">'. - time2str("%D",$_date). '</TD></TR>'; - -print qq!<TR><TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">\$<INPUT TYPE="text" NAME="refund" VALUE="$refund" SIZE=8 MAXLENGTH=8></TD></TR>!; - -print qq!<TR><TD ALIGN="right">Reason</TD><TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="$reason"></TD></TR>!; - -print <<END; -</TABLE> -<BR> -<INPUT TYPE="submit" VALUE="Post refund"> - </FORM> - </BODY> -</HTML> -END - -%> diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index c40a00492..ac00fc5f0 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -1,197 +1,199 @@ -<% - - # options example... - # - # 'name' => - # 'table' => - # #? 'primary_key' => #required when the dbdef doesn't know...??? - # 'labels' => { - # 'column' => 'Label', - # } - # - # listref - each item is a literal column name (or method) or hashref - # or (notyet) coderef - # if not specified all columns (except for the primary key) will be editable - # 'fields' => [ - # 'columname', - # { 'field' => 'another_columname', - # 'type' => 'text', #text, fixed, hidden, checkbox - # #eventually more for <SELECT>, etc. - # 'value' => 'Y', #only for checkbox - # }, - # ] - # - # 'menubar' => '', #menubar arrayref - # - # #run when re-displaying with an error - # 'error_callback' => sub { my( $cgi, $object ) = @_; }, - # - # #run when editing - # 'edit_callback' => sub { my( $cgi, $object ) = @_; }, - # - # # returns a hashref for the new object - # 'new_hashref_callback' - # - # #run when adding - # 'new_callback' => sub { my( $cgi, $object ) = @_; }, - # - # #XXX describe - # 'field_callback' => sub { }, - # - # #string or coderef of additional HTML to add before </TABLE> - # 'html_table_bottom' => '', - # - # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' - # - # 'html_bottom' => '', #string - # 'html_bottom' => sub { - # my $object = shift; - # # ... - # "html_string"; - # }, - - my(%opt) = @_; - - #false laziness w/process.html - my $table = $opt{'table'}; - my $class = "FS::$table"; - my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || - my $fields = $opt{'fields'} - #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; - || [ grep { $_ ne $pkey } fields($table) ]; - #my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; - - my $object; - if ( $cgi->param('error') ) { - - $object = $class->new( { - map { $_ => scalar($cgi->param($_)) } fields($table) - }); - - &{$opt{'error_callback'}}($cgi, $object) - if $opt{'error_callback'}; - - } elsif ( $cgi->keywords ) { #editing - - my( $query ) = $cgi->keywords; - $query =~ /^(\d+)$/; - $object = qsearchs( $table, { $pkey => $1 } ); - warn "$table $pkey => $1" - if $opt{'debug'}; - - &{$opt{'edit_callback'}}($cgi, $object) - if $opt{'edit_callback'}; - - } else { #adding - - my $hashref = $opt{'new_hashref_callback'} - ? &{$opt{'new_hashref_callback'}} - : {}; - - $object = $class->new( $hashref ); - - &{$opt{'new_callback'}}($cgi, $object) - if $opt{'new_callback'}; - - } - - my $action = $object->$pkey() ? 'Edit' : 'Add'; - - my $title = "$action $opt{'name'}"; - - my @menubar = (); - if ( $opt{'menubar'} ) { - @menubar = @{ $opt{'menubar'} }; - } else { - @menubar = ( - 'Main menu' => $p, #eventually get rid of this when the ACL/UI update is done - #eventually use Lingua::bs to pluralize - "View all $opt{'name'}s" => $p. ( $opt{'viewall_dir'} || 'search' ). - "/$table.html", - ); - } - -%><%= include("/elements/header.html", $title, +% +% +% # options example... +% # +% # 'name' => +% # 'table' => +% # #? 'primary_key' => #required when the dbdef doesn't know...??? +% # 'labels' => { +% # 'column' => 'Label', +% # } +% # +% # listref - each item is a literal column name (or method) or hashref +% # or (notyet) coderef +% # if not specified all columns (except for the primary key) will be editable +% # 'fields' => [ +% # 'columname', +% # { 'field' => 'another_columname', +% # 'type' => 'text', #text, fixed, hidden, checkbox +% # #eventually more for <SELECT>, etc. +% # 'value' => 'Y', #only for checkbox +% # }, +% # ] +% # +% # 'menubar' => '', #menubar arrayref +% # +% # #run when re-displaying with an error +% # 'error_callback' => sub { my( $cgi, $object ) = @_; }, +% # +% # #run when editing +% # 'edit_callback' => sub { my( $cgi, $object ) = @_; }, +% # +% # # returns a hashref for the new object +% # 'new_hashref_callback' +% # +% # #run when adding +% # 'new_callback' => sub { my( $cgi, $object ) = @_; }, +% # +% # #XXX describe +% # 'field_callback' => sub { }, +% # +% # #string or coderef of additional HTML to add before </TABLE> +% # 'html_table_bottom' => '', +% # +% # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' +% # +% # 'html_bottom' => '', #string +% # 'html_bottom' => sub { +% # my $object = shift; +% # # ... +% # "html_string"; +% # }, +% +% my(%opt) = @_; +% +% #false laziness w/process.html +% my $table = $opt{'table'}; +% my $class = "FS::$table"; +% my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || +% my $fields = $opt{'fields'} +% #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; +% || [ grep { $_ ne $pkey } fields($table) ]; +% #my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; +% +% my $object; +% if ( $cgi->param('error') ) { +% +% $object = $class->new( { +% map { $_ => scalar($cgi->param($_)) } fields($table) +% }); +% +% &{$opt{'error_callback'}}($cgi, $object) +% if $opt{'error_callback'}; +% +% } elsif ( $cgi->keywords ) { #editing +% +% my( $query ) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $object = qsearchs( $table, { $pkey => $1 } ); +% warn "$table $pkey => $1" +% if $opt{'debug'}; +% +% &{$opt{'edit_callback'}}($cgi, $object) +% if $opt{'edit_callback'}; +% +% } else { #adding +% +% my $hashref = $opt{'new_hashref_callback'} +% ? &{$opt{'new_hashref_callback'}} +% : {}; +% +% $object = $class->new( $hashref ); +% +% &{$opt{'new_callback'}}($cgi, $object) +% if $opt{'new_callback'}; +% +% } +% +% my $action = $object->$pkey() ? 'Edit' : 'Add'; +% +% my $title = "$action $opt{'name'}"; +% +% my @menubar = (); +% if ( $opt{'menubar'} ) { +% @menubar = @{ $opt{'menubar'} }; +% } else { +% @menubar = ( +% 'Main menu' => $p, #eventually get rid of this when the ACL/UI update is done +% #eventually use Lingua::bs to pluralize +% "View all $opt{'name'}s" => $p. ( $opt{'viewall_dir'} || 'search' ). +% "/$table.html", +% ); +% } +% +% +<% include("/elements/header.html", $title, include( '/elements/menubar.html', @menubar ) ) %> +% if ( $cgi->param('error') ) { -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> +% } -<FORM ACTION="<%= popurl(1) %>process/<%= $table %>.html" METHOD=POST> -<INPUT TYPE="hidden" NAME="<%= $pkey %>" VALUE="<%= $object->$pkey() %>"> -<%= ( $opt{labels} && exists $opt{labels}->{$pkey} ) + +<FORM ACTION="<% popurl(1) %>process/<% $table %>.html" METHOD=POST> +<INPUT TYPE="hidden" NAME="<% $pkey %>" VALUE="<% $object->$pkey() %>"> +<% ( $opt{labels} && exists $opt{labels}->{$pkey} ) ? $opt{labels}->{$pkey} : $pkey %> -#<%= $object->$pkey() || "(NEW)" %> - -<%= ntable("#cccccc",2) %> - -<% foreach my $f ( map { ref($_) ? $_ : {'field'=>$_} } - @$fields - ) { +#<% $object->$pkey() || "(NEW)" %> + +<% ntable("#cccccc",2) %> +% foreach my $f ( map { ref($_) ? $_ : {'field'=>$_} } +% @$fields +% ) { +% +% &{ $opt{'field_callback'} }( $f ) +% if $opt{'field_callback'}; +% +% my $field = $f->{'field'}; +% my $type = $f->{'type'} ||= 'text'; +% +% - &{ $opt{'field_callback'} }( $f ) - if $opt{'field_callback'}; - - my $field = $f->{'field'}; - my $type = $f->{'type'} ||= 'text'; - -%> <TR> <TD ALIGN="right"> - <%= ( $opt{labels} && exists $opt{labels}->{$field} ) + <% ( $opt{labels} && exists $opt{labels}->{$field} ) ? $opt{labels}->{$field} : $field %> </TD> +% if ( $type eq 'fixed' ) { - <% if ( $type eq 'fixed' ) { %> - <TD BGCOLOR="#dddddd"><%= $f->{'value'} %></TD> - <INPUT TYPE="hidden" NAME="<%= $field %>" VALUE="<%= $f->{'value'} %>"> + <TD BGCOLOR="#dddddd"><% $f->{'value'} %></TD> + <INPUT TYPE="hidden" NAME="<% $field %>" VALUE="<% $f->{'value'} %>"> +% } elsif ( $type eq 'checkbox' ) { - <% } elsif ( $type eq 'checkbox' ) { %> <TD> - <INPUT TYPE="checkbox" NAME="<%= $field %>" VALUE="<%= $f->{'value'} %>" <%= $object->$field() eq $f->{'value'} ? ' CHECKED' : '' %>> + <INPUT TYPE="checkbox" NAME="<% $field %>" VALUE="<% $f->{'value'} %>" <% $object->$field() eq $f->{'value'} ? ' CHECKED' : '' %>> </TD> +% } else { - <% } else { %> <TD> - <INPUT TYPE="<%= $type %>" NAME="<%= $field %>" VALUE="<%= $object->$field() %>"> + <INPUT TYPE="<% $type %>" NAME="<% $field %>" VALUE="<% $object->$field() %>"> <TD> +% } - <% } %> </TR> +% } -<% } %> -<%= ref( $opt{'html_table_bottom'} ) +<% ref( $opt{'html_table_bottom'} ) ? &{ $opt{'html_table_bottom'} }( $object ) : $opt{'html_table_bottom'} %> </TABLE> -<%= ref( $opt{'html_bottom'} ) +<% ref( $opt{'html_bottom'} ) ? &{ $opt{'html_bottom'} }( $object ) : $opt{'html_bottom'} %> <BR> -<INPUT TYPE="submit" VALUE="<%= $object->$pkey() ? "Apply changes" : "Add $opt{'name'}" %>"> +<INPUT TYPE="submit" VALUE="<% $object->$pkey() ? "Apply changes" : "Add $opt{'name'}" %>"> </FORM> -<%= include("/elements/footer.html") %> +<% include("/elements/footer.html") %> diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index c113ad645..da59cc9ed 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -1,19 +1,20 @@ -<% - - my %opt = @_; - - #my( $svcnum, $pkgnum, $svcpart, $part_svc ); - my( $pkgnum, $svcpart, $part_svc ); - - #get & untaint pkgnum & svcpart - my($query) = $cgi->keywords; #they're not proper cgi params - if ( $query =~ /^pkgnum(\d+)-svcpart(\d+)$/ ) { - $pkgnum = $1; - $svcpart = $2; - $cgi->delete_all(); #so the standard edit.html treats this correctly as new - } - -%><%= include( 'edit.html', +% +% +% my %opt = @_; +% +% #my( $svcnum, $pkgnum, $svcpart, $part_svc ); +% my( $pkgnum, $svcpart, $part_svc ); +% +% #get & untaint pkgnum & svcpart +% my($query) = $cgi->keywords; #they're not proper cgi params +% if ( $query =~ /^pkgnum(\d+)-svcpart(\d+)$/ ) { +% $pkgnum = $1; +% $svcpart = $2; +% $cgi->delete_all(); #so the standard edit.html treats this correctly as new +% } +% +% +<% include( 'edit.html', 'menubar' => [], diff --git a/httemplate/edit/inventory_class.html b/httemplate/edit/inventory_class.html index 8c5ae4770..beefcd580 100644 --- a/httemplate/edit/inventory_class.html +++ b/httemplate/edit/inventory_class.html @@ -1,4 +1,4 @@ -<%= include( 'elements/edit.html', +<% include( 'elements/edit.html', 'name' => 'Inventory Class', 'table' => 'inventory_class', 'labels' => { diff --git a/httemplate/edit/msgcat.cgi b/httemplate/edit/msgcat.cgi index ee9b1c6b3..54a340d83 100755 --- a/httemplate/edit/msgcat.cgi +++ b/httemplate/edit/msgcat.cgi @@ -1,58 +1,59 @@ <!-- mason kludge --> -<% +% +% +%print header("Edit Message catalog", menubar( +%# 'Main Menu' => $p, +%)), '<BR>'; +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !. $cgi->param('error'). +% '</FONT><BR><BR>' +% if $cgi->param('error'); +% +%my $widget = new HTML::Widgets::SelectLayers( +% 'selected_layer' => 'en_US', +% 'options' => { 'en_US'=>'en_US' }, +% 'form_action' => 'process/msgcat.cgi', +% 'layer_callback' => sub { +% my $layer = shift; +% my $html = qq!<INPUT TYPE="hidden" NAME="locale" VALUE="$layer">!. +% "<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><INPUT TYPE="text" SIZE=32 '. +% qq! NAME="!. $msgcat->msgnum. '" '. +% qq!VALUE="!. ($cgi->param($msgcat->msgnum)||$msgcat->msg). qq!"></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><BR><INPUT TYPE="submit" VALUE="Apply changes">'; +% +% $html; +% }, +% +%); +% +%print $widget->html; +% +%print <<END; +% </TABLE> +% </BODY> +%</HTML> +%END +% +% -print header("Edit Message catalog", menubar( -# 'Main Menu' => $p, -)), '<BR>'; - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !. $cgi->param('error'). - '</FONT><BR><BR>' - if $cgi->param('error'); - -my $widget = new HTML::Widgets::SelectLayers( - 'selected_layer' => 'en_US', - 'options' => { 'en_US'=>'en_US' }, - 'form_action' => 'process/msgcat.cgi', - 'layer_callback' => sub { - my $layer = shift; - my $html = qq!<INPUT TYPE="hidden" NAME="locale" VALUE="$layer">!. - "<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><INPUT TYPE="text" SIZE=32 '. - qq! NAME="!. $msgcat->msgnum. '" '. - qq!VALUE="!. ($cgi->param($msgcat->msgnum)||$msgcat->msg). qq!"></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><BR><INPUT TYPE="submit" VALUE="Apply changes">'; - - $html; - }, - -); - -print $widget->html; - -print <<END; - </TABLE> - </BODY> -</HTML> -END - -%> diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi index 32a3f2df0..a58f07883 100755 --- a/httemplate/edit/part_bill_event.cgi +++ b/httemplate/edit/part_bill_event.cgi @@ -1,31 +1,32 @@ <!--mason kludge--> -<% - -if ( $cgi->param('eventpart') && $cgi->param('eventpart') =~ /^(\d+)$/ ) { - $cgi->param('eventpart', $1); -} else { - $cgi->param('eventpart', ''); -} - -my ($query) = $cgi->keywords; -my $action = ''; -my $part_bill_event = ''; -if ( $cgi->param('error') ) { - $part_bill_event = new FS::part_bill_event ( { - map { $_, scalar($cgi->param($_)) } fields('part_bill_event') - } ); -} -if ( $query && $query =~ /^(\d+)$/ ) { - $part_bill_event ||= qsearchs('part_bill_event',{'eventpart'=>$1}); -} else { - $part_bill_event ||= new FS::part_bill_event {}; -} -$action ||= $part_bill_event->eventpart ? 'Edit' : 'Add'; -my $hashref = $part_bill_event->hashref; - -%> - -<%= include('/elements/header.html', +% +% +%if ( $cgi->param('eventpart') && $cgi->param('eventpart') =~ /^(\d+)$/ ) { +% $cgi->param('eventpart', $1); +%} else { +% $cgi->param('eventpart', ''); +%} +% +%my ($query) = $cgi->keywords; +%my $action = ''; +%my $part_bill_event = ''; +%if ( $cgi->param('error') ) { +% $part_bill_event = new FS::part_bill_event ( { +% map { $_, scalar($cgi->param($_)) } fields('part_bill_event') +% } ); +%} +%if ( $query && $query =~ /^(\d+)$/ ) { +% $part_bill_event ||= qsearchs('part_bill_event',{'eventpart'=>$1}); +%} else { +% $part_bill_event ||= new FS::part_bill_event {}; +%} +%$action ||= $part_bill_event->eventpart ? 'Edit' : 'Add'; +%my $hashref = $part_bill_event->hashref; +% +% + + +<% include('/elements/header.html', "$action Invoice Event Definition", menubar( 'Main Menu' => popurl(2), @@ -33,58 +34,59 @@ my $hashref = $part_bill_event->hashref; ) ) %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> +% } -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> -<FORM ACTION="<%= popurl(1) %>process/part_bill_event.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="eventpart" VALUE="<%= $part_bill_event->eventpart %>"> -Invoice Event #<%= $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %> +<FORM ACTION="<% popurl(1) %>process/part_bill_event.cgi" METHOD=POST> +<INPUT TYPE="hidden" NAME="eventpart" VALUE="<% $part_bill_event->eventpart %>"> +Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %> -<%= ntable("#cccccc",2) %> +<% ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Event name </TD> - <TD><INPUT TYPE="text" NAME="event" VALUE="<%= $hashref->{event} %>"></TD> + <TD><INPUT TYPE="text" NAME="event" VALUE="<% $hashref->{event} %>"></TD> </TR> <TR> <TD ALIGN="right">For </TD> <TD> <SELECT NAME="payby"> +% tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname; +% foreach my $payby ( keys %payby ) { +% - <% tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname; - foreach my $payby ( keys %payby ) { - %> - <OPTION VALUE="<%= $payby %>"<%= ($part_bill_event->payby eq $payby) ? ' SELECTED' : '' %>><%= $payby{$payby} %></OPTION> + <OPTION VALUE="<% $payby %>"<% ($part_bill_event->payby eq $payby) ? ' SELECTED' : '' %>><% $payby{$payby} %></OPTION> +% } - <% } %> </SELECT> customers </TD> </TR> +% my $days = $hashref->{seconds}/86400; - <% my $days = $hashref->{seconds}/86400; %> <TR> <TD ALIGN="right">After</TD> - <TD><INPUT TYPE="text" NAME="days" VALUE="<%= $days %>"> days</TD> + <TD><INPUT TYPE="text" NAME="days" VALUE="<% $days %>"> days</TD> </TR> <TR> <TD ALIGN="right">Test event</TD> <TD> <SELECT NAME="freq"> +% tie my %freq, 'Tie::IxHash', '1d' => 'daily', '1m' => 'monthly'; +% foreach my $freq ( keys %freq ) { +% - <% tie my %freq, 'Tie::IxHash', '1d' => 'daily', '1m' => 'monthly'; - foreach my $freq ( keys %freq ) { - %> - <OPTION VALUE="<%= $freq %>"<%= ($part_bill_event->freq eq $freq) ? ' SELECTED' : '' %>><%= $freq{$freq} %></OPTION> + <OPTION VALUE="<% $freq %>"<% ($part_bill_event->freq eq $freq) ? ' SELECTED' : '' %>><% $freq{$freq} %></OPTION> +% } - <% } %> </SELECT> </TD> @@ -94,335 +96,335 @@ Invoice Event #<%= $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %> <TR> <TD ALIGN="right">Disabled</TD> <TD> - <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>> + <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>> </TD> </TR> <TR> <TD VALIGN="top" ALIGN="right">Action</TD> <TD> +% +% +%#print ntable(); +% +%sub select_pkgpart { +% my $label = shift; +% my $plandata = shift; +% my %selected = map { $_=>1 } split(/,\s*/, $plandata->{$label}); +% qq(<SELECT NAME="$label" MULTIPLE>). +% join("\n", map { +% '<OPTION VALUE="'. $_->pkgpart. '"'. +% ( $selected{$_->pkgpart} ? ' SELECTED' : '' ). +% '>'. $_->pkg. ' - '. $_->comment +% } qsearch('part_pkg', { 'disabled' => '' } ) ). +% '</SELECT>'; +%} +% +%sub select_agentnum { +% my $plandata = shift; +% #my $agentnum = $plandata->{'agentnum'}; +% my %agentnums = map { $_=>1 } split(/,\s*/, $plandata->{'agentnum'}); +% '<SELECT NAME="agentnum" MULTIPLE>'. +% join("\n", map { +% '<OPTION VALUE="'. $_->agentnum. '"'. +% ( $agentnums{$_->agentnum} ? ' SELECTED' : '' ). +% '>'. $_->agent +% } qsearch('agent', { 'disabled' => '' } ) ). +% '</SELECT>'; +%} +% +%my $conf = new FS::Conf; +%my $money_char = $conf->config('money_char') || '$'; +% +%#this is pretty kludgy right here. +%tie my %events, 'Tie::IxHash', +% +% 'fee' => { +% 'name' => 'Late fee (flat)', +% 'code' => '$cust_main->charge( %%%charge%%%, \'%%%reason%%%\' );', +% 'html' => +% 'Amount <INPUT TYPE="text" SIZE="7" NAME="charge" VALUE="%%%charge%%%">'. +% '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">', +% 'weight' => 10, +% }, +% 'fee_percent' => { +% 'name' => 'Late fee (percentage)', +% 'code' => '$cust_main->charge( sprintf(\'%.2f\', $cust_bill->owed * %%%percent%%% / 100 ), \'%%%reason%%%\' );', +% 'html' => +% 'Percent <INPUT TYPE="text" SIZE="2" NAME="percent" VALUE="%%%percent%%%">%'. +% '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">', +% 'weight' => 10, +% }, +% 'suspend' => { +% 'name' => 'Suspend', +% 'code' => '$cust_main->suspend();', +% 'weight' => 10, +% }, +% 'suspend-if-balance' => { +% 'name' => 'Suspend if balance (this invoice and previous) over', +% 'code' => '$cust_bill->cust_suspend_if_balance_over( %%%balanceover%%% );', +% 'html' => " $money_char ". '<INPUT TYPE="text" SIZE="7" NAME="balanceover" VALUE="%%%balanceover%%%">', +% 'weight' => 10, +% }, +% 'suspend-if-pkgpart' => { +% 'name' => 'Suspend packages', +% 'code' => '$cust_main->suspend_if_pkgpart(%%%if_pkgpart%%%);', +% 'html' => sub { &select_pkgpart('if_pkgpart', @_) }, +% 'weight' => 10, +% }, +% 'suspend-unless-pkgpart' => { +% 'name' => 'Suspend packages except', +% 'code' => '$cust_main->suspend_unless_pkgpart(%%%unless_pkgpart%%%);', +% 'html' => sub { &select_pkgpart('unless_pkgpart', @_) }, +% 'weight' => 10, +% }, +% 'cancel' => { +% 'name' => 'Cancel', +% 'code' => '$cust_main->cancel();', +% 'weight' => 10, +% }, +% +% 'addpost' => { +% 'name' => 'Add postal invoicing', +% 'code' => '$cust_main->invoicing_list_addpost(); "";', +% 'weight' => 20, +% }, +% +% 'comp' => { +% 'name' => 'Pay invoice with a complimentary "payment"', +% 'code' => '$cust_bill->comp();', +% 'weight' => 30, +% }, +% +% 'realtime-card' => { +% 'name' => 'Run card with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway', +% 'code' => '$cust_bill->realtime_card();', +% 'weight' => 30, +% }, +% +% 'realtime-check' => { +% 'name' => 'Run check with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway', +% 'code' => '$cust_bill->realtime_ach();', +% 'weight' => 30, +% }, +% +% 'realtime-lec' => { +% 'name' => 'Run phone bill ("LEC") billing with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway', +% 'code' => '$cust_bill->realtime_lec();', +% 'weight' => 30, +% }, +% +% 'batch-card' => { +% 'name' => 'Add card to the pending credit card batch', +% 'code' => '$cust_bill->batch_card();', +% 'weight' => 40, +% }, +% +% 'send' => { +% 'name' => 'Send invoice (email/print/fax)', +% 'code' => '$cust_bill->send();', +% 'weight' => 50, +% }, +% +% 'send_alternate' => { +% 'name' => 'Send invoice (email/print/fax) with alternate template', +% 'code' => '$cust_bill->send(\'%%%templatename%%%\');', +% 'html' => +% '<INPUT TYPE="text" NAME="templatename" VALUE="%%%templatename%%%">', +% 'weight' => 50, +% }, +% +% 'send_if_newest' => { +% 'name' => 'Send invoice (email/print/fax) with alternate template, if it is still the newest invoice (useful for late notices - set to 31 days or later)', +% 'code' => '$cust_bill->send_if_newest(\'%%%if_newest_templatename%%%\');', +% 'html' => +% '<INPUT TYPE="text" NAME="if_newest_templatename" VALUE="%%%if_newest_templatename%%%">', +% 'weight' => 50, +% }, +% +% 'send_agent' => { +% 'name' => 'Send invoice (email/print/fax) ', +% 'code' => '$cust_bill->send(\'%%%agent_templatename%%%\', [ %%%agentnum%%% ], \'%%%agent_invoice_from%%%\');', +% 'html' => sub { +% '<TABLE BORDER=0> +% <TR> +% <TD ALIGN="right">only for agent(s) </TD> +% <TD>'. &select_agentnum(@_). '</TD> +% </TR> +% <TR> +% <TD ALIGN="right">with template </TD> +% <TD> +% <INPUT TYPE="text" NAME="agent_templatename" VALUE="%%%agent_templatename%%%"> +% </TD> +% </TR> +% <TR> +% <TD ALIGN="right">email From: </TD> +% <TD> +% <INPUT TYPE="text" NAME="agent_invoice_from" VALUE="%%%agent_invoice_from%%%"> +% </TD> +% </TR> +% </TABLE>'; +% }, +% 'weight' => 50, +% }, +% +% 'send_csv_ftp' => { +% 'name' => 'Upload CSV invoice data to an FTP server', +% 'code' => '$cust_bill->send_csv( protocol => \'ftp\', +% server => \'%%%ftpserver%%%\', +% username => \'%%%ftpusername%%%\', +% password => \'%%%ftppassword%%%\', +% dir => \'%%%ftpdir%%%\', +% \'format\' => \'%%%ftpformat%%%\', +% );', +% 'html' => +% '<TABLE BORDER=0>'. +% '<TR><TD ALIGN="right">Format ("default" or "billco"): </TD>'. +% '<TD>'. +% '<!--'. +% '<SELECT NAME="ftpformat">'. +% '<OPTION VALUE="default">Default'. +% '<OPTION VALUE="billco">Billco'. +% '</SELECT>'. +% '-->'. +% '<INPUT TYPE="text" NAME="ftpformat" VALUE="%%%ftpformat%%%">'. +% '</TD></TR>'. +% '<TR><TD ALIGN="right">FTP server: </TD>'. +% '<TD><INPUT TYPE="text" NAME="ftpserver" VALUE="%%%ftpserver%%%">'. +% '</TD></TR>'. +% '<TR><TD ALIGN="right">FTP username: </TD><TD>'. +% '<INPUT TYPE="text" NAME="ftpusername" VALUE="%%%ftpusername%%%">'. +% '</TD></TR>'. +% '<TR><TD ALIGN="right">FTP password: </TD><TD>'. +% '<INPUT TYPE="text" NAME="ftppassword" VALUE="%%%ftppassword%%%">'. +% '</TD></TR>'. +% '<TR><TD ALIGN="right">FTP directory: </TD>'. +% '<TD><INPUT TYPE="text" NAME="ftpdir" VALUE="%%%ftpdir%%%">'. +% '</TD></TR>'. +% '</TABLE>', +% 'weight' => 50, +% }, +% +% 'spool_csv' => { +% 'name' => 'Spool CSV invoice data', +% 'code' => '$cust_bill->spool_csv( +% \'format\' => \'%%%spoolformat%%%\', +% \'dest\' => \'%%%spooldest%%%\', +% \'balanceover\' => \'%%%spoolbalanceover%%%\', +% \'agent_spools\' => \'%%%spoolagent_spools%%%\', +% );', +% 'html' => sub { +% my $plandata = shift; +% +% my $html = +% '<TABLE BORDER=0>'. +% '<TR><TD ALIGN="right">Format: </TD>'. +% '<TD>'. +% '<SELECT NAME="spoolformat">'; +% +% foreach my $option (qw( default billco )) { +% $html .= qq(<OPTION VALUE="$option"); +% $html .= ' SELECTED' if $option eq $plandata->{'spoolformat'}; +% $html .= ">\u$option"; +% } +% +% $html .= +% '</SELECT>'. +% '</TD></TR>'. +% '<TR><TD ALIGN="right">For destination: </TD>'. +% '<TD>'. +% '<SELECT NAME="spooldest">'; +% +% tie my %dest, 'Tie::IxHash', +% '' => '(all)', +% 'POST' => 'Postal Mail', +% 'EMAIL' => 'Email', +% 'FAX' => 'Fax', +% ; +% +% foreach my $dest (keys %dest) { +% $html .= qq(<OPTION VALUE="$dest"); +% $html .= ' SELECTED' if $dest eq $plandata->{'spooldest'}; +% $html .= '>'. $dest{$dest}; +% } +% +% $html .= +% '</SELECT>'. +% '</TD></TR>'. +% +% '<TR>'. +% '<TD ALIGN="right">if balance (this invoice and previous) over </TD>'. +% '<TD>'. +% "$money_char ". +% '<INPUT TYPE="text" SIZE="7" NAME="spoolbalanceover" VALUE="%%%spoolbalanceover%%%">'. +% '</TD>'. +% '<TR><TD ALIGN="right">Individual per-agent spools? </TD>'. +% '<TD><INPUT TYPE="checkbox" NAME="spoolagent_spools" VALUE="1" '. +% ( $plandata->{'spoolagent_spools'} ? 'CHECKED' : '' ). +% '>'. +% '</TD></TR>'. +% '</TABLE>'; +% +% $html; +% }, +% 'weight' => 50, +% }, +% +% 'bill' => { +% 'name' => 'Generate invoices (normally only used with a <i>Late Fee</i> event)', +% 'code' => '$cust_main->bill();', +% 'weight' => 60, +% }, +% +% 'apply' => { +% 'name' => 'Apply unapplied payments and credits', +% 'code' => '$cust_main->apply_payments; $cust_main->apply_credits; "";', +% 'weight' => 70, +% }, +% +% 'collect' => { +% 'name' => 'Collect on invoices (normally only used with a <i>Late Fee</i> and <i>Generate Invoice</i> events)', +% 'code' => '$cust_main->collect();', +% 'weight' => 80, +% }, +% +%; +% +%foreach my $event ( keys %events ) { +% my %plandata = map { /^(\w+) (.*)$/; ($1, $2); } +% split(/\n/, $part_bill_event->plandata); +% my $html = $events{$event}{html}; +% if ( ref($html) eq 'CODE' ) { +% $html = &{$html}(\%plandata); +% } +% while ( $html =~ /%%%(\w+)%%%/ ) { +% my $field = $1; +% $html =~ s/%%%$field%%%/$plandata{$field}/; +% } +% +% print ntable( "#cccccc", 2). +% qq!<TR><TD><INPUT TYPE="radio" NAME="plan_weight_eventcode" !; +% print "CHECKED " if $event eq $part_bill_event->plan; +% print qq!VALUE="!. $event. ":". $events{$event}{weight}. ":". +% encode_entities($events{$event}{code}). +% qq!">$events{$event}{name}</TD>!; +% print '<TD>'. $html. '</TD>' if $html; +% print qq!</TR>!; +% print '</TABLE>'; +%} +% +%#print '</TABLE>'; +% +%print <<END; +%</TD></TR> +%</TABLE> +%END +% +%print qq!<INPUT TYPE="submit" VALUE="!, +% $hashref->{eventpart} ? "Apply changes" : "Add invoice event", +% qq!">!; +% -<% - -#print ntable(); - -sub select_pkgpart { - my $label = shift; - my $plandata = shift; - my %selected = map { $_=>1 } split(/,\s*/, $plandata->{$label}); - qq(<SELECT NAME="$label" MULTIPLE>). - join("\n", map { - '<OPTION VALUE="'. $_->pkgpart. '"'. - ( $selected{$_->pkgpart} ? ' SELECTED' : '' ). - '>'. $_->pkg. ' - '. $_->comment - } qsearch('part_pkg', { 'disabled' => '' } ) ). - '</SELECT>'; -} - -sub select_agentnum { - my $plandata = shift; - #my $agentnum = $plandata->{'agentnum'}; - my %agentnums = map { $_=>1 } split(/,\s*/, $plandata->{'agentnum'}); - '<SELECT NAME="agentnum" MULTIPLE>'. - join("\n", map { - '<OPTION VALUE="'. $_->agentnum. '"'. - ( $agentnums{$_->agentnum} ? ' SELECTED' : '' ). - '>'. $_->agent - } qsearch('agent', { 'disabled' => '' } ) ). - '</SELECT>'; -} - -my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; - -#this is pretty kludgy right here. -tie my %events, 'Tie::IxHash', - - 'fee' => { - 'name' => 'Late fee (flat)', - 'code' => '$cust_main->charge( %%%charge%%%, \'%%%reason%%%\' );', - 'html' => - 'Amount <INPUT TYPE="text" SIZE="7" NAME="charge" VALUE="%%%charge%%%">'. - '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">', - 'weight' => 10, - }, - 'fee_percent' => { - 'name' => 'Late fee (percentage)', - 'code' => '$cust_main->charge( sprintf(\'%.2f\', $cust_bill->owed * %%%percent%%% / 100 ), \'%%%reason%%%\' );', - 'html' => - 'Percent <INPUT TYPE="text" SIZE="2" NAME="percent" VALUE="%%%percent%%%">%'. - '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">', - 'weight' => 10, - }, - 'suspend' => { - 'name' => 'Suspend', - 'code' => '$cust_main->suspend();', - 'weight' => 10, - }, - 'suspend-if-balance' => { - 'name' => 'Suspend if balance (this invoice and previous) over', - 'code' => '$cust_bill->cust_suspend_if_balance_over( %%%balanceover%%% );', - 'html' => " $money_char ". '<INPUT TYPE="text" SIZE="7" NAME="balanceover" VALUE="%%%balanceover%%%">', - 'weight' => 10, - }, - 'suspend-if-pkgpart' => { - 'name' => 'Suspend packages', - 'code' => '$cust_main->suspend_if_pkgpart(%%%if_pkgpart%%%);', - 'html' => sub { &select_pkgpart('if_pkgpart', @_) }, - 'weight' => 10, - }, - 'suspend-unless-pkgpart' => { - 'name' => 'Suspend packages except', - 'code' => '$cust_main->suspend_unless_pkgpart(%%%unless_pkgpart%%%);', - 'html' => sub { &select_pkgpart('unless_pkgpart', @_) }, - 'weight' => 10, - }, - 'cancel' => { - 'name' => 'Cancel', - 'code' => '$cust_main->cancel();', - 'weight' => 10, - }, - - 'addpost' => { - 'name' => 'Add postal invoicing', - 'code' => '$cust_main->invoicing_list_addpost(); "";', - 'weight' => 20, - }, - - 'comp' => { - 'name' => 'Pay invoice with a complimentary "payment"', - 'code' => '$cust_bill->comp();', - 'weight' => 30, - }, - - 'realtime-card' => { - 'name' => 'Run card with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway', - 'code' => '$cust_bill->realtime_card();', - 'weight' => 30, - }, - - 'realtime-check' => { - 'name' => 'Run check with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway', - 'code' => '$cust_bill->realtime_ach();', - 'weight' => 30, - }, - - 'realtime-lec' => { - 'name' => 'Run phone bill ("LEC") billing with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway', - 'code' => '$cust_bill->realtime_lec();', - 'weight' => 30, - }, - - 'batch-card' => { - 'name' => 'Add card to the pending credit card batch', - 'code' => '$cust_bill->batch_card();', - 'weight' => 40, - }, - - 'send' => { - 'name' => 'Send invoice (email/print/fax)', - 'code' => '$cust_bill->send();', - 'weight' => 50, - }, - - 'send_alternate' => { - 'name' => 'Send invoice (email/print/fax) with alternate template', - 'code' => '$cust_bill->send(\'%%%templatename%%%\');', - 'html' => - '<INPUT TYPE="text" NAME="templatename" VALUE="%%%templatename%%%">', - 'weight' => 50, - }, - - 'send_if_newest' => { - 'name' => 'Send invoice (email/print/fax) with alternate template, if it is still the newest invoice (useful for late notices - set to 31 days or later)', - 'code' => '$cust_bill->send_if_newest(\'%%%if_newest_templatename%%%\');', - 'html' => - '<INPUT TYPE="text" NAME="if_newest_templatename" VALUE="%%%if_newest_templatename%%%">', - 'weight' => 50, - }, - - 'send_agent' => { - 'name' => 'Send invoice (email/print/fax) ', - 'code' => '$cust_bill->send(\'%%%agent_templatename%%%\', [ %%%agentnum%%% ], \'%%%agent_invoice_from%%%\');', - 'html' => sub { - '<TABLE BORDER=0> - <TR> - <TD ALIGN="right">only for agent(s) </TD> - <TD>'. &select_agentnum(@_). '</TD> - </TR> - <TR> - <TD ALIGN="right">with template </TD> - <TD> - <INPUT TYPE="text" NAME="agent_templatename" VALUE="%%%agent_templatename%%%"> - </TD> - </TR> - <TR> - <TD ALIGN="right">email From: </TD> - <TD> - <INPUT TYPE="text" NAME="agent_invoice_from" VALUE="%%%agent_invoice_from%%%"> - </TD> - </TR> - </TABLE>'; - }, - 'weight' => 50, - }, - - 'send_csv_ftp' => { - 'name' => 'Upload CSV invoice data to an FTP server', - 'code' => '$cust_bill->send_csv( protocol => \'ftp\', - server => \'%%%ftpserver%%%\', - username => \'%%%ftpusername%%%\', - password => \'%%%ftppassword%%%\', - dir => \'%%%ftpdir%%%\', - \'format\' => \'%%%ftpformat%%%\', - );', - 'html' => - '<TABLE BORDER=0>'. - '<TR><TD ALIGN="right">Format ("default" or "billco"): </TD>'. - '<TD>'. - '<!--'. - '<SELECT NAME="ftpformat">'. - '<OPTION VALUE="default">Default'. - '<OPTION VALUE="billco">Billco'. - '</SELECT>'. - '-->'. - '<INPUT TYPE="text" NAME="ftpformat" VALUE="%%%ftpformat%%%">'. - '</TD></TR>'. - '<TR><TD ALIGN="right">FTP server: </TD>'. - '<TD><INPUT TYPE="text" NAME="ftpserver" VALUE="%%%ftpserver%%%">'. - '</TD></TR>'. - '<TR><TD ALIGN="right">FTP username: </TD><TD>'. - '<INPUT TYPE="text" NAME="ftpusername" VALUE="%%%ftpusername%%%">'. - '</TD></TR>'. - '<TR><TD ALIGN="right">FTP password: </TD><TD>'. - '<INPUT TYPE="text" NAME="ftppassword" VALUE="%%%ftppassword%%%">'. - '</TD></TR>'. - '<TR><TD ALIGN="right">FTP directory: </TD>'. - '<TD><INPUT TYPE="text" NAME="ftpdir" VALUE="%%%ftpdir%%%">'. - '</TD></TR>'. - '</TABLE>', - 'weight' => 50, - }, - - 'spool_csv' => { - 'name' => 'Spool CSV invoice data', - 'code' => '$cust_bill->spool_csv( - \'format\' => \'%%%spoolformat%%%\', - \'dest\' => \'%%%spooldest%%%\', - \'balanceover\' => \'%%%spoolbalanceover%%%\', - \'agent_spools\' => \'%%%spoolagent_spools%%%\', - );', - 'html' => sub { - my $plandata = shift; - - my $html = - '<TABLE BORDER=0>'. - '<TR><TD ALIGN="right">Format: </TD>'. - '<TD>'. - '<SELECT NAME="spoolformat">'; - - foreach my $option (qw( default billco )) { - $html .= qq(<OPTION VALUE="$option"); - $html .= ' SELECTED' if $option eq $plandata->{'spoolformat'}; - $html .= ">\u$option"; - } - - $html .= - '</SELECT>'. - '</TD></TR>'. - '<TR><TD ALIGN="right">For destination: </TD>'. - '<TD>'. - '<SELECT NAME="spooldest">'; - - tie my %dest, 'Tie::IxHash', - '' => '(all)', - 'POST' => 'Postal Mail', - 'EMAIL' => 'Email', - 'FAX' => 'Fax', - ; - - foreach my $dest (keys %dest) { - $html .= qq(<OPTION VALUE="$dest"); - $html .= ' SELECTED' if $dest eq $plandata->{'spooldest'}; - $html .= '>'. $dest{$dest}; - } - - $html .= - '</SELECT>'. - '</TD></TR>'. - - '<TR>'. - '<TD ALIGN="right">if balance (this invoice and previous) over </TD>'. - '<TD>'. - "$money_char ". - '<INPUT TYPE="text" SIZE="7" NAME="spoolbalanceover" VALUE="%%%spoolbalanceover%%%">'. - '</TD>'. - '<TR><TD ALIGN="right">Individual per-agent spools? </TD>'. - '<TD><INPUT TYPE="checkbox" NAME="spoolagent_spools" VALUE="1" '. - ( $plandata->{'spoolagent_spools'} ? 'CHECKED' : '' ). - '>'. - '</TD></TR>'. - '</TABLE>'; - - $html; - }, - 'weight' => 50, - }, - - 'bill' => { - 'name' => 'Generate invoices (normally only used with a <i>Late Fee</i> event)', - 'code' => '$cust_main->bill();', - 'weight' => 60, - }, - - 'apply' => { - 'name' => 'Apply unapplied payments and credits', - 'code' => '$cust_main->apply_payments; $cust_main->apply_credits; "";', - 'weight' => 70, - }, - - 'collect' => { - 'name' => 'Collect on invoices (normally only used with a <i>Late Fee</i> and <i>Generate Invoice</i> events)', - 'code' => '$cust_main->collect();', - 'weight' => 80, - }, - -; - -foreach my $event ( keys %events ) { - my %plandata = map { /^(\w+) (.*)$/; ($1, $2); } - split(/\n/, $part_bill_event->plandata); - my $html = $events{$event}{html}; - if ( ref($html) eq 'CODE' ) { - $html = &{$html}(\%plandata); - } - while ( $html =~ /%%%(\w+)%%%/ ) { - my $field = $1; - $html =~ s/%%%$field%%%/$plandata{$field}/; - } - - print ntable( "#cccccc", 2). - qq!<TR><TD><INPUT TYPE="radio" NAME="plan_weight_eventcode" !; - print "CHECKED " if $event eq $part_bill_event->plan; - print qq!VALUE="!. $event. ":". $events{$event}{weight}. ":". - encode_entities($events{$event}{code}). - qq!">$events{$event}{name}</TD>!; - print '<TD>'. $html. '</TD>' if $html; - print qq!</TR>!; - print '</TABLE>'; -} - -#print '</TABLE>'; - -print <<END; -</TD></TR> -</TABLE> -END - -print qq!<INPUT TYPE="submit" VALUE="!, - $hashref->{eventpart} ? "Apply changes" : "Add invoice event", - qq!">!; -%> </FORM> </BODY> diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi index 6a8a0deb6..6717471dd 100644 --- a/httemplate/edit/part_export.cgi +++ b/httemplate/edit/part_export.cgi @@ -1,128 +1,130 @@ <!-- mason kludge --> -<% - -#if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { -# $cgi->param('clone', $1); -#} else { -# $cgi->param('clone', ''); -#} - -my($query) = $cgi->keywords; -my $action = ''; -my $part_export = ''; -if ( $cgi->param('error') ) { - $part_export = new FS::part_export ( { - map { $_, scalar($cgi->param($_)) } fields('part_export') - } ); -} elsif ( $query =~ /^(\d+)$/ ) { - $part_export = qsearchs('part_export', { 'exportnum' => $1 } ); -} else { - $part_export = new FS::part_export; -} -$action ||= $part_export->exportnum ? 'Edit' : 'Add'; - -#my $exports = FS::part_export::export_info($svcdb); -my $exports = FS::part_export::export_info(); - -my %layers = map { $_ => "$_ - ". $exports->{$_}{desc} } keys %$exports; -$layers{''}=''; - -my $widget = new HTML::Widgets::SelectLayers( - 'selected_layer' => $part_export->exporttype, - 'options' => \%layers, - 'form_name' => 'dummy', - 'form_action' => 'process/part_export.cgi', - 'form_text' => [qw( exportnum machine )], -# 'form_checkbox' => [qw()], - 'html_between' => "</TD></TR></TABLE>\n", - 'layer_callback' => sub { - my $layer = shift; - my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!. - ntable("#cccccc",2); - - $html .= '<TR><TD ALIGN="right">Description</TD><TD BGCOLOR=#ffffff>'. - $exports->{$layer}{notes}. '</TD></TR>' - if $layer; - - foreach my $option ( keys %{$exports->{$layer}{options}} ) { - my $optinfo = $exports->{$layer}{options}{$option}; - die "Retreived non-ref export info option from $layer export: $optinfo" - unless ref($optinfo); - my $label = $optinfo->{label}; - my $type = defined($optinfo->{type}) ? $optinfo->{type} : 'text'; - my $value = $cgi->param($option) - || ( $part_export->exportnum && $part_export->option($option) ) - || ( (exists $optinfo->{default} && !$part_export->exportnum) - ? $optinfo->{default} - : '' - ); - $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!; - if ( $type eq 'select' ) { - $html .= qq!<SELECT NAME="$option">!; - foreach my $select_option ( @{$optinfo->{options}} ) { - #if ( ref($select_option) ) { - #} else { - my $selected = $select_option eq $value ? ' SELECTED' : ''; - $html .= qq!<OPTION VALUE="$select_option"$selected>!. - qq!$select_option</OPTION>!; - #} - } - $html .= '</SELECT>'; - } elsif ( $type eq 'textarea' ) { - $html .= qq!<TEXTAREA NAME="$option" COLS=80 ROWS=8 WRAP="virtual">!. - encode_entities($value). '</TEXTAREA>'; - } elsif ( $type eq 'text' ) { - $html .= qq!<INPUT TYPE="text" NAME="$option" VALUE="!. - encode_entities($value). '" SIZE=64>'; - } elsif ( $type eq 'checkbox' ) { - $html .= qq!<INPUT TYPE="checkbox" NAME="$option" VALUE="1"!; - $html .= ' CHECKED' if $value; - $html .= '>'; - } else { - $html .= "unknown type $type"; - } - $html .= '</TD></TR>'; - } - $html .= '</TABLE>'; - - $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'. - join(',', keys %{$exports->{$layer}{options}} ). '">'; - - $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'. - $exports->{$layer}{nodomain}. '">'; - - $html .= '<INPUT TYPE="submit" VALUE="'. - ( $part_export->exportnum ? "Apply changes" : "Add export" ). - '">'; - - $html; - }, -); - -%> -<%= include("/elements/header.html","$action Export", menubar( +% +% +%#if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { +%# $cgi->param('clone', $1); +%#} else { +%# $cgi->param('clone', ''); +%#} +% +%my($query) = $cgi->keywords; +%my $action = ''; +%my $part_export = ''; +%if ( $cgi->param('error') ) { +% $part_export = new FS::part_export ( { +% map { $_, scalar($cgi->param($_)) } fields('part_export') +% } ); +%} elsif ( $query =~ /^(\d+)$/ ) { +% $part_export = qsearchs('part_export', { 'exportnum' => $1 } ); +%} else { +% $part_export = new FS::part_export; +%} +%$action ||= $part_export->exportnum ? 'Edit' : 'Add'; +% +%#my $exports = FS::part_export::export_info($svcdb); +%my $exports = FS::part_export::export_info(); +% +%my %layers = map { $_ => "$_ - ". $exports->{$_}{desc} } keys %$exports; +%$layers{''}=''; +% +%my $widget = new HTML::Widgets::SelectLayers( +% 'selected_layer' => $part_export->exporttype, +% 'options' => \%layers, +% 'form_name' => 'dummy', +% 'form_action' => 'process/part_export.cgi', +% 'form_text' => [qw( exportnum machine )], +%# 'form_checkbox' => [qw()], +% 'html_between' => "</TD></TR></TABLE>\n", +% 'layer_callback' => sub { +% my $layer = shift; +% my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!. +% ntable("#cccccc",2); +% +% $html .= '<TR><TD ALIGN="right">Description</TD><TD BGCOLOR=#ffffff>'. +% $exports->{$layer}{notes}. '</TD></TR>' +% if $layer; +% +% foreach my $option ( keys %{$exports->{$layer}{options}} ) { +% my $optinfo = $exports->{$layer}{options}{$option}; +% die "Retreived non-ref export info option from $layer export: $optinfo" +% unless ref($optinfo); +% my $label = $optinfo->{label}; +% my $type = defined($optinfo->{type}) ? $optinfo->{type} : 'text'; +% my $value = $cgi->param($option) +% || ( $part_export->exportnum && $part_export->option($option) ) +% || ( (exists $optinfo->{default} && !$part_export->exportnum) +% ? $optinfo->{default} +% : '' +% ); +% $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!; +% if ( $type eq 'select' ) { +% $html .= qq!<SELECT NAME="$option">!; +% foreach my $select_option ( @{$optinfo->{options}} ) { +% #if ( ref($select_option) ) { +% #} else { +% my $selected = $select_option eq $value ? ' SELECTED' : ''; +% $html .= qq!<OPTION VALUE="$select_option"$selected>!. +% qq!$select_option</OPTION>!; +% #} +% } +% $html .= '</SELECT>'; +% } elsif ( $type eq 'textarea' ) { +% $html .= qq!<TEXTAREA NAME="$option" COLS=80 ROWS=8 WRAP="virtual">!. +% encode_entities($value). '</TEXTAREA>'; +% } elsif ( $type eq 'text' ) { +% $html .= qq!<INPUT TYPE="text" NAME="$option" VALUE="!. +% encode_entities($value). '" SIZE=64>'; +% } elsif ( $type eq 'checkbox' ) { +% $html .= qq!<INPUT TYPE="checkbox" NAME="$option" VALUE="1"!; +% $html .= ' CHECKED' if $value; +% $html .= '>'; +% } else { +% $html .= "unknown type $type"; +% } +% $html .= '</TD></TR>'; +% } +% $html .= '</TABLE>'; +% +% $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'. +% join(',', keys %{$exports->{$layer}{options}} ). '">'; +% +% $html .= '<INPUT TYPE="hidden" NAME="nodomain" VALUE="'. +% $exports->{$layer}{nodomain}. '">'; +% +% $html .= '<INPUT TYPE="submit" VALUE="'. +% ( $part_export->exportnum ? "Apply changes" : "Add export" ). +% '">'; +% +% $html; +% }, +%); +% +% + +<% include("/elements/header.html","$action Export", menubar( 'Main Menu' => popurl(2), ), ' onLoad="visualize()"') %> +% if ( $cgi->param('error') ) { -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> +% } + <FORM NAME="dummy"> -<INPUT TYPE="hidden" NAME="exportnum" VALUE="<%= $part_export->exportnum %>"> +<INPUT TYPE="hidden" NAME="exportnum" VALUE="<% $part_export->exportnum %>"> -<%= ntable("#cccccc",2) %> +<% ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Export host</TD> <TD> - <INPUT TYPE="text" NAME="machine" VALUE="<%= $part_export->machine %>"> + <INPUT TYPE="text" NAME="machine" VALUE="<% $part_export->machine %>"> </TD> </TR> <TR> <TD ALIGN="right">Export</TD> - <TD><%= $widget->html %> + <TD><% $widget->html %> </BODY> </HTML> diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index b085d2260..185d66ac7 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,100 +1,101 @@ -<% - -if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { - $cgi->param('clone', $1); -} else { - $cgi->param('clone', ''); -} -if ( $cgi->param('pkgnum') && $cgi->param('pkgnum') =~ /^(\d+)$/ ) { - $cgi->param('pkgnum', $1); -} else { - $cgi->param('pkgnum', ''); -} - -my ($query) = $cgi->keywords; - -my $part_pkg = ''; -if ( $cgi->param('error') ) { - $part_pkg = new FS::part_pkg ( { - map { $_, scalar($cgi->param($_)) } fields('part_pkg') - } ); -} - -my $action = ''; -my $clone_part_pkg = ''; -my $pkgpart = ''; -if ( $cgi->param('clone') ) { - $pkgpart = $cgi->param('clone'); - $action = 'Custom Pricing'; - $clone_part_pkg= qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } ); - $part_pkg ||= $clone_part_pkg->clone; - $part_pkg->disabled('Y'); #isn't sticky on errors -} elsif ( $query && $query =~ /^(\d+)$/ ) { - $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); - $pkgpart = $part_pkg->pkgpart; -} else { - unless ( $part_pkg ) { - $part_pkg = new FS::part_pkg {}; - $part_pkg->plan('flat'); - } -} -unless ( $part_pkg->plan ) { #backwards-compat - $part_pkg->plan('flat'); - $part_pkg->plandata("setup_fee=". $part_pkg->setup. "\n". - "recur_fee=". $part_pkg->recur. "\n"); -} -$action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; -my $hashref = $part_pkg->hashref; - -%> - -<%= include("/elements/header.html","$action Package Definition", menubar( +% +% +%if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { +% $cgi->param('clone', $1); +%} else { +% $cgi->param('clone', ''); +%} +%if ( $cgi->param('pkgnum') && $cgi->param('pkgnum') =~ /^(\d+)$/ ) { +% $cgi->param('pkgnum', $1); +%} else { +% $cgi->param('pkgnum', ''); +%} +% +%my ($query) = $cgi->keywords; +% +%my $part_pkg = ''; +%if ( $cgi->param('error') ) { +% $part_pkg = new FS::part_pkg ( { +% map { $_, scalar($cgi->param($_)) } fields('part_pkg') +% } ); +%} +% +%my $action = ''; +%my $clone_part_pkg = ''; +%my $pkgpart = ''; +%if ( $cgi->param('clone') ) { +% $pkgpart = $cgi->param('clone'); +% $action = 'Custom Pricing'; +% $clone_part_pkg= qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } ); +% $part_pkg ||= $clone_part_pkg->clone; +% $part_pkg->disabled('Y'); #isn't sticky on errors +%} elsif ( $query && $query =~ /^(\d+)$/ ) { +% $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); +% $pkgpart = $part_pkg->pkgpart; +%} else { +% unless ( $part_pkg ) { +% $part_pkg = new FS::part_pkg {}; +% $part_pkg->plan('flat'); +% } +%} +%unless ( $part_pkg->plan ) { #backwards-compat +% $part_pkg->plan('flat'); +% $part_pkg->plandata("setup_fee=". $part_pkg->setup. "\n". +% "recur_fee=". $part_pkg->recur. "\n"); +%} +%$action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; +%my $hashref = $part_pkg->hashref; +% +% + + +<% include("/elements/header.html","$action Package Definition", menubar( 'Main Menu' => popurl(2), 'View all packages' => popurl(2). 'browse/part_pkg.cgi', )) %> +% #), ' onLoad="visualize()"'); +% if ( $cgi->param('error') ) { -<% #), ' onLoad="visualize()"'); %> + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> +% } -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> <FORM NAME="dummy"> -<%= itable('',8,1) %><TR><TD VALIGN="top"> +<% itable('',8,1) %><TR><TD VALIGN="top"> Package information -<%= ntable("#cccccc",2) %> +<% ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Package Definition #</TD> <TD BGCOLOR="#ffffff"> - <%= $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)" %> + <% $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)" %> </TD> </TR> <TR> <TD ALIGN="right">Package (customer-visible)</TD> <TD> - <INPUT TYPE="text" NAME="pkg" SIZE=32 VALUE="<%= $part_pkg->pkg %>"> + <INPUT TYPE="text" NAME="pkg" SIZE=32 VALUE="<% $part_pkg->pkg %>"> </TD> </TR> <TR> <TD ALIGN="right">Comment (customer-hidden)</TD> <TD> - <INPUT TYPE="text" NAME="comment" SIZE=32 VALUE="<%=$part_pkg->comment%>"> + <INPUT TYPE="text" NAME="comment" SIZE=32 VALUE="<%$part_pkg->comment%>"> </TD> </TR> - <%= include( '/elements/tr-select-pkg_class.html', $part_pkg->classnum ) %> + <% include( '/elements/tr-select-pkg_class.html', $part_pkg->classnum ) %> <TR> <TD ALIGN="right">Promotional code</TD> <TD> - <INPUT TYPE="text" NAME="promo_code" SIZE=32 VALUE="<%=$part_pkg->promo_code%>"> + <INPUT TYPE="text" NAME="promo_code" SIZE=32 VALUE="<%$part_pkg->promo_code%>"> </TD> </TR> <TR> <TD ALIGN="right">Disable new orders</TD> <TD> - <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %> + <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %> </TD> </TR> @@ -103,253 +104,253 @@ Package information </TD><TD VALIGN="top"> Tax information -<%= ntable("#cccccc", 2) %> +<% ntable("#cccccc", 2) %> <TR> <TD ALIGN="right">Setup fee tax exempt</TD> <TD> - <INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <%= $hashref->{setuptax} eq 'Y' ? ' CHECKED' : '' %>> + <INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <% $hashref->{setuptax} eq 'Y' ? ' CHECKED' : '' %>> </TD> </TR> <TR> <TD ALIGN="right">Recurring fee tax exempt</TD> <TD> - <INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y" <%= $hashref->{recurtax} eq 'Y' ? ' CHECKED' : '' %>> + <INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y" <% $hashref->{recurtax} eq 'Y' ? ' CHECKED' : '' %>> </TD> </TR> +% my $conf = new FS::Conf; +% if ( $conf->exists('enable_taxclasses') ) { -<% my $conf = new FS::Conf; %> -<% if ( $conf->exists('enable_taxclasses') ) { %> <TR> <TD align="right">Tax class</TD> <TD> - <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> + <% include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> </TD> </TR> +% } else { -<% } else { %> - <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> + <% include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> +% } -<% } %> </TABLE> </TD></TR></TABLE> +% +% +%my $thead = "\n\n". ntable('#cccccc', 2). +% '<TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH>'; +%$thead .= '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Primary</FONT></TH>' +% if dbdef->table('pkg_svc')->column('primary_svc'); +%$thead .= '<TH BGCOLOR="#dcdcdc">Service</TH></TR>'; +% +% -<% - -my $thead = "\n\n". ntable('#cccccc', 2). - '<TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH>'; -$thead .= '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Primary</FONT></TH>' - if dbdef->table('pkg_svc')->column('primary_svc'); -$thead .= '<TH BGCOLOR="#dcdcdc">Service</TH></TR>'; - -%> <BR><BR>Services included -<%= itable('', 4, 1) %><TR><TD VALIGN="top"> -<%= $thead %> - -<% +<% itable('', 4, 1) %><TR><TD VALIGN="top"> +<% $thead %> +% +% +%my $where = "WHERE disabled IS NULL OR disabled = ''"; +%if ( $pkgpart ) { +% $where .= " OR 0 < ( SELECT quantity FROM pkg_svc +% WHERE pkg_svc.svcpart = part_svc.svcpart +% AND pkgpart = $pkgpart +% )"; +%} +%my @part_svc = qsearch('part_svc', {}, '', $where); +%my $q_part_pkg = $clone_part_pkg || $part_pkg; +%my %pkg_svc = map { $_->svcpart => $_ } $q_part_pkg->pkg_svc; +% +%my @fixups = (); +%my $count = 0; +%my $columns = 3; +%foreach my $part_svc ( @part_svc ) { +% my $svcpart = $part_svc->svcpart; +% my $pkg_svc = $pkg_svc{$svcpart} +% || new FS::pkg_svc ( { +% 'pkgpart' => $pkgpart, +% 'svcpart' => $svcpart, +% 'quantity' => 0, +% 'primary_svc' => '', +% } ); +% +% push @fixups, "pkg_svc$svcpart"; +% +% -my $where = "WHERE disabled IS NULL OR disabled = ''"; -if ( $pkgpart ) { - $where .= " OR 0 < ( SELECT quantity FROM pkg_svc - WHERE pkg_svc.svcpart = part_svc.svcpart - AND pkgpart = $pkgpart - )"; -} -my @part_svc = qsearch('part_svc', {}, '', $where); -my $q_part_pkg = $clone_part_pkg || $part_pkg; -my %pkg_svc = map { $_->svcpart => $_ } $q_part_pkg->pkg_svc; - -my @fixups = (); -my $count = 0; -my $columns = 3; -foreach my $part_svc ( @part_svc ) { - my $svcpart = $part_svc->svcpart; - my $pkg_svc = $pkg_svc{$svcpart} - || new FS::pkg_svc ( { - 'pkgpart' => $pkgpart, - 'svcpart' => $svcpart, - 'quantity' => 0, - 'primary_svc' => '', - } ); - - push @fixups, "pkg_svc$svcpart"; - -%> <TR> <TD> - <INPUT TYPE="text" NAME="pkg_svc<%= $svcpart %>" SIZE=4 MAXLENGTH=3 VALUE="<%= $cgi->param("pkg_svc$svcpart") || $pkg_svc->quantity || 0 %>"> + <INPUT TYPE="text" NAME="pkg_svc<% $svcpart %>" SIZE=4 MAXLENGTH=3 VALUE="<% $cgi->param("pkg_svc$svcpart") || $pkg_svc->quantity || 0 %>"> </TD> <TD> - <INPUT TYPE="radio" NAME="pkg_svc_primary" VALUE="<%= $svcpart %>" <%= $pkg_svc->primary_svc =~ /^Y/i ? ' CHECKED' : '' %>> + <INPUT TYPE="radio" NAME="pkg_svc_primary" VALUE="<% $svcpart %>" <% $pkg_svc->primary_svc =~ /^Y/i ? ' CHECKED' : '' %>> </TD> <TD> - <A HREF="part_svc.cgi?<%= $part_svc->svcpart %>"><%= $part_svc->svc %></A> <%= $part_svc->disabled =~ /^Y/i ? ' (DISABLED' : '' %> + <A HREF="part_svc.cgi?<% $part_svc->svcpart %>"><% $part_svc->svc %></A> <% $part_svc->disabled =~ /^Y/i ? ' (DISABLED' : '' %> </TD> </TR> +% foreach ( 1 .. $columns-1 ) { +% if ( $count == int( $_ * scalar(@part_svc) / $columns ) ) { +% - <% foreach ( 1 .. $columns-1 ) { - if ( $count == int( $_ * scalar(@part_svc) / $columns ) ) { - %> - </TABLE></TD><TD VALIGN="top"><%= $thead %> - - <% } - } - $count++; - %> + </TABLE></TD><TD VALIGN="top"><% $thead %> +% } +% } +% $count++; +% +% } -<% } %> </TR></TABLE></TD></TR></TABLE> - -<% foreach my $f ( qw( clone pkgnum ) ) { %> - <INPUT TYPE="hidden" NAME="<%= $f %>" VALUE="<%= $cgi->param($f) %>"> -<% } %> -<INPUT TYPE="hidden" NAME="pkgpart" VALUE="<%= $part_pkg->pkgpart %>"> - -<% - -# prolly should be in database -tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() }; - -my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } - split("\n", ($clone_part_pkg||$part_pkg)->plandata ); -#warn join("\n", map { "$_: $plandata{$_}" } keys %plandata ). "\n"; - -tie my %options, 'Tie::IxHash', map { $_=>$plans{$_}->{'name'} } keys %plans; - -my @form_select = ('classnum'); -if ( $conf->exists('enable_taxclasses') ) { - push @form_select, 'taxclass'; -} else { - push @fixups, 'taxclass'; #hidden -} - -my @form_radio = (); -if ( dbdef->table('pkg_svc')->column('primary_svc') ) { - push @form_radio, 'pkg_svc_primary'; -} - -tie my %freq, 'Tie::IxHash', %{FS::part_pkg->freqs_href()}; -if ( $part_pkg->dbdef_table->column('freq')->type =~ /(int)/i ) { - delete $freq{$_} foreach grep { ! /^\d+$/ } keys %freq; -} - -my $widget = new HTML::Widgets::SelectLayers( - 'selected_layer' => $part_pkg->plan, - 'options' => \%options, - 'form_name' => 'dummy', - 'form_action' => 'process/part_pkg.cgi', - 'form_text' => [ qw(pkg comment promo_code clone pkgnum pkgpart), - @fixups - ], - 'form_checkbox' => [ qw(setuptax recurtax disabled) ], - 'form_radio' => \@form_radio, - 'form_select' => \@form_select, - 'layer_callback' => sub { - my $layer = shift; - my $html = qq!<INPUT TYPE="hidden" NAME="plan" VALUE="$layer">!. - ntable("#cccccc",2); - $html .= ' - <TR> - <TD ALIGN="right">Recurring fee frequency </TD> - <TD><SELECT NAME="freq"> - '; - - my @freq = keys %freq; - @freq = grep { /^\d+$/ } @freq - if exists($plans{$layer}->{'freq'}) && $plans{$layer}->{'freq'} eq 'm'; - foreach my $freq ( @freq ) { - $html .= qq(<OPTION VALUE="$freq"); - $html .= ' SELECTED' if $freq eq $part_pkg->freq; - $html .= ">$freq{$freq}"; - } - $html .= '</SELECT></TD></TR>'; - - my $href = $plans{$layer}->{'fields'}; - foreach my $field ( exists($plans{$layer}->{'fieldorder'}) - ? @{$plans{$layer}->{'fieldorder'}} - : keys %{ $href } - ) { - - $html .= '<TR><TD ALIGN="right">'. $href->{$field}{'name'}. '</TD><TD>'; - - if ( ! exists($href->{$field}{'type'}) ) { - $html .= qq!<INPUT TYPE="text" NAME="$field" VALUE="!. - ( exists($plandata{$field}) - ? $plandata{$field} - : $href->{$field}{'default'} ). - qq!" onChange="fchanged(this)">!; - } elsif ( $href->{$field}{'type'} eq 'checkbox' ) { - $html .= qq!<INPUT TYPE="checkbox" NAME="$field" VALUE=1 !. - ( exists($plandata{$field}) && $plandata{$field} - ? ' CHECKED' - : '' - ). '>'; - } elsif ( $href->{$field}{'type'} =~ /^select/ ) { - $html .= '<SELECT'; - $html .= ' MULTIPLE' - if $href->{$field}{'type'} eq 'select_multiple'; - $html .= qq! NAME="$field" onChange="fchanged(this)">!; - - if ( $href->{$field}{'select_table'} ) { - foreach my $record ( - qsearch( $href->{$field}{'select_table'}, - $href->{$field}{'select_hash'} ) - ) { - my $value = $record->getfield($href->{$field}{'select_key'}); - $html .= qq!<OPTION VALUE="$value"!. - ( $plandata{$field} =~ /(^|, *)$value *(,|$)/ - ? ' SELECTED' - : '' - ). - '>'. $record->getfield($href->{$field}{'select_label'}); - } - } elsif ( $href->{$field}{'select_options'} ) { - foreach my $key ( keys %{ $href->{$field}{'select_options'} } ) { - my $value = $href->{$field}{'select_options'}{$key}; - $html .= qq!<OPTION VALUE="$key"!. - ( $plandata{$field} =~ /(^|, *)$value *(,|$)/ - ? ' SELECTED' - : '' - ). - '>'. $value; - } - - } else { - $html .= '<font color="#ff0000">warning: '. - "don't know how to retreive options for $field select field". - '</font>'; - } - $html .= '</SELECT>'; - } - - $html .= '</TD></TR>'; - } - $html .= '</TABLE>'; - - $html .= '<INPUT TYPE="hidden" NAME="plandata" VALUE="'. - join(',', keys %{ $href } ). '">'. - '<BR><BR>'; - - $html .= '<INPUT TYPE="submit" VALUE="'. - ( $hashref->{pkgpart} ? "Apply changes" : "Add package" ). - '" onClick="fchanged(this)">'; - - $html; - - }, -); - -%> - -<BR><BR>Price plan <%= $widget->html %> +% foreach my $f ( qw( clone pkgnum ) ) { + + <INPUT TYPE="hidden" NAME="<% $f %>" VALUE="<% $cgi->param($f) %>"> +% } + +<INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>"> +% +% +%# prolly should be in database +%tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() }; +% +%my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } +% split("\n", ($clone_part_pkg||$part_pkg)->plandata ); +%#warn join("\n", map { "$_: $plandata{$_}" } keys %plandata ). "\n"; +% +%tie my %options, 'Tie::IxHash', map { $_=>$plans{$_}->{'name'} } keys %plans; +% +%my @form_select = ('classnum'); +%if ( $conf->exists('enable_taxclasses') ) { +% push @form_select, 'taxclass'; +%} else { +% push @fixups, 'taxclass'; #hidden +%} +% +%my @form_radio = (); +%if ( dbdef->table('pkg_svc')->column('primary_svc') ) { +% push @form_radio, 'pkg_svc_primary'; +%} +% +%tie my %freq, 'Tie::IxHash', %{FS::part_pkg->freqs_href()}; +%if ( $part_pkg->dbdef_table->column('freq')->type =~ /(int)/i ) { +% delete $freq{$_} foreach grep { ! /^\d+$/ } keys %freq; +%} +% +%my $widget = new HTML::Widgets::SelectLayers( +% 'selected_layer' => $part_pkg->plan, +% 'options' => \%options, +% 'form_name' => 'dummy', +% 'form_action' => 'process/part_pkg.cgi', +% 'form_text' => [ qw(pkg comment promo_code clone pkgnum pkgpart), +% @fixups +% ], +% 'form_checkbox' => [ qw(setuptax recurtax disabled) ], +% 'form_radio' => \@form_radio, +% 'form_select' => \@form_select, +% 'layer_callback' => sub { +% my $layer = shift; +% my $html = qq!<INPUT TYPE="hidden" NAME="plan" VALUE="$layer">!. +% ntable("#cccccc",2); +% $html .= ' +% <TR> +% <TD ALIGN="right">Recurring fee frequency </TD> +% <TD><SELECT NAME="freq"> +% '; +% +% my @freq = keys %freq; +% @freq = grep { /^\d+$/ } @freq +% if exists($plans{$layer}->{'freq'}) && $plans{$layer}->{'freq'} eq 'm'; +% foreach my $freq ( @freq ) { +% $html .= qq(<OPTION VALUE="$freq"); +% $html .= ' SELECTED' if $freq eq $part_pkg->freq; +% $html .= ">$freq{$freq}"; +% } +% $html .= '</SELECT></TD></TR>'; +% +% my $href = $plans{$layer}->{'fields'}; +% foreach my $field ( exists($plans{$layer}->{'fieldorder'}) +% ? @{$plans{$layer}->{'fieldorder'}} +% : keys %{ $href } +% ) { +% +% $html .= '<TR><TD ALIGN="right">'. $href->{$field}{'name'}. '</TD><TD>'; +% +% if ( ! exists($href->{$field}{'type'}) ) { +% $html .= qq!<INPUT TYPE="text" NAME="$field" VALUE="!. +% ( exists($plandata{$field}) +% ? $plandata{$field} +% : $href->{$field}{'default'} ). +% qq!" onChange="fchanged(this)">!; +% } elsif ( $href->{$field}{'type'} eq 'checkbox' ) { +% $html .= qq!<INPUT TYPE="checkbox" NAME="$field" VALUE=1 !. +% ( exists($plandata{$field}) && $plandata{$field} +% ? ' CHECKED' +% : '' +% ). '>'; +% } elsif ( $href->{$field}{'type'} =~ /^select/ ) { +% $html .= '<SELECT'; +% $html .= ' MULTIPLE' +% if $href->{$field}{'type'} eq 'select_multiple'; +% $html .= qq! NAME="$field" onChange="fchanged(this)">!; +% +% if ( $href->{$field}{'select_table'} ) { +% foreach my $record ( +% qsearch( $href->{$field}{'select_table'}, +% $href->{$field}{'select_hash'} ) +% ) { +% my $value = $record->getfield($href->{$field}{'select_key'}); +% $html .= qq!<OPTION VALUE="$value"!. +% ( $plandata{$field} =~ /(^|, *)$value *(,|$)/ +% ? ' SELECTED' +% : '' +% ). +% '>'. $record->getfield($href->{$field}{'select_label'}); +% } +% } elsif ( $href->{$field}{'select_options'} ) { +% foreach my $key ( keys %{ $href->{$field}{'select_options'} } ) { +% my $value = $href->{$field}{'select_options'}{$key}; +% $html .= qq!<OPTION VALUE="$key"!. +% ( $plandata{$field} =~ /(^|, *)$value *(,|$)/ +% ? ' SELECTED' +% : '' +% ). +% '>'. $value; +% } +% +% } else { +% $html .= '<font color="#ff0000">warning: '. +% "don't know how to retreive options for $field select field". +% '</font>'; +% } +% $html .= '</SELECT>'; +% } +% +% $html .= '</TD></TR>'; +% } +% $html .= '</TABLE>'; +% +% $html .= '<INPUT TYPE="hidden" NAME="plandata" VALUE="'. +% join(',', keys %{ $href } ). '">'. +% '<BR><BR>'; +% +% $html .= '<INPUT TYPE="submit" VALUE="'. +% ( $hashref->{pkgpart} ? "Apply changes" : "Add package" ). +% '" onClick="fchanged(this)">'; +% +% $html; +% +% }, +%); +% +% + + +<BR><BR>Price plan <% $widget->html %> </BODY> </HTML> diff --git a/httemplate/edit/part_referral.html b/httemplate/edit/part_referral.html index ec0f32f58..7ce52174d 100755 --- a/httemplate/edit/part_referral.html +++ b/httemplate/edit/part_referral.html @@ -1,4 +1,4 @@ -<%= include( 'elements/edit.html', +<% include( 'elements/edit.html', 'name' => 'Advertising source', 'table' => 'part_referral', 'fields' => [ 'referral' ], diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 489a2339c..595d7b87a 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -1,29 +1,30 @@ -<% -my $part_svc; -my $clone = ''; -if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {#clone - #$cgi->param('clone') =~ /^(\d+)$/ or die "malformed query: $query"; - $part_svc = qsearchs('part_svc', { 'svcpart'=>$1 } ) - or die "unknown svcpart: $1"; - $clone = $part_svc->svcpart; - $part_svc->svcpart(''); -} elsif ( $cgi->keywords ) { #edit - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/ or die "malformed query: $query"; - $part_svc=qsearchs('part_svc', { 'svcpart'=>$1 } ) - or die "unknown svcpart: $1"; -} else { #adding - $part_svc = new FS::part_svc {}; -} - -my $action = $part_svc->svcpart ? 'Edit' : 'Add'; -my $hashref = $part_svc->hashref; -# my $p_svcdb = $part_svc->svcdb || 'svc_acct'; - - - #" onLoad=\"visualize()\"" -%> -<%= include("/elements/header.html","$action Service Definition", +% +%my $part_svc; +%my $clone = ''; +%if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {#clone +% #$cgi->param('clone') =~ /^(\d+)$/ or die "malformed query: $query"; +% $part_svc = qsearchs('part_svc', { 'svcpart'=>$1 } ) +% or die "unknown svcpart: $1"; +% $clone = $part_svc->svcpart; +% $part_svc->svcpart(''); +%} elsif ( $cgi->keywords ) { #edit +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/ or die "malformed query: $query"; +% $part_svc=qsearchs('part_svc', { 'svcpart'=>$1 } ) +% or die "unknown svcpart: $1"; +%} else { #adding +% $part_svc = new FS::part_svc {}; +%} +% +%my $action = $part_svc->svcpart ? 'Edit' : 'Add'; +%my $hashref = $part_svc->hashref; +%# my $p_svcdb = $part_svc->svcdb || 'svc_acct'; +% +% +% #" onLoad=\"visualize()\"" +% + +<% include("/elements/header.html","$action Service Definition", menubar( 'Main Menu' => $p, 'View all service definitions' => "${p}browse/part_svc.cgi" ), @@ -32,11 +33,11 @@ my $hashref = $part_svc->hashref; <FORM NAME="dummy"> - Service Part #<%= $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %> + Service Part #<% $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %> <BR><BR> -Service <INPUT TYPE="text" NAME="svc" VALUE="<%= $hashref->{svc} %>"><BR> -Disable new orders <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>><BR> -<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $hashref->{svcpart} %>"> +Service <INPUT TYPE="text" NAME="svc" VALUE="<% $hashref->{svc} %>"><BR> +Disable new orders <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>><BR> +<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $hashref->{svcpart} %>"> <BR> Service definitions are the templates for items you offer to your customers. <UL><LI>svc_acct - Accounts - anything with a username (Mailboxes, PPP accounts, shell accounts, RADIUS entries for broadband, etc.) @@ -54,402 +55,402 @@ For the selected table, you can give fields default or fixed (unchangable) values, or select an inventory class to manually or automatically fill in that field. <BR><BR> - -<% - -#these might belong somewhere else for other user interfaces -#pry need to eventually create stuff that's shared amount UIs -my $conf = new FS::Conf; -my %defs = ( - - 'svc_acct' => { - 'dir' => 'Home directory', - 'uid' => 'UID (set to fixed and blank for no UIDs)', - 'slipip' => 'IP address', -# 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!, - 'popnum' => { - desc => 'Access number', - type => 'select', - select_table => 'svc_acct_pop', - select_key => 'popnum', - select_label => 'city', - }, - 'username' => { - desc => 'Username', - type => 'text', - disable_default => 1, - disable_fixed => 1, - }, - 'quota' => { - desc => '', - type => 'text', - disable_inventory => 1, - }, - '_password' => 'Password', - 'gid' => 'GID (when blank, defaults to UID)', - 'shell' => { - #desc =>'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file, set to blank for no shell tracking)', - desc =>'Shell ( set to blank for no shell tracking)', - type =>'select', - select_list => [ $conf->config('shells') ], - disable_inventory => 1, - }, - 'finger' => 'Real name (GECOS)', - 'domsvc' => { - desc =>'svcnum from svc_domain', - type =>'select', - select_table => 'svc_domain', - select_key => 'svcnum', - select_label => 'domain', - disable_inventory => 1, - }, - 'usergroup' => { - desc =>'RADIUS groups', - type =>'radius_usergroup_selector', - disable_inventory => 1, - }, - 'seconds' => { desc => '', - type => 'text', - disable_inventory => 1, - }, - }, - - 'svc_domain' => { - 'domain' => 'Domain', - }, - - 'svc_forward' => { - 'srcsvc' => 'service from which mail is to be forwarded', - 'dstsvc' => 'service to which mail is to be forwarded', - 'dst' => 'someone@another.domain.com to use when dstsvc is 0', - }, - -# 'svc_charge' => { -# 'amount' => 'amount', -# }, -# 'svc_wo' => { -# 'worker' => 'Worker', -# '_date' => 'Date', -# }, - - 'svc_www' => { - #'recnum' => '', - #'usersvc' => '', - }, - - 'svc_broadband' => { - 'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.', - 'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.', - 'ip_addr' => 'IP address. Leave blank for automatic assignment.', - 'blocknum' => 'Address block.', - }, - - 'svc_phone' => { - 'countrycode' => { desc => 'Country code', - type => 'text', - disable_inventory => 1, - }, - 'phonenum' => 'Phone number', - 'pin' => { desc => 'Personal Identification Number', - type => 'text', - disable_inventory => 1, - }, - }, - - 'svc_external' => { - #'id' => '', - #'title' => '', - }, - -); - - my %vfields; - foreach my $svcdb (grep dbdef->table($_), keys %defs ) { - my $self = "FS::$svcdb"->new; - $vfields{$svcdb} = {}; - foreach my $field ($self->virtual_fields) { # svc_Common::virtual_fields with a null svcpart returns all of them - my $pvf = $self->pvf($field); - my @list = $pvf->list; - if (scalar @list) { - $defs{$svcdb}->{$field} = { desc => $pvf->label, - type => 'select', - select_list => \@list }; - } else { - $defs{$svcdb}->{$field} = $pvf->label; - } #endif - $vfields{$svcdb}->{$field} = $pvf; - warn "\$vfields{$svcdb}->{$field} = $pvf"; - } #next $field - } #next $svcdb - - #code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm - # and generalize the subs - # condition sub is tested to see whether to disable display of this choice - # params: ( $def, $layer, $field ) (see SUB below) - my $inv_sub = sub { - ref($_[0]) && ( $_[0]->{disable_inventory} - || $_[0]->{'type'} ne 'text' ) - }; - tie my %flag, 'Tie::IxHash', - '' => { 'desc' => 'No default', }, - 'D' => { 'desc' => 'Default', - 'condition' => - sub { ref($_[0]) && $_[0]->{disable_default} }, - }, - 'F' => { 'desc' => 'Fixed (unchangeable)', - 'condition' => - sub { ref($_[0]) && $_[0]->{disable_fixed} }, - }, -# need to template-ize httemplate/edit/svc_* first -# 'M' => { 'desc' => 'Manual selection from inventory', -# 'condition' => $inv_sub, -# }, - 'A' => { 'desc' => 'Automatically fill in from inventory', - 'condition' => $inv_sub, - }, - 'X' => { 'desc' => 'Excluded', - 'condition' => - sub { ! $vfields{$_[1]}->{$_[2]} }, - - }, - ; - - my @dbs = $hashref->{svcdb} - ? ( $hashref->{svcdb} ) - : qw( svc_acct svc_domain svc_forward svc_www svc_broadband svc_phone svc_external ); - - tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } grep dbdef->table($_), @dbs; - my $widget = new HTML::Widgets::SelectLayers( - #'selected_layer' => $p_svcdb, - 'selected_layer' => $hashref->{svcdb} || 'svc_acct', - 'options' => \%svcdb, - 'form_name' => 'dummy', - #'form_action' => 'process/part_svc.cgi', - 'form_action' => 'part_svc.cgi', #self - 'form_text' => [ qw( svc svcpart ) ], - 'form_checkbox' => [ 'disabled' ], - 'layer_callback' => sub { - my $layer = shift; - - my $html = qq!<INPUT TYPE="hidden" NAME="svcdb" VALUE="$layer">!; - - my $columns = 3; - my $count = 0; - my @part_export = - map { qsearch( 'part_export', {exporttype => $_ } ) } - keys %{FS::part_export::export_info($layer)}; - $html .= '<BR><BR>'. table(). - "<TR><TH COLSPAN=$columns>Exports</TH></TR><TR>"; - foreach my $part_export ( @part_export ) { - $html .= '<TD><INPUT TYPE="checkbox"'. - ' NAME="exportnum'. $part_export->exportnum. '" VALUE="1" '; - $html .= 'CHECKED' - if ( $clone || $part_svc->svcpart ) #null svcpart search causing error - && qsearchs( 'export_svc', { - exportnum => $part_export->exportnum, - svcpart => $clone || $part_svc->svcpart }); - $html .= '>'. $part_export->exportnum. ': '. $part_export->exporttype. - ' to '. $part_export->machine. '</TD>'; - $count++; - $html .= '</TR><TR>' unless $count % $columns; - } - $html .= '</TR></TABLE><BR><BR>'; - - $html .= include('/elements/table-grid.html', 'cellpadding' => 4 ). - '<TR>'. - '<TH CLASS="grid" BGCOLOR="#cccccc">Field</TH>'. - '<TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2>Modifier</TH>'. - '</TR>'; - - my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor; - - #yucky kludge - my @fields = defined( dbdef->table($layer) ) - ? grep { $_ ne 'svcnum' } fields($layer) - : (); - push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge - $part_svc->svcpart($clone) if $clone; #haha, undone below - - - foreach my $field (@fields) { - - my $part_svc_column = $part_svc->part_svc_column($field); - my $value = $part_svc_column->columnvalue; - my $flag = $part_svc_column->columnflag; - my $def = $defs{$layer}{$field}; - my $desc = ref($def) ? $def->{desc} : $def; - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - - $html .= qq!<TR><TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">!. - $field; - $html .= "- <FONT SIZE=-1>$desc</FONT>" if $desc; - $html .= "</TD>"; - $flag = '' if ref($def) && $def->{type} eq 'disabled'; - - $html .= qq!<TD CLASS="grid" BGCOLOR="$bgcolor">!; - - if ( ref($def) && $def->{type} eq 'disabled' ) { - - $html .= 'No default'; - - } else { - - $html .= qq!<SELECT NAME="${layer}__${field}_flag"!. - qq! onChange="${layer}__${field}_flag_changed(this)">!; - - foreach my $f ( keys %flag ) { - - #here is where the SUB from above is called, to skip some choices - next if $flag{$f}->{condition} - && &{ $flag{$f}->{condition} }( $def, $layer, $field ); - - $html .= qq!<OPTION VALUE="$f"!. - ' SELECTED'x($flag eq $f ). - '>'. $flag{$f}->{desc}; - - } - - $html .= '</SELECT>'; - - $html .= join("\n", - '<SCRIPT>', - " function ${layer}__${field}_flag_changed(what) {", - ' var f = what.options[what.selectedIndex].value;', - ' if ( f == "" || f == "X" ) { //disable', - " what.form.${layer}__${field}.disabled = true;". - " what.form.${layer}__${field}.style.backgroundColor = '#dddddd';". - " if ( what.form.${layer}__${field}_classnum ) {". - " what.form.${layer}__${field}_classnum.disabled = true;". - " what.form.${layer}__${field}_classnum.style.backgroundColor = '#dddddd';". - " }". - ' } else if ( f == "D" || f == "F" ) { //enable, text box', - " what.form.${layer}__${field}.disabled = false;". - " what.form.${layer}__${field}.style.backgroundColor = '#ffffff';". - " what.form.${layer}__${field}.style.display = '';". - " if ( what.form.${layer}__${field}_classnum ) {". - " what.form.${layer}__${field}_classnum.disabled = false;". - " what.form.${layer}__${field}_classnum.style.backgroundColor = '#ffffff';". - " what.form.${layer}__${field}_classnum.style.display = 'none';". - " }". - ' } else if ( f == "M" || f == "A" ) { //enable, inventory', - " what.form.${layer}__${field}.disabled = false;". - " what.form.${layer}__${field}.style.backgroundColor = '#ffffff';". - " what.form.${layer}__${field}.style.display = 'none';". - " if ( what.form.${layer}__${field}_classnum ) {". - " what.form.${layer}__${field}_classnum.disabled = false;". - " what.form.${layer}__${field}_classnum.style.backgroundColor = '#ffffff';". - " what.form.${layer}__${field}_classnum.style.display = '';". - " }". - ' }', - ' }', - '</SCRIPT>', - ); - - } - - $html .= qq!</TD><TD CLASS="grid" BGCOLOR="$bgcolor">!; - - my $disabled = $flag ? '' - : 'DISABLED STYLE="background-color: #dddddd"'; - - if ( ! ref($def) || $def->{type} eq 'text' ) { - - my $nodisplay = ' STYLE="display:none"'; - my $is_inv = ( $flag =~ /^[MA]$/ ); - - $html .= - qq!<INPUT TYPE="text" NAME="${layer}__${field}" VALUE="$value" !. - $disabled. - ( $is_inv ? $nodisplay : $disabled ). - '>'; - - $html .= include('/elements/select-table.html', - 'element_name' => "${layer}__${field}_classnum", - 'element_etc' => ( $is_inv - ? $disabled - : $nodisplay - ), - 'table' => 'inventory_class', - 'name_col' => 'classname', - 'value' => $value, - 'empty_label' => 'Select inventory class', - ); - - } elsif ( $def->{type} eq 'select' ) { - - $html .= qq!<SELECT NAME="${layer}__${field}" $disabled>!; - $html .= '<OPTION> </OPTION>' unless $value; - if ( $def->{select_table} ) { - foreach my $record ( qsearch( $def->{select_table}, {} ) ) { - my $rvalue = $record->getfield($def->{select_key}); - $html .= qq!<OPTION VALUE="$rvalue"!. - ( $rvalue==$value ? ' SELECTED>' : '>' ). - $record->getfield($def->{select_label}). '</OPTION>'; - } #next $record - } else { # select_list - foreach my $item ( @{$def->{select_list}} ) { - $html .= qq!<OPTION VALUE="$item"!. - ( $item eq $value ? ' SELECTED>' : '>' ). - $item. '</OPTION>'; - } #next $item - } #endif - $html .= '</SELECT>'; - - } elsif ( $def->{type} eq 'radius_usergroup_selector' ) { - - #XXX disable the RADIUS usergroup selector? ugh it sure does need - #an overhaul, people have dum group problems because of it - - $html .= FS::svc_acct::radius_usergroup_selector( - [ split(',', $value) ], "${layer}__${field}" ); - - } elsif ( $def->{type} eq 'disabled' ) { - - $html .= - qq!<INPUT TYPE="hidden" NAME="${layer}__${field}" VALUE="">!; - - } else { - - $html .= '<font color="#ff0000">unknown type'. $def->{type}; - - } - - $html .= "</TD></TR>\n"; - - } #foreach my $field (@fields) { - - $part_svc->svcpart('') if $clone; #undone - $html .= "</TABLE>"; - - $html .= include('/elements/progress-init.html', - $layer, #form name - [ qw(svc svcpart disabled exportnum), @fields ], - 'process/part_svc.cgi', - $p.'browse/part_svc.cgi', - $layer, - ); - $html .= '<BR><INPUT NAME="submit" TYPE="button" VALUE="'. - ($hashref->{svcpart} ? 'Apply changes' : 'Add service'). '" '. - ' onClick="document.'. "$layer.submit.disabled=true; ". - "fixup(document.$layer); $layer". 'process();">'; - - #$html .= '<BR><INPUT TYPE="submit" VALUE="'. - # ($hashref->{svcpart} ? 'Apply changes' : 'Add service'). '">'; - - $html; - - }, - ); - -%> -Table <%= $widget->html %> +% +% +%#these might belong somewhere else for other user interfaces +%#pry need to eventually create stuff that's shared amount UIs +%my $conf = new FS::Conf; +%my %defs = ( +% +% 'svc_acct' => { +% 'dir' => 'Home directory', +% 'uid' => 'UID (set to fixed and blank for no UIDs)', +% 'slipip' => 'IP address', +%# 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!, +% 'popnum' => { +% desc => 'Access number', +% type => 'select', +% select_table => 'svc_acct_pop', +% select_key => 'popnum', +% select_label => 'city', +% }, +% 'username' => { +% desc => 'Username', +% type => 'text', +% disable_default => 1, +% disable_fixed => 1, +% }, +% 'quota' => { +% desc => '', +% type => 'text', +% disable_inventory => 1, +% }, +% '_password' => 'Password', +% 'gid' => 'GID (when blank, defaults to UID)', +% 'shell' => { +% #desc =>'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file, set to blank for no shell tracking)', +% desc =>'Shell ( set to blank for no shell tracking)', +% type =>'select', +% select_list => [ $conf->config('shells') ], +% disable_inventory => 1, +% }, +% 'finger' => 'Real name (GECOS)', +% 'domsvc' => { +% desc =>'svcnum from svc_domain', +% type =>'select', +% select_table => 'svc_domain', +% select_key => 'svcnum', +% select_label => 'domain', +% disable_inventory => 1, +% }, +% 'usergroup' => { +% desc =>'RADIUS groups', +% type =>'radius_usergroup_selector', +% disable_inventory => 1, +% }, +% 'seconds' => { desc => '', +% type => 'text', +% disable_inventory => 1, +% }, +% }, +% +% 'svc_domain' => { +% 'domain' => 'Domain', +% }, +% +% 'svc_forward' => { +% 'srcsvc' => 'service from which mail is to be forwarded', +% 'dstsvc' => 'service to which mail is to be forwarded', +% 'dst' => 'someone@another.domain.com to use when dstsvc is 0', +% }, +% +%# 'svc_charge' => { +%# 'amount' => 'amount', +%# }, +%# 'svc_wo' => { +%# 'worker' => 'Worker', +%# '_date' => 'Date', +%# }, +% +% 'svc_www' => { +% #'recnum' => '', +% #'usersvc' => '', +% }, +% +% 'svc_broadband' => { +% 'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.', +% 'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.', +% 'ip_addr' => 'IP address. Leave blank for automatic assignment.', +% 'blocknum' => 'Address block.', +% }, +% +% 'svc_phone' => { +% 'countrycode' => { desc => 'Country code', +% type => 'text', +% disable_inventory => 1, +% }, +% 'phonenum' => 'Phone number', +% 'pin' => { desc => 'Personal Identification Number', +% type => 'text', +% disable_inventory => 1, +% }, +% }, +% +% 'svc_external' => { +% #'id' => '', +% #'title' => '', +% }, +% +%); +% +% my %vfields; +% foreach my $svcdb (grep dbdef->table($_), keys %defs ) { +% my $self = "FS::$svcdb"->new; +% $vfields{$svcdb} = {}; +% foreach my $field ($self->virtual_fields) { # svc_Common::virtual_fields with a null svcpart returns all of them +% my $pvf = $self->pvf($field); +% my @list = $pvf->list; +% if (scalar @list) { +% $defs{$svcdb}->{$field} = { desc => $pvf->label, +% type => 'select', +% select_list => \@list }; +% } else { +% $defs{$svcdb}->{$field} = $pvf->label; +% } #endif +% $vfields{$svcdb}->{$field} = $pvf; +% warn "\$vfields{$svcdb}->{$field} = $pvf"; +% } #next $field +% } #next $svcdb +% +% #code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm +% # and generalize the subs +% # condition sub is tested to see whether to disable display of this choice +% # params: ( $def, $layer, $field ) (see SUB below) +% my $inv_sub = sub { +% ref($_[0]) && ( $_[0]->{disable_inventory} +% || $_[0]->{'type'} ne 'text' ) +% }; +% tie my %flag, 'Tie::IxHash', +% '' => { 'desc' => 'No default', }, +% 'D' => { 'desc' => 'Default', +% 'condition' => +% sub { ref($_[0]) && $_[0]->{disable_default} }, +% }, +% 'F' => { 'desc' => 'Fixed (unchangeable)', +% 'condition' => +% sub { ref($_[0]) && $_[0]->{disable_fixed} }, +% }, +%# need to template-ize httemplate/edit/svc_* first +%# 'M' => { 'desc' => 'Manual selection from inventory', +%# 'condition' => $inv_sub, +%# }, +% 'A' => { 'desc' => 'Automatically fill in from inventory', +% 'condition' => $inv_sub, +% }, +% 'X' => { 'desc' => 'Excluded', +% 'condition' => +% sub { ! $vfields{$_[1]}->{$_[2]} }, +% +% }, +% ; +% +% my @dbs = $hashref->{svcdb} +% ? ( $hashref->{svcdb} ) +% : qw( svc_acct svc_domain svc_forward svc_www svc_broadband svc_phone svc_external ); +% +% tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } grep dbdef->table($_), @dbs; +% my $widget = new HTML::Widgets::SelectLayers( +% #'selected_layer' => $p_svcdb, +% 'selected_layer' => $hashref->{svcdb} || 'svc_acct', +% 'options' => \%svcdb, +% 'form_name' => 'dummy', +% #'form_action' => 'process/part_svc.cgi', +% 'form_action' => 'part_svc.cgi', #self +% 'form_text' => [ qw( svc svcpart ) ], +% 'form_checkbox' => [ 'disabled' ], +% 'layer_callback' => sub { +% my $layer = shift; +% +% my $html = qq!<INPUT TYPE="hidden" NAME="svcdb" VALUE="$layer">!; +% +% my $columns = 3; +% my $count = 0; +% my @part_export = +% map { qsearch( 'part_export', {exporttype => $_ } ) } +% keys %{FS::part_export::export_info($layer)}; +% $html .= '<BR><BR>'. table(). +% "<TR><TH COLSPAN=$columns>Exports</TH></TR><TR>"; +% foreach my $part_export ( @part_export ) { +% $html .= '<TD><INPUT TYPE="checkbox"'. +% ' NAME="exportnum'. $part_export->exportnum. '" VALUE="1" '; +% $html .= 'CHECKED' +% if ( $clone || $part_svc->svcpart ) #null svcpart search causing error +% && qsearchs( 'export_svc', { +% exportnum => $part_export->exportnum, +% svcpart => $clone || $part_svc->svcpart }); +% $html .= '>'. $part_export->exportnum. ': '. $part_export->exporttype. +% ' to '. $part_export->machine. '</TD>'; +% $count++; +% $html .= '</TR><TR>' unless $count % $columns; +% } +% $html .= '</TR></TABLE><BR><BR>'; +% +% $html .= include('/elements/table-grid.html', 'cellpadding' => 4 ). +% '<TR>'. +% '<TH CLASS="grid" BGCOLOR="#cccccc">Field</TH>'. +% '<TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2>Modifier</TH>'. +% '</TR>'; +% +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor; +% +% #yucky kludge +% my @fields = defined( dbdef->table($layer) ) +% ? grep { $_ ne 'svcnum' } fields($layer) +% : (); +% push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge +% $part_svc->svcpart($clone) if $clone; #haha, undone below +% +% +% foreach my $field (@fields) { +% +% my $part_svc_column = $part_svc->part_svc_column($field); +% my $value = $part_svc_column->columnvalue; +% my $flag = $part_svc_column->columnflag; +% my $def = $defs{$layer}{$field}; +% my $desc = ref($def) ? $def->{desc} : $def; +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% $html .= qq!<TR><TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">!. +% $field; +% $html .= "- <FONT SIZE=-1>$desc</FONT>" if $desc; +% $html .= "</TD>"; +% $flag = '' if ref($def) && $def->{type} eq 'disabled'; +% +% $html .= qq!<TD CLASS="grid" BGCOLOR="$bgcolor">!; +% +% if ( ref($def) && $def->{type} eq 'disabled' ) { +% +% $html .= 'No default'; +% +% } else { +% +% $html .= qq!<SELECT NAME="${layer}__${field}_flag"!. +% qq! onChange="${layer}__${field}_flag_changed(this)">!; +% +% foreach my $f ( keys %flag ) { +% +% #here is where the SUB from above is called, to skip some choices +% next if $flag{$f}->{condition} +% && &{ $flag{$f}->{condition} }( $def, $layer, $field ); +% +% $html .= qq!<OPTION VALUE="$f"!. +% ' SELECTED'x($flag eq $f ). +% '>'. $flag{$f}->{desc}; +% +% } +% +% $html .= '</SELECT>'; +% +% $html .= join("\n", +% '<SCRIPT>', +% " function ${layer}__${field}_flag_changed(what) {", +% ' var f = what.options[what.selectedIndex].value;', +% ' if ( f == "" || f == "X" ) { //disable', +% " what.form.${layer}__${field}.disabled = true;". +% " what.form.${layer}__${field}.style.backgroundColor = '#dddddd';". +% " if ( what.form.${layer}__${field}_classnum ) {". +% " what.form.${layer}__${field}_classnum.disabled = true;". +% " what.form.${layer}__${field}_classnum.style.backgroundColor = '#dddddd';". +% " }". +% ' } else if ( f == "D" || f == "F" ) { //enable, text box', +% " what.form.${layer}__${field}.disabled = false;". +% " what.form.${layer}__${field}.style.backgroundColor = '#ffffff';". +% " what.form.${layer}__${field}.style.display = '';". +% " if ( what.form.${layer}__${field}_classnum ) {". +% " what.form.${layer}__${field}_classnum.disabled = false;". +% " what.form.${layer}__${field}_classnum.style.backgroundColor = '#ffffff';". +% " what.form.${layer}__${field}_classnum.style.display = 'none';". +% " }". +% ' } else if ( f == "M" || f == "A" ) { //enable, inventory', +% " what.form.${layer}__${field}.disabled = false;". +% " what.form.${layer}__${field}.style.backgroundColor = '#ffffff';". +% " what.form.${layer}__${field}.style.display = 'none';". +% " if ( what.form.${layer}__${field}_classnum ) {". +% " what.form.${layer}__${field}_classnum.disabled = false;". +% " what.form.${layer}__${field}_classnum.style.backgroundColor = '#ffffff';". +% " what.form.${layer}__${field}_classnum.style.display = '';". +% " }". +% ' }', +% ' }', +% '</SCRIPT>', +% ); +% +% } +% +% $html .= qq!</TD><TD CLASS="grid" BGCOLOR="$bgcolor">!; +% +% my $disabled = $flag ? '' +% : 'DISABLED STYLE="background-color: #dddddd"'; +% +% if ( ! ref($def) || $def->{type} eq 'text' ) { +% +% my $nodisplay = ' STYLE="display:none"'; +% my $is_inv = ( $flag =~ /^[MA]$/ ); +% +% $html .= +% qq!<INPUT TYPE="text" NAME="${layer}__${field}" VALUE="$value" !. +% $disabled. +% ( $is_inv ? $nodisplay : $disabled ). +% '>'; +% +% $html .= include('/elements/select-table.html', +% 'element_name' => "${layer}__${field}_classnum", +% 'element_etc' => ( $is_inv +% ? $disabled +% : $nodisplay +% ), +% 'table' => 'inventory_class', +% 'name_col' => 'classname', +% 'value' => $value, +% 'empty_label' => 'Select inventory class', +% ); +% +% } elsif ( $def->{type} eq 'select' ) { +% +% $html .= qq!<SELECT NAME="${layer}__${field}" $disabled>!; +% $html .= '<OPTION> </OPTION>' unless $value; +% if ( $def->{select_table} ) { +% foreach my $record ( qsearch( $def->{select_table}, {} ) ) { +% my $rvalue = $record->getfield($def->{select_key}); +% $html .= qq!<OPTION VALUE="$rvalue"!. +% ( $rvalue==$value ? ' SELECTED>' : '>' ). +% $record->getfield($def->{select_label}). '</OPTION>'; +% } #next $record +% } else { # select_list +% foreach my $item ( @{$def->{select_list}} ) { +% $html .= qq!<OPTION VALUE="$item"!. +% ( $item eq $value ? ' SELECTED>' : '>' ). +% $item. '</OPTION>'; +% } #next $item +% } #endif +% $html .= '</SELECT>'; +% +% } elsif ( $def->{type} eq 'radius_usergroup_selector' ) { +% +% #XXX disable the RADIUS usergroup selector? ugh it sure does need +% #an overhaul, people have dum group problems because of it +% +% $html .= FS::svc_acct::radius_usergroup_selector( +% [ split(',', $value) ], "${layer}__${field}" ); +% +% } elsif ( $def->{type} eq 'disabled' ) { +% +% $html .= +% qq!<INPUT TYPE="hidden" NAME="${layer}__${field}" VALUE="">!; +% +% } else { +% +% $html .= '<font color="#ff0000">unknown type'. $def->{type}; +% +% } +% +% $html .= "</TD></TR>\n"; +% +% } #foreach my $field (@fields) { +% +% $part_svc->svcpart('') if $clone; #undone +% $html .= "</TABLE>"; +% +% $html .= include('/elements/progress-init.html', +% $layer, #form name +% [ qw(svc svcpart disabled exportnum), @fields ], +% 'process/part_svc.cgi', +% $p.'browse/part_svc.cgi', +% $layer, +% ); +% $html .= '<BR><INPUT NAME="submit" TYPE="button" VALUE="'. +% ($hashref->{svcpart} ? 'Apply changes' : 'Add service'). '" '. +% ' onClick="document.'. "$layer.submit.disabled=true; ". +% "fixup(document.$layer); $layer". 'process();">'; +% +% #$html .= '<BR><INPUT TYPE="submit" VALUE="'. +% # ($hashref->{svcpart} ? 'Apply changes' : 'Add service'). '">'; +% +% $html; +% +% }, +% ); +% +% + +Table <% $widget->html %> </BODY> </HTML> diff --git a/httemplate/edit/part_virtual_field.cgi b/httemplate/edit/part_virtual_field.cgi index 7b2c768a7..c6564f5be 100644 --- a/httemplate/edit/part_virtual_field.cgi +++ b/httemplate/edit/part_virtual_field.cgi @@ -1,83 +1,94 @@ -<% -my ($vfieldpart, $part_virtual_field); +% +%my ($vfieldpart, $part_virtual_field); +% +%if ( $cgi->param('error') ) { +% $part_virtual_field = new FS::part_virtual_field ( { +% map { $_, scalar($cgi->param($_)) } fields('part_virtual_field')}); +% $vfieldpart = $part_virtual_field->vfieldpart; +%} else { +% my($query) = $cgi->keywords; +% if ( $query =~ /^(\d+)$/ ) { #editing +% $vfieldpart=$1; +% $part_virtual_field=qsearchs('part_virtual_field', +% {'vfieldpart' => $vfieldpart}) +% or die "Unknown vfieldpart!"; +% +% } else { #adding +% $part_virtual_field = new FS::part_virtual_field({}); +% } +%} +%my $action = $part_virtual_field->vfieldpart ? 'Edit' : 'Add'; +% +%my $p1 = popurl(1); +% +% +<% include('/elements/header.html', "$action Virtual Field Definition") %> +% if ( $cgi->param('error') ) { -if ( $cgi->param('error') ) { - $part_virtual_field = new FS::part_virtual_field ( { - map { $_, scalar($cgi->param($_)) } fields('part_virtual_field')}); - $vfieldpart = $part_virtual_field->vfieldpart; -} else { - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $vfieldpart=$1; - $part_virtual_field=qsearchs('part_virtual_field', - {'vfieldpart' => $vfieldpart}) - or die "Unknown vfieldpart!"; - - } else { #adding - $part_virtual_field = new FS::part_virtual_field({}); - } -} -my $action = $part_virtual_field->vfieldpart ? 'Edit' : 'Add'; - -my $p1 = popurl(1); - -%><%= include('/elements/header.html', "$action Virtual Field Definition") %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> +% } + -<FORM ACTION="<%=$p1%>process/generic.cgi" METHOD="POST"> +<FORM ACTION="<%$p1%>process/generic.cgi" METHOD="POST"> <INPUT TYPE="hidden" NAME="table" VALUE="part_virtual_field"> <INPUT TYPE="hidden" NAME="redirect_ok" - VALUE="<%=popurl(2)%>browse/part_virtual_field.cgi"> -<INPUT TYPE="hidden" NAME="vfieldpart" VALUE="<%= + VALUE="<%popurl(2)%>browse/part_virtual_field.cgi"> +<INPUT TYPE="hidden" NAME="vfieldpart" VALUE="<% $vfieldpart%>"> -Field #<B><%=$vfieldpart or "(NEW)"%></B><BR><BR> +Field #<B><%$vfieldpart or "(NEW)"%></B><BR><BR> -<%=ntable("#cccccc",2)%> +<%ntable("#cccccc",2)%> <TR> <TD ALIGN="right">Name</TD> - <TD><INPUT TYPE="text" NAME="name" MAXLENGTH=15 VALUE="<%= + <TD><INPUT TYPE="text" NAME="name" MAXLENGTH=15 VALUE="<% $part_virtual_field->name%>"></TD> </TR> <TR> <TD ALIGN="right">Table</TD> - <TD><% if ($action eq 'Add') { %> - <SELECT SIZE=1 NAME="dbtable"><% - my $dbdef = dbdef; # ick - foreach my $dbtable (sort { $a cmp $b } $dbdef->tables) { - if ($dbtable !~ /^h_/ - and $dbdef->table($dbtable)->primary_key) { %> - <OPTION VALUE="<%=$dbtable%>"><%=$dbtable%></OPTION><% - } - } - %></SELECT><% - } else { # Edit - %><%=$part_virtual_field->dbtable%> - <INPUT TYPE="hidden" NAME="dbtable" VALUE="<%=$part_virtual_field->dbtable%>"> - <% } %> + <TD> +% if ($action eq 'Add') { + + <SELECT SIZE=1 NAME="dbtable"> +% +% my $dbdef = dbdef; # ick +% foreach my $dbtable (sort { $a cmp $b } $dbdef->tables) { +% if ($dbtable !~ /^h_/ +% and $dbdef->table($dbtable)->primary_key) { + + <OPTION VALUE="<%$dbtable%>"><%$dbtable%></OPTION> +% +% } +% } +% +</SELECT> +% +% } else { # Edit +% +<%$part_virtual_field->dbtable%> + <INPUT TYPE="hidden" NAME="dbtable" VALUE="<%$part_virtual_field->dbtable%>"> +% } + </TD> <TR> <TD ALIGN="right">Label</TD> - <TD><INPUT TYPE="text" NAME="label" MAXLENGTH="20" VALUE="<%= + <TD><INPUT TYPE="text" NAME="label" MAXLENGTH="20" VALUE="<% $part_virtual_field->label%>"></TD> </TR> <TR> <TD ALIGN="right">Length</TD> - <TD><INPUT TYPE="text" NAME="length" MAXLENGTH=4 VALUE="<%= + <TD><INPUT TYPE="text" NAME="length" MAXLENGTH=4 VALUE="<% $part_virtual_field->length%>"></TD> </TR> <TR> <TD ALIGN="right">Check</TD> - <TD><TEXTAREA COLS="20" ROWS="4" NAME="check_block"><%= + <TD><TEXTAREA COLS="20" ROWS="4" NAME="check_block"><% $part_virtual_field->check_block%></TEXTAREA></TD> </TR> <TR> <TD ALIGN="right">List source</TD> - <TD><TEXTAREA COLS="20" ROWS="4" NAME="list_source"><%= + <TD><TEXTAREA COLS="20" ROWS="4" NAME="list_source"><% $part_virtual_field->list_source%></TEXTAREA></TD> </TR> </TABLE><BR><INPUT TYPE="submit" VALUE="Submit"> @@ -88,4 +99,4 @@ Field #<B><%=$vfieldpart or "(NEW)"%></B><BR><BR> <FONT SIZE=-2>If you don't understand what <I>check_block</I> and <I>list_source</I> mean, <B>LEAVE THEM BLANK</B>. We mean it.</FONT> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/edit/payment_gateway.html b/httemplate/edit/payment_gateway.html index 1eda11249..b79e4a976 100644 --- a/httemplate/edit/payment_gateway.html +++ b/httemplate/edit/payment_gateway.html @@ -1,113 +1,119 @@ -<% - -my $payment_gateway; -if ( $cgi->param('error') ) { - $payment_gateway = new FS::payment_gateway ( { - map { $_, scalar($cgi->param($_)) } fields('payment_gateway') - } ); -} elsif ( $cgi->keywords ) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $payment_gateway = qsearchs( 'payment_gateway', { 'gatewaynum' => $1 } ); -} else { #adding - $payment_gateway = new FS::payment_gateway {}; -} -my $action = $payment_gateway->gatewaynum ? 'Edit' : 'Add'; -#my $hashref = $payment_gateway->hashref; - -%> - -<%= include("/elements/header.html","$action Payment gateway", menubar( +% +% +%my $payment_gateway; +%if ( $cgi->param('error') ) { +% $payment_gateway = new FS::payment_gateway ( { +% map { $_, scalar($cgi->param($_)) } fields('payment_gateway') +% } ); +%} elsif ( $cgi->keywords ) { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $payment_gateway = qsearchs( 'payment_gateway', { 'gatewaynum' => $1 } ); +%} else { #adding +% $payment_gateway = new FS::payment_gateway {}; +%} +%my $action = $payment_gateway->gatewaynum ? 'Edit' : 'Add'; +%#my $hashref = $payment_gateway->hashref; +% +% + + +<% include("/elements/header.html","$action Payment gateway", menubar( 'Main Menu' => $p, 'View all payment gateways' => $p. 'browse/payment_gateway.html', )) %> +% if ( $cgi->param('error') ) { -<% if ( $cgi->param('error') ) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> +<FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> +% } -<FORM ACTION="<%=popurl(1)%>process/payment_gateway.html" METHOD=POST> -<INPUT TYPE="hidden" NAME="gatewaynum" VALUE="<%= $payment_gateway->gatewaynum %>"> -Gateway #<%= $payment_gateway->gatewaynum || "(NEW)" %> -<%= ntable('#cccccc', 2, '') %> +<FORM ACTION="<%popurl(1)%>process/payment_gateway.html" METHOD=POST> +<INPUT TYPE="hidden" NAME="gatewaynum" VALUE="<% $payment_gateway->gatewaynum %>"> +Gateway #<% $payment_gateway->gatewaynum || "(NEW)" %> + +<% ntable('#cccccc', 2, '') %> <TR> <TH ALIGN="right">Gateway: </TH> <TD> +% if ( $payment_gateway->gatewaynum ) { - <% if ( $payment_gateway->gatewaynum ) { %> - <%= $payment_gateway->gateway_module %> - <INPUT TYPE="hidden" NAME="gateway_module" VALUE="<%= $payment_gateway->gateway_module %>"> + <% $payment_gateway->gateway_module %> + <INPUT TYPE="hidden" NAME="gateway_module" VALUE="<% $payment_gateway->gateway_module %>"> +% } else { - <% } else { %> <SELECT NAME="gateway_module" SIZE=1> - <% foreach my $module ( qw( - 2CheckOut - AuthorizeNet - BankOfAmerica - Beanstream - Capstone - Cardstream - CashCow - CyberSource - eSec - eSelectPlus - Exact - iAuthorizer - IPaymentTPG - Jettis - LinkPoint - MerchantCommerce - Network1Financial - OCV - OpenECHO - PayConnect - PayflowPro - PaymentsGateway - PXPost - SecureHostingUPG - Skipjack - StGeorge - SurePay - TCLink - TransactionCentral - VirtualNet - ) ) { - %> - <OPTION VALUE="<%= $module %>"><%= $module %> - <% } %> +% foreach my $module ( qw( +% 2CheckOut +% AuthorizeNet +% BankOfAmerica +% Beanstream +% Capstone +% Cardstream +% CashCow +% CyberSource +% eSec +% eSelectPlus +% Exact +% iAuthorizer +% IPaymentTPG +% Jettis +% LinkPoint +% MerchantCommerce +% Network1Financial +% OCV +% OpenECHO +% PayConnect +% PayflowPro +% PaymentsGateway +% PXPost +% SecureHostingUPG +% Skipjack +% StGeorge +% SurePay +% TCLink +% TransactionCentral +% VirtualNet +% ) ) { +% + + <OPTION VALUE="<% $module %>"><% $module %> +% } + </SELECT> +% } - <% } %> </TD> </TR> <TR> <TH ALIGN="right">Username: </TH> - <TD><INPUT TYPE="text" NAME="gateway_username" VALUE="<%= $payment_gateway->gateway_username %>"></TD> + <TD><INPUT TYPE="text" NAME="gateway_username" VALUE="<% $payment_gateway->gateway_username %>"></TD> </TR> <TR> <TH ALIGN="right">Password: </TH> - <TD><INPUT TYPE="text" NAME="gateway_password" VALUE="<%= $payment_gateway->gateway_password %>"></TD> + <TD><INPUT TYPE="text" NAME="gateway_password" VALUE="<% $payment_gateway->gateway_password %>"></TD> </TR> <TR> <TH ALIGN="right">Action: </TH> <TD> <SELECT NAME="gateway_action" SIZE=1> - <% foreach my $action ( - 'Normal Authorization', - 'Authorization Only', - 'Authorization Only, Post Authorization', - ) { - %> - <OPTION VALUE="<%= $action %>"<%= $action eq $payment_gateway->gateway_action ? ' SELECTED' : '' %>><%= $action %> - <% } %> +% foreach my $action ( +% 'Normal Authorization', +% 'Authorization Only', +% 'Authorization Only, Post Authorization', +% ) { +% + + <OPTION VALUE="<% $action %>"<% $action eq $payment_gateway->gateway_action ? ' SELECTED' : '' %>><% $action %> +% } + </SELECT> </TD> </TR> @@ -115,13 +121,13 @@ Gateway #<%= $payment_gateway->gatewaynum || "(NEW)" %> <TR> <TH ALIGN="right">Options: </TH> <TD> - <TEXTAREA ROWS="5" NAME="gateway_options"><%= join("\r", $payment_gateway->options ) %></TEXTAREA> + <TEXTAREA ROWS="5" NAME="gateway_options"><% join("\r", $payment_gateway->options ) %></TEXTAREA> </TD> </TR> </TABLE> -<BR><INPUT TYPE="submit" VALUE="<%= $payment_gateway->gatewaynum ? "Apply changes" : "Add gateway" %>"> +<BR><INPUT TYPE="submit" VALUE="<% $payment_gateway->gatewaynum ? "Apply changes" : "Add gateway" %>"> </FORM> </BODY> </HTML> diff --git a/httemplate/edit/pkg_class.html b/httemplate/edit/pkg_class.html index b077f6fa9..181072f71 100644 --- a/httemplate/edit/pkg_class.html +++ b/httemplate/edit/pkg_class.html @@ -1,4 +1,4 @@ -<%= include( 'elements/edit.html', +<% include( 'elements/edit.html', 'name' => 'Package Class', 'table' => 'pkg_class', 'labels' => { diff --git a/httemplate/edit/prepay_credit.cgi b/httemplate/edit/prepay_credit.cgi index 253edb94b..f563e253b 100644 --- a/httemplate/edit/prepay_credit.cgi +++ b/httemplate/edit/prepay_credit.cgi @@ -1,53 +1,61 @@ -<% -my $agent = ''; -my $agentnum = ''; -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $agent = qsearchs('agent', { 'agentnum' => $agentnum=$1 } ); -} +% +%my $agent = ''; +%my $agentnum = ''; +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $agent = qsearchs('agent', { 'agentnum' => $agentnum=$1 } ); +%} +% +%tie my %multiplier, 'Tie::IxHash', +% 1 => 'seconds', +% 60 => 'minutes', +% 3600 => 'hours', +%; +% +%$cgi->param('multiplier', '60') unless $cgi->param('multiplier'); +% +% -tie my %multiplier, 'Tie::IxHash', - 1 => 'seconds', - 60 => 'minutes', - 3600 => 'hours', -; -$cgi->param('multiplier', '60') unless $cgi->param('multiplier'); - -%> - -<%= include("/elements/header.html",'Generate prepaid cards'. ($agent ? ' for '. $agent->agent : ''), +<% include("/elements/header.html",'Generate prepaid cards'. ($agent ? ' for '. $agent->agent : ''), menubar( 'Main Menu' => $p, )) %> +% if ( $cgi->param('error') ) { -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#FF0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> + <FONT SIZE="+1" COLOR="#FF0000">Error: <% $cgi->param('error') %></FONT> +% } -<FORM ACTION="<%=popurl(1)%>process/prepay_credit.cgi" METHOD="POST" NAME="OneTrueForm" onSubmit="document.OneTrueForm.submit.disabled=true"> + +<FORM ACTION="<%popurl(1)%>process/prepay_credit.cgi" METHOD="POST" NAME="OneTrueForm" onSubmit="document.OneTrueForm.submit.disabled=true"> Generate -<INPUT TYPE="text" NAME="num" VALUE="<%= $cgi->param('num') || '(quantity)' %>" SIZE=10 MAXLENGTH=10 onFocus="if ( this.value == '(quantity)' ) { this.value = ''; }"> +<INPUT TYPE="text" NAME="num" VALUE="<% $cgi->param('num') || '(quantity)' %>" SIZE=10 MAXLENGTH=10 onFocus="if ( this.value == '(quantity)' ) { this.value = ''; }"> <SELECT NAME="type"> -<% foreach (qw(alpha alphanumeric numeric)) { %> - <OPTION<%= $cgi->param('type') eq $_ ? ' SELECTED' : '' %>><%= $_ %> -<% } %> +% foreach (qw(alpha alphanumeric numeric)) { + + <OPTION<% $cgi->param('type') eq $_ ? ' SELECTED' : '' %>><% $_ %> +% } + </SELECT> prepaid cards <BR>for <SELECT NAME="agentnum"><OPTION>(any agent) -<% foreach my $opt_agent ( qsearch('agent', { 'disabled' => '' } ) ) { %> - <OPTION VALUE="<%= $opt_agent->agentnum %>"<%= $opt_agent->agentnum == $agentnum ? ' SELECTED' : '' %>><%= $opt_agent->agent %> -<% } %> +% foreach my $opt_agent ( qsearch('agent', { 'disabled' => '' } ) ) { + + <OPTION VALUE="<% $opt_agent->agentnum %>"<% $opt_agent->agentnum == $agentnum ? ' SELECTED' : '' %>><% $opt_agent->agent %> +% } + </SELECT> <BR>Value: -$<INPUT TYPE="text" NAME="amount" SIZE=8 MAXLENGTH=7 VALUE="<%= $cgi->param('amount') %>"> +$<INPUT TYPE="text" NAME="amount" SIZE=8 MAXLENGTH=7 VALUE="<% $cgi->param('amount') %>"> and/or -<INPUT TYPE="text" NAME="seconds" SIZE=6 MAXLENGTH=5 VALUE="<%= $cgi->param('seconds') %>"> +<INPUT TYPE="text" NAME="seconds" SIZE=6 MAXLENGTH=5 VALUE="<% $cgi->param('seconds') %>"> <SELECT NAME="multiplier"> -<% foreach my $multiplier ( keys %multiplier ) { %> - <OPTION VALUE="<%= $multiplier %>"<%= $cgi->param('multiplier') eq $multiplier ? ' SELECTED' : '' %>><%= $multiplier{$multiplier} %> -<% } %> +% foreach my $multiplier ( keys %multiplier ) { + + <OPTION VALUE="<% $multiplier %>"<% $cgi->param('multiplier') eq $multiplier ? ' SELECTED' : '' %>><% $multiplier{$multiplier} %> +% } + </SELECT> <BR><BR> <INPUT TYPE="submit" NAME="submit" VALUE="Generate" onSubmit="this.disabled = true"> diff --git a/httemplate/edit/process/REAL_cust_pkg.cgi b/httemplate/edit/process/REAL_cust_pkg.cgi index 84d0cc129..26e234fb0 100755 --- a/httemplate/edit/process/REAL_cust_pkg.cgi +++ b/httemplate/edit/process/REAL_cust_pkg.cgi @@ -1,34 +1,35 @@ -<% +% +% +%my $pkgnum = $cgi->param('pkgnum') or die; +%my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +%my %hash = $old->hash; +%$hash{'setup'} = $cgi->param('setup') ? str2time($cgi->param('setup')) : ''; +%$hash{'bill'} = $cgi->param('bill') ? str2time($cgi->param('bill')) : ''; +%$hash{'last_bill'} = +% $cgi->param('last_bill') ? str2time($cgi->param('last_bill')) : ''; +%$hash{'expire'} = $cgi->param('expire') ? str2time($cgi->param('expire')) : ''; +% +%my $new; +%my $error; +%if ( $hash{'bill'} != $old->bill # if the next bill date was changed +% && $hash{'bill'} < time # to a date in the past +% && ! $cgi->param('bill_areyousure') # and it wasn't confirmed +% ) +%{ +% $error = '_bill_areyousure'; +%} else { +% $new = new FS::cust_pkg \%hash; +% $error = $new->replace($old); +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string ); +%} else { +% my $custnum = $new->custnum; +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". +% "#cust_pkg$pkgnum" ); +%} +% +% -my $pkgnum = $cgi->param('pkgnum') or die; -my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); -my %hash = $old->hash; -$hash{'setup'} = $cgi->param('setup') ? str2time($cgi->param('setup')) : ''; -$hash{'bill'} = $cgi->param('bill') ? str2time($cgi->param('bill')) : ''; -$hash{'last_bill'} = - $cgi->param('last_bill') ? str2time($cgi->param('last_bill')) : ''; -$hash{'expire'} = $cgi->param('expire') ? str2time($cgi->param('expire')) : ''; - -my $new; -my $error; -if ( $hash{'bill'} != $old->bill # if the next bill date was changed - && $hash{'bill'} < time # to a date in the past - && ! $cgi->param('bill_areyousure') # and it wasn't confirmed - ) -{ - $error = '_bill_areyousure'; -} else { - $new = new FS::cust_pkg \%hash; - $error = $new->replace($old); -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string ); -} else { - my $custnum = $new->custnum; - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". - "#cust_pkg$pkgnum" ); -} - -%> diff --git a/httemplate/edit/process/access_group.html b/httemplate/edit/process/access_group.html index 9bb9d1dda..c80311586 100644 --- a/httemplate/edit/process/access_group.html +++ b/httemplate/edit/process/access_group.html @@ -1,4 +1,4 @@ -<%= include( 'elements/process.html', +<% include( 'elements/process.html', 'table' => 'access_group', 'viewall_dir' => 'browse', 'process_m2m' => { 'link_table' => 'access_groupagent', diff --git a/httemplate/edit/process/access_user.html b/httemplate/edit/process/access_user.html index a6c2a36b1..78857c525 100644 --- a/httemplate/edit/process/access_user.html +++ b/httemplate/edit/process/access_user.html @@ -1,4 +1,4 @@ -<%= include( 'elements/process.html', +<% include( 'elements/process.html', 'table' => 'access_user', 'viewall_dir' => 'browse', 'process_m2m' => { 'link_table' => 'access_usergroup', diff --git a/httemplate/edit/process/addr_block/add.cgi b/httemplate/edit/process/addr_block/add.cgi index 34d799ccd..85780c678 100755 --- a/httemplate/edit/process/addr_block/add.cgi +++ b/httemplate/edit/process/addr_block/add.cgi @@ -1,20 +1,21 @@ -<% +% +% +%my $error = ''; +%my $ip_gateway = $cgi->param('ip_gateway'); +%my $ip_netmask = $cgi->param('ip_netmask'); +% +%my $new = new FS::addr_block { +% ip_gateway => $ip_gateway, +% ip_netmask => $ip_netmask, +% routernum => 0 }; +% +%$error = $new->insert; +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(4). "browse/addr_block.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(4). "browse/addr_block.cgi"); +%} +% -my $error = ''; -my $ip_gateway = $cgi->param('ip_gateway'); -my $ip_netmask = $cgi->param('ip_netmask'); - -my $new = new FS::addr_block { - ip_gateway => $ip_gateway, - ip_netmask => $ip_netmask, - routernum => 0 }; - -$error = $new->insert; - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(4). "browse/addr_block.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(4). "browse/addr_block.cgi"); -} -%> diff --git a/httemplate/edit/process/addr_block/allocate.cgi b/httemplate/edit/process/addr_block/allocate.cgi index 85b0d7a7a..a94c0320f 100755 --- a/httemplate/edit/process/addr_block/allocate.cgi +++ b/httemplate/edit/process/addr_block/allocate.cgi @@ -1,25 +1,26 @@ -<% -my $error = ''; -my $blocknum = $cgi->param('blocknum'); -my $routernum = $cgi->param('routernum'); +% +%my $error = ''; +%my $blocknum = $cgi->param('blocknum'); +%my $routernum = $cgi->param('routernum'); +% +%my $addr_block = qsearchs('addr_block', { blocknum => $blocknum }); +%my $router = qsearchs('router', { routernum => $routernum }); +% +%if($addr_block) { +% if ($router) { +% $error = $addr_block->allocate($router); +% } else { +% $error = "Cannot find router with routernum $routernum"; +% } +%} else { +% $error = "Cannot find block with blocknum $blocknum"; +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(4). "browse/addr_block.cgi?" . $cgi->query_string); +%} else { +% print $cgi->redirect(popurl(4). "browse/addr_block.cgi"); +%} +% -my $addr_block = qsearchs('addr_block', { blocknum => $blocknum }); -my $router = qsearchs('router', { routernum => $routernum }); - -if($addr_block) { - if ($router) { - $error = $addr_block->allocate($router); - } else { - $error = "Cannot find router with routernum $routernum"; - } -} else { - $error = "Cannot find block with blocknum $blocknum"; -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(4). "browse/addr_block.cgi?" . $cgi->query_string); -} else { - print $cgi->redirect(popurl(4). "browse/addr_block.cgi"); -} -%> diff --git a/httemplate/edit/process/addr_block/deallocate.cgi b/httemplate/edit/process/addr_block/deallocate.cgi index cfb7ed04d..494c19f75 100755 --- a/httemplate/edit/process/addr_block/deallocate.cgi +++ b/httemplate/edit/process/addr_block/deallocate.cgi @@ -1,24 +1,25 @@ -<% -my $error = ''; -my $blocknum = $cgi->param('blocknum'); +% +%my $error = ''; +%my $blocknum = $cgi->param('blocknum'); +% +%my $addr_block = qsearchs('addr_block', { blocknum => $blocknum }); +% +%if($addr_block) { +% my $router = $addr_block->router; +% if ($router) { +% $error = $addr_block->deallocate($router); +% } else { +% $error = "Block is not allocated to a router"; +% } +%} else { +% $error = "Cannot find block with blocknum $blocknum"; +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(4). "browse/addr_block.cgi?" . $cgi->query_string); +%} else { +% print $cgi->redirect(popurl(4). "browse/addr_block.cgi"); +%} +% -my $addr_block = qsearchs('addr_block', { blocknum => $blocknum }); - -if($addr_block) { - my $router = $addr_block->router; - if ($router) { - $error = $addr_block->deallocate($router); - } else { - $error = "Block is not allocated to a router"; - } -} else { - $error = "Cannot find block with blocknum $blocknum"; -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(4). "browse/addr_block.cgi?" . $cgi->query_string); -} else { - print $cgi->redirect(popurl(4). "browse/addr_block.cgi"); -} -%> diff --git a/httemplate/edit/process/addr_block/split.cgi b/httemplate/edit/process/addr_block/split.cgi index bb6d4ba3e..617c3f8ce 100755 --- a/httemplate/edit/process/addr_block/split.cgi +++ b/httemplate/edit/process/addr_block/split.cgi @@ -1,19 +1,20 @@ -<% -my $error = ''; -my $blocknum = $cgi->param('blocknum'); -my $addr_block = qsearchs('addr_block', { blocknum => $blocknum }); +% +%my $error = ''; +%my $blocknum = $cgi->param('blocknum'); +%my $addr_block = qsearchs('addr_block', { blocknum => $blocknum }); +% +%if ( $addr_block) { +% $error = $addr_block->split_block; +%} else { +% $error = "Unknown blocknum: $blocknum"; +%} +% +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(4). "browse/addr_block.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(4). "browse/addr_block.cgi"); +%} +% -if ( $addr_block) { - $error = $addr_block->split_block; -} else { - $error = "Unknown blocknum: $blocknum"; -} - - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(4). "browse/addr_block.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(4). "browse/addr_block.cgi"); -} -%> diff --git a/httemplate/edit/process/agent.cgi b/httemplate/edit/process/agent.cgi index 182eeab41..5128d7ae8 100755 --- a/httemplate/edit/process/agent.cgi +++ b/httemplate/edit/process/agent.cgi @@ -1,28 +1,29 @@ -<% +% +% +%my $agentnum = $cgi->param('agentnum'); +% +%my $old = qsearchs('agent',{'agentnum'=>$agentnum}) if $agentnum; +% +%my $new = new FS::agent ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('agent') +%} ); +% +%my $error; +%if ( $agentnum ) { +% $error=$new->replace($old); +%} else { +% $error=$new->insert; +% $agentnum=$new->getfield('agentnum'); +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "agent.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "browse/agent.cgi"); +%} +% +% -my $agentnum = $cgi->param('agentnum'); - -my $old = qsearchs('agent',{'agentnum'=>$agentnum}) if $agentnum; - -my $new = new FS::agent ( { - map { - $_, scalar($cgi->param($_)); - } fields('agent') -} ); - -my $error; -if ( $agentnum ) { - $error=$new->replace($old); -} else { - $error=$new->insert; - $agentnum=$new->getfield('agentnum'); -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "agent.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "browse/agent.cgi"); -} - -%> diff --git a/httemplate/edit/process/agent_payment_gateway.html b/httemplate/edit/process/agent_payment_gateway.html index c306bfa3f..436317ec4 100644 --- a/httemplate/edit/process/agent_payment_gateway.html +++ b/httemplate/edit/process/agent_payment_gateway.html @@ -1,25 +1,26 @@ -<% - -$cgi->param('agentnum') =~ /(\d+)$/ or die "illegal agentnum"; -my $agent = qsearchs('agent', { 'agentnum' => $1 } ); -die "agentnum $1 not found" unless $agent; - -#my $old - -my @new = map { - my $cardtype = $_; - new FS::agent_payment_gateway { - ( map { $_ => scalar($cgi->param($_)) } - fields('agent_payment_gateway') - ), - 'cardtype' => $cardtype, - }; - } - $cgi->param('cardtype'); - -foreach my $new (@new) { - my $error = $new->insert; - die $error if $error; -} - -%><%= $cgi->redirect(popurl(3). "browse/agent.cgi") %> +% +% +%$cgi->param('agentnum') =~ /(\d+)$/ or die "illegal agentnum"; +%my $agent = qsearchs('agent', { 'agentnum' => $1 } ); +%die "agentnum $1 not found" unless $agent; +% +%#my $old +% +%my @new = map { +% my $cardtype = $_; +% new FS::agent_payment_gateway { +% ( map { $_ => scalar($cgi->param($_)) } +% fields('agent_payment_gateway') +% ), +% 'cardtype' => $cardtype, +% }; +% } +% $cgi->param('cardtype'); +% +%foreach my $new (@new) { +% my $error = $new->insert; +% die $error if $error; +%} +% +% +<% $cgi->redirect(popurl(3). "browse/agent.cgi") %> diff --git a/httemplate/edit/process/agent_type.cgi b/httemplate/edit/process/agent_type.cgi index fd8ca8833..b8d03705c 100755 --- a/httemplate/edit/process/agent_type.cgi +++ b/httemplate/edit/process/agent_type.cgi @@ -1,36 +1,37 @@ -<% +% +% +%my $typenum = $cgi->param('typenum'); +%my $old = qsearchs('agent_type',{'typenum'=>$typenum}) if $typenum; +% +%my $new = new FS::agent_type ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('agent_type') +%} ); +% +%my $error; +%if ( $typenum ) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $typenum = $new->getfield('typenum'); +%} +%#$error ||= $new->process_m2m( ); +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "agent_type.cgi?". $cgi->query_string ); +%} else { +% +% my $error = $new->process_m2m( +% 'link_table' => 'type_pkgs', +% 'target_table' => 'part_pkg', +% 'params' => scalar($cgi->Vars) +% ); +% die $error if $error; +% +% print $cgi->redirect(popurl(3). "browse/agent_type.cgi"); +%} +% +% -my $typenum = $cgi->param('typenum'); -my $old = qsearchs('agent_type',{'typenum'=>$typenum}) if $typenum; - -my $new = new FS::agent_type ( { - map { - $_, scalar($cgi->param($_)); - } fields('agent_type') -} ); - -my $error; -if ( $typenum ) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $typenum = $new->getfield('typenum'); -} -#$error ||= $new->process_m2m( ); - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "agent_type.cgi?". $cgi->query_string ); -} else { - - my $error = $new->process_m2m( - 'link_table' => 'type_pkgs', - 'target_table' => 'part_pkg', - 'params' => scalar($cgi->Vars) - ); - die $error if $error; - - print $cgi->redirect(popurl(3). "browse/agent_type.cgi"); -} - -%> diff --git a/httemplate/edit/process/bulk-cust_svc.cgi b/httemplate/edit/process/bulk-cust_svc.cgi index dd9d1dbd2..ad4d67307 100644 --- a/httemplate/edit/process/bulk-cust_svc.cgi +++ b/httemplate/edit/process/bulk-cust_svc.cgi @@ -1,3 +1,4 @@ -<% - my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process_bulk_cust_svc', $cgi; -%><%= $server->process %> +% +% my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process_bulk_cust_svc', $cgi; +% +<% $server->process %> diff --git a/httemplate/edit/process/cust_bill_pay.cgi b/httemplate/edit/process/cust_bill_pay.cgi index fc668bb07..962fc4eb9 100755 --- a/httemplate/edit/process/cust_bill_pay.cgi +++ b/httemplate/edit/process/cust_bill_pay.cgi @@ -1,51 +1,54 @@ -<% - -$cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!"; -my $paynum = $1; - -my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ) - or die "No such paynum"; - -my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_pay->custnum } ) - or die "Bogus credit: not attached to customer"; - -my $custnum = $cust_main->custnum; - -my $new; -if ($cgi->param('invnum') =~ /^Refund$/) { - $new = new FS::cust_refund ( { - 'reason' => 'Refunding payment', #enter reason in UI - 'refund' => $cgi->param('amount'), - 'payby' => 'BILL', - #'_date' => $cgi->param('_date'), - 'payinfo' => 'Cash', #enter payinfo in UI - 'paynum' => $paynum, - } ); -} else { - $new = new FS::cust_bill_pay ( { - map { - $_, scalar($cgi->param($_)); - #} qw(custnum _date amount invnum) - } fields('cust_bill_pay') - } ); -} - -my $error = $new->insert; - -if ( $error ) { - - $cgi->param('error', $error); - %><%= $cgi->redirect(popurl(2). "cust_bill_pay.cgi?". $cgi->query_string ) %><% - -} else { - - #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); - - %><%= header('Payment application sucessful') %> +% +% +%$cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!"; +%my $paynum = $1; +% +%my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ) +% or die "No such paynum"; +% +%my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_pay->custnum } ) +% or die "Bogus credit: not attached to customer"; +% +%my $custnum = $cust_main->custnum; +% +%my $new; +%if ($cgi->param('invnum') =~ /^Refund$/) { +% $new = new FS::cust_refund ( { +% 'reason' => 'Refunding payment', #enter reason in UI +% 'refund' => $cgi->param('amount'), +% 'payby' => 'BILL', +% #'_date' => $cgi->param('_date'), +% 'payinfo' => 'Cash', #enter payinfo in UI +% 'paynum' => $paynum, +% } ); +%} else { +% $new = new FS::cust_bill_pay ( { +% map { +% $_, scalar($cgi->param($_)); +% #} qw(custnum _date amount invnum) +% } fields('cust_bill_pay') +% } ); +%} +% +%my $error = $new->insert; +% +%if ( $error ) { +% +% $cgi->param('error', $error); +% +<% $cgi->redirect(popurl(2). "cust_bill_pay.cgi?". $cgi->query_string ) %> +% +% +%} else { +% +% #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); +% +% +<% header('Payment application sucessful') %> <SCRIPT TYPE="text/javascript"> window.top.location.reload(); </SCRIPT> </BODY></HTML> +% } -<% } %> diff --git a/httemplate/edit/process/cust_credit.cgi b/httemplate/edit/process/cust_credit.cgi index 6a4ef194a..19faca47a 100755 --- a/httemplate/edit/process/cust_credit.cgi +++ b/httemplate/edit/process/cust_credit.cgi @@ -1,35 +1,38 @@ -<% - -$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!"; -my $custnum = $1; - -my $new = new FS::cust_credit ( { - map { - $_, scalar($cgi->param($_)); - } fields('cust_credit') -} ); - -my $error = $new->insert; - -if ( $error ) { - $cgi->param('error', $error); - - %><%= $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string ) %><% - -} else { - - if ( $cgi->param('apply') eq 'yes' ) { - my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum }) - or die "unknown custnum $custnum"; - $cust_main->apply_credits; - } - #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); - - %><%= header('Credit sucessful') %> +% +% +%$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!"; +%my $custnum = $1; +% +%my $new = new FS::cust_credit ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('cust_credit') +%} ); +% +%my $error = $new->insert; +% +%if ( $error ) { +% $cgi->param('error', $error); +% +% +<% $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string ) %> +% +% +%} else { +% +% if ( $cgi->param('apply') eq 'yes' ) { +% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum }) +% or die "unknown custnum $custnum"; +% $cust_main->apply_credits; +% } +% #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); +% +% +<% header('Credit sucessful') %> <SCRIPT TYPE="text/javascript"> window.top.location.reload(); </SCRIPT> </BODY></HTML> +% } -<% } %> diff --git a/httemplate/edit/process/cust_credit_bill.cgi b/httemplate/edit/process/cust_credit_bill.cgi index 3b759536f..7509a3f02 100755 --- a/httemplate/edit/process/cust_credit_bill.cgi +++ b/httemplate/edit/process/cust_credit_bill.cgi @@ -1,52 +1,55 @@ -<% - -$cgi->param('crednum') =~ /^(\d*)$/ or die "Illegal crednum!"; -my $crednum = $1; - -my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } ) - or die "No such crednum"; - -my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_credit->custnum } ) - or die "Bogus credit: not attached to customer"; - -my $custnum = $cust_main->custnum; - -my $new; -if ($cgi->param('invnum') =~ /^Refund$/) { - $new = new FS::cust_refund ( { - 'reason' => ( $cust_credit->reason || 'refund from credit' ), - 'refund' => $cgi->param('amount'), - 'payby' => 'BILL', - #'_date' => $cgi->param('_date'), - #'payinfo' => 'Cash', - 'payinfo' => 'Refund', - 'crednum' => $crednum, - } ); -} else { - $new = new FS::cust_credit_bill ( { - map { - $_, scalar($cgi->param($_)); - #} qw(custnum _date amount invnum) - } fields('cust_credit_bill') - } ); -} - -my $error = $new->insert; - -if ( $error ) { - - $cgi->param('error', $error); - %><%= $cgi->redirect(popurl(2). "cust_credit_bill.cgi?". $cgi->query_string ) %><% - -} else { - - #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); - - %><%= header('Credit application sucessful') %> +% +% +%$cgi->param('crednum') =~ /^(\d*)$/ or die "Illegal crednum!"; +%my $crednum = $1; +% +%my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } ) +% or die "No such crednum"; +% +%my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_credit->custnum } ) +% or die "Bogus credit: not attached to customer"; +% +%my $custnum = $cust_main->custnum; +% +%my $new; +%if ($cgi->param('invnum') =~ /^Refund$/) { +% $new = new FS::cust_refund ( { +% 'reason' => ( $cust_credit->reason || 'refund from credit' ), +% 'refund' => $cgi->param('amount'), +% 'payby' => 'BILL', +% #'_date' => $cgi->param('_date'), +% #'payinfo' => 'Cash', +% 'payinfo' => 'Refund', +% 'crednum' => $crednum, +% } ); +%} else { +% $new = new FS::cust_credit_bill ( { +% map { +% $_, scalar($cgi->param($_)); +% #} qw(custnum _date amount invnum) +% } fields('cust_credit_bill') +% } ); +%} +% +%my $error = $new->insert; +% +%if ( $error ) { +% +% $cgi->param('error', $error); +% +<% $cgi->redirect(popurl(2). "cust_credit_bill.cgi?". $cgi->query_string ) %> +% +% +%} else { +% +% #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); +% +% +<% header('Credit application sucessful') %> <SCRIPT TYPE="text/javascript"> window.top.location.reload(); </SCRIPT> </BODY></HTML> +% } -<% } %> diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 4ba30c435..2d698c7b0 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -1,153 +1,154 @@ -<% +% +% +%my $error = ''; +% +%#unmunge stuff +% +%$cgi->param('tax','') unless defined $cgi->param('tax'); +% +%$cgi->param('refnum', (split(/:/, ($cgi->param('refnum'))[0] ))[0] ); +% +%#my $payby = $cgi->param('payby'); +%my $payby = $cgi->param('select'); # XXX key +% +%my %noauto = ( +% 'CARD' => 'DCRD', +% 'CHEK' => 'DCHK', +%); +%$payby = $noauto{$payby} +% if ! $cgi->param('payauto') && exists $noauto{$payby}; +% +%$cgi->param('payby', $payby); +% +%if ( $payby ) { +% if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) { +% $cgi->param('payinfo', +% $cgi->param('payinfo1'). '@'. $cgi->param('payinfo2') ); +% } +% $cgi->param('paydate', +% $cgi->param( 'exp_month' ). '-'. $cgi->param( 'exp_year' ) ); +%} +% +%my @invoicing_list = split( /\s*\,\s*/, $cgi->param('invoicing_list') ); +%push @invoicing_list, 'POST' if $cgi->param('invoicing_list_POST'); +%push @invoicing_list, 'FAX' if $cgi->param('invoicing_list_FAX'); +%$cgi->param('invoicing_list', join(',', @invoicing_list) ); +% +% +%#create new record object +% +%my $new = new FS::cust_main ( { +% map { +% $_, scalar($cgi->param($_)) +%# } qw(custnum agentnum last first ss company address1 address2 city county +%# state zip daytime night fax payby payinfo paydate payname tax +%# otaker refnum) +% } fields('cust_main') +%} ); +% +%if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { +% $new->setfield("ship_$_", '') foreach qw( +% last first company address1 address2 city county state zip +% country daytime night fax +% ); +%} +% +%$new->setfield('paid', $cgi->param('paid') ) +% if $cgi->param('paid'); +% +%#perhaps this stuff should go to cust_main.pm +%my $cust_pkg = ''; +%my $svc_acct = ''; +%if ( $new->custnum eq '' ) { +% +% if ( $cgi->param('pkgpart_svcpart') ) { +% my $x = $cgi->param('pkgpart_svcpart'); +% $x =~ /^(\d+)_(\d+)$/ or die "illegal pkgpart_svcpart $x\n"; +% my($pkgpart, $svcpart) = ($1, $2); +% #false laziness: copied from FS::cust_pkg::order (which should become a +% #FS::cust_main method) +% my(%part_pkg); +% # generate %part_pkg +% # $part_pkg{$pkgpart} is true iff $custnum may purchase $pkgpart +% my $agent = qsearchs('agent',{'agentnum'=> $new->agentnum }); +% #my($type_pkgs); +% #foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { +% # my($pkgpart)=$type_pkgs->pkgpart; +% # $part_pkg{$pkgpart}++; +% #} +% # $pkgpart_href->{PKGPART} is true iff $custnum may purchase $pkgpart +% my $pkgpart_href = $agent->pkgpart_hashref; +% #eslaf +% +% # this should wind up in FS::cust_pkg! +% $error ||= "Agent ". $new->agentnum. " (type ". $agent->typenum. ") can't ". +% "purchase pkgpart ". $pkgpart +% #unless $part_pkg{ $pkgpart }; +% unless $pkgpart_href->{ $pkgpart }; +% +% $cust_pkg = new FS::cust_pkg ( { +% #later 'custnum' => $custnum, +% 'pkgpart' => $pkgpart, +% } ); +% #$error ||= $cust_pkg->check; +% +% #$cust_svc = new FS::cust_svc ( { 'svcpart' => $svcpart } ); +% +% #$error ||= $cust_svc->check; +% +% $svc_acct = new FS::svc_acct ( { +% 'svcpart' => $svcpart, +% 'username' => $cgi->param('username'), +% '_password' => $cgi->param('_password'), +% 'popnum' => $cgi->param('popnum'), +% } ); +% +% #and just in case you were silly +% $svc_acct->svcpart($svcpart); +% $svc_acct->username($cgi->param('username')); +% $svc_acct->_password($cgi->param('_password')); +% $svc_acct->popnum($cgi->param('popnum')); +% +% #$error ||= $svc_acct->check; +% +% } elsif ( $cgi->param('username') ) { #good thing to catch +% $error = "Can't assign username without a package!"; +% } +% +% use Tie::RefHash; +% tie my %hash, 'Tie::RefHash'; +% %hash = ( $cust_pkg => [ $svc_acct ] ) if $cust_pkg; +% $error ||= $new->insert( \%hash, \@invoicing_list ); +% +% my $conf = new FS::Conf; +% if ( $conf->exists('backend-realtime') && ! $error ) { +% +% my $berror = $new->bill; +% $new->apply_payments; +% $new->apply_credits; +% $berror ||= $new->collect; +% warn "Warning, error billing during backend-realtime: $berror" if $berror; +% +% } +% +%} else { #create old record object +% +% my $old = qsearchs( 'cust_main', { 'custnum' => $new->custnum } ); +% $error ||= "Old record not found!" unless $old; +% if ( defined dbdef->table('cust_main')->column('paycvv') +% && length($old->paycvv) +% && $new->paycvv =~ /^\s*\*+\s*$/ ) { +% $new->paycvv($old->paycvv); +% } +% $error ||= $new->replace($old, \@invoicing_list); +% +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "cust_main.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?". $new->custnum); +%} +% -my $error = ''; - -#unmunge stuff - -$cgi->param('tax','') unless defined $cgi->param('tax'); - -$cgi->param('refnum', (split(/:/, ($cgi->param('refnum'))[0] ))[0] ); - -#my $payby = $cgi->param('payby'); -my $payby = $cgi->param('select'); # XXX key - -my %noauto = ( - 'CARD' => 'DCRD', - 'CHEK' => 'DCHK', -); -$payby = $noauto{$payby} - if ! $cgi->param('payauto') && exists $noauto{$payby}; - -$cgi->param('payby', $payby); - -if ( $payby ) { - if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) { - $cgi->param('payinfo', - $cgi->param('payinfo1'). '@'. $cgi->param('payinfo2') ); - } - $cgi->param('paydate', - $cgi->param( 'exp_month' ). '-'. $cgi->param( 'exp_year' ) ); -} - -my @invoicing_list = split( /\s*\,\s*/, $cgi->param('invoicing_list') ); -push @invoicing_list, 'POST' if $cgi->param('invoicing_list_POST'); -push @invoicing_list, 'FAX' if $cgi->param('invoicing_list_FAX'); -$cgi->param('invoicing_list', join(',', @invoicing_list) ); - - -#create new record object - -my $new = new FS::cust_main ( { - map { - $_, scalar($cgi->param($_)) -# } qw(custnum agentnum last first ss company address1 address2 city county -# state zip daytime night fax payby payinfo paydate payname tax -# otaker refnum) - } fields('cust_main') -} ); - -if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { - $new->setfield("ship_$_", '') foreach qw( - last first company address1 address2 city county state zip - country daytime night fax - ); -} - -$new->setfield('paid', $cgi->param('paid') ) - if $cgi->param('paid'); - -#perhaps this stuff should go to cust_main.pm -my $cust_pkg = ''; -my $svc_acct = ''; -if ( $new->custnum eq '' ) { - - if ( $cgi->param('pkgpart_svcpart') ) { - my $x = $cgi->param('pkgpart_svcpart'); - $x =~ /^(\d+)_(\d+)$/ or die "illegal pkgpart_svcpart $x\n"; - my($pkgpart, $svcpart) = ($1, $2); - #false laziness: copied from FS::cust_pkg::order (which should become a - #FS::cust_main method) - my(%part_pkg); - # generate %part_pkg - # $part_pkg{$pkgpart} is true iff $custnum may purchase $pkgpart - my $agent = qsearchs('agent',{'agentnum'=> $new->agentnum }); - #my($type_pkgs); - #foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { - # my($pkgpart)=$type_pkgs->pkgpart; - # $part_pkg{$pkgpart}++; - #} - # $pkgpart_href->{PKGPART} is true iff $custnum may purchase $pkgpart - my $pkgpart_href = $agent->pkgpart_hashref; - #eslaf - - # this should wind up in FS::cust_pkg! - $error ||= "Agent ". $new->agentnum. " (type ". $agent->typenum. ") can't ". - "purchase pkgpart ". $pkgpart - #unless $part_pkg{ $pkgpart }; - unless $pkgpart_href->{ $pkgpart }; - - $cust_pkg = new FS::cust_pkg ( { - #later 'custnum' => $custnum, - 'pkgpart' => $pkgpart, - } ); - #$error ||= $cust_pkg->check; - - #$cust_svc = new FS::cust_svc ( { 'svcpart' => $svcpart } ); - - #$error ||= $cust_svc->check; - - $svc_acct = new FS::svc_acct ( { - 'svcpart' => $svcpart, - 'username' => $cgi->param('username'), - '_password' => $cgi->param('_password'), - 'popnum' => $cgi->param('popnum'), - } ); - - #and just in case you were silly - $svc_acct->svcpart($svcpart); - $svc_acct->username($cgi->param('username')); - $svc_acct->_password($cgi->param('_password')); - $svc_acct->popnum($cgi->param('popnum')); - - #$error ||= $svc_acct->check; - - } elsif ( $cgi->param('username') ) { #good thing to catch - $error = "Can't assign username without a package!"; - } - - use Tie::RefHash; - tie my %hash, 'Tie::RefHash'; - %hash = ( $cust_pkg => [ $svc_acct ] ) if $cust_pkg; - $error ||= $new->insert( \%hash, \@invoicing_list ); - - my $conf = new FS::Conf; - if ( $conf->exists('backend-realtime') && ! $error ) { - - my $berror = $new->bill; - $new->apply_payments; - $new->apply_credits; - $berror ||= $new->collect; - warn "Warning, error billing during backend-realtime: $berror" if $berror; - - } - -} else { #create old record object - - my $old = qsearchs( 'cust_main', { 'custnum' => $new->custnum } ); - $error ||= "Old record not found!" unless $old; - if ( defined dbdef->table('cust_main')->column('paycvv') - && length($old->paycvv) - && $new->paycvv =~ /^\s*\*+\s*$/ ) { - $new->paycvv($old->paycvv); - } - $error ||= $new->replace($old, \@invoicing_list); - -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "cust_main.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?". $new->custnum); -} -%> diff --git a/httemplate/edit/process/cust_main_county-collapse.cgi b/httemplate/edit/process/cust_main_county-collapse.cgi index 5da9dea80..4bcaf1de3 100755 --- a/httemplate/edit/process/cust_main_county-collapse.cgi +++ b/httemplate/edit/process/cust_main_county-collapse.cgi @@ -1,35 +1,36 @@ -<% +% +% +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ or die "Illegal taxnum!"; +%my $taxnum = $1; +%my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } ) +% or die "Unknown taxnum $taxnum"; +% +%#really should do this in a .pm & start transaction +% +%foreach my $delete ( qsearch('cust_main_county', { +% 'country' => $cust_main_county->country, +% 'state' => $cust_main_county->state +% } ) ) { +%# unless ( qsearch('cust_main',{ +%# 'state' => $cust_main_county->getfield('state'), +%# 'county' => $cust_main_county->getfield('county'), +%# 'country' => $cust_main_county->getfield('country'), +%# } ) ) { +% my $error = $delete->delete; +% die $error if $error; +%# } else { +% #should really fix the $cust_main record +%# } +% +%} +% +%$cust_main_county->taxnum(''); +%$cust_main_county->county(''); +%my $error = $cust_main_county->insert; +%die $error if $error; +% +%print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi"); +% +% -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ or die "Illegal taxnum!"; -my $taxnum = $1; -my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } ) - or die "Unknown taxnum $taxnum"; - -#really should do this in a .pm & start transaction - -foreach my $delete ( qsearch('cust_main_county', { - 'country' => $cust_main_county->country, - 'state' => $cust_main_county->state - } ) ) { -# unless ( qsearch('cust_main',{ -# 'state' => $cust_main_county->getfield('state'), -# 'county' => $cust_main_county->getfield('county'), -# 'country' => $cust_main_county->getfield('country'), -# } ) ) { - my $error = $delete->delete; - die $error if $error; -# } else { - #should really fix the $cust_main record -# } - -} - -$cust_main_county->taxnum(''); -$cust_main_county->county(''); -my $error = $cust_main_county->insert; -die $error if $error; - -print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi"); - -%> diff --git a/httemplate/edit/process/cust_main_county-expand.cgi b/httemplate/edit/process/cust_main_county-expand.cgi index a452711c1..e550e8b4a 100755 --- a/httemplate/edit/process/cust_main_county-expand.cgi +++ b/httemplate/edit/process/cust_main_county-expand.cgi @@ -1,58 +1,59 @@ -<% +% +% +%$cgi->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!"; +%my $taxnum = $1; +%my $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum}) +% or die ("Unknown taxnum!"); +% +%my @expansion; +%if ( $cgi->param('delim') eq 'n' ) { +% @expansion=split(/\n/,$cgi->param('expansion')); +%} elsif ( $cgi->param('delim') eq 's' ) { +% @expansion=split(' ',$cgi->param('expansion')); +%} else { +% die "Illegal delim!"; +%} +% +%@expansion=map { +% unless ( /^\s*([\w\- ]+)\s*$/ ) { +% $cgi->param('error', "Illegal item in expansion"); +% print $cgi->redirect(popurl(2). "cust_main_county-expand.cgi?". $cgi->query_string ); +% myexit(); +% } +% $1; +%} @expansion; +% +%foreach ( @expansion) { +% my(%hash)=$cust_main_county->hash; +% my($new)=new FS::cust_main_county \%hash; +% $new->setfield('taxnum',''); +% if ( $cgi->param('taxclass') ) { +% $new->setfield('taxclass', $_); +% } elsif ( ! $cust_main_county->state ) { +% $new->setfield('state',$_); +% } else { +% $new->setfield('county',$_); +% } +% #if (datasrc =~ m/Pg/) +% #{ +% # $new->setfield('tax',0.0); +% #} +% my($error)=$new->insert; +% die $error if $error; +%} +% +%unless ( qsearch( 'cust_main', { +% 'state' => $cust_main_county->state, +% 'county' => $cust_main_county->county, +% 'country' => $cust_main_county->country, +% } ) +% || ! @expansion +%) { +% my($error)=($cust_main_county->delete); +% die $error if $error; +%} +% +%print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi"); +% +% -$cgi->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!"; -my $taxnum = $1; -my $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum}) - or die ("Unknown taxnum!"); - -my @expansion; -if ( $cgi->param('delim') eq 'n' ) { - @expansion=split(/\n/,$cgi->param('expansion')); -} elsif ( $cgi->param('delim') eq 's' ) { - @expansion=split(' ',$cgi->param('expansion')); -} else { - die "Illegal delim!"; -} - -@expansion=map { - unless ( /^\s*([\w\- ]+)\s*$/ ) { - $cgi->param('error', "Illegal item in expansion"); - print $cgi->redirect(popurl(2). "cust_main_county-expand.cgi?". $cgi->query_string ); - myexit(); - } - $1; -} @expansion; - -foreach ( @expansion) { - my(%hash)=$cust_main_county->hash; - my($new)=new FS::cust_main_county \%hash; - $new->setfield('taxnum',''); - if ( $cgi->param('taxclass') ) { - $new->setfield('taxclass', $_); - } elsif ( ! $cust_main_county->state ) { - $new->setfield('state',$_); - } else { - $new->setfield('county',$_); - } - #if (datasrc =~ m/Pg/) - #{ - # $new->setfield('tax',0.0); - #} - my($error)=$new->insert; - die $error if $error; -} - -unless ( qsearch( 'cust_main', { - 'state' => $cust_main_county->state, - 'county' => $cust_main_county->county, - 'country' => $cust_main_county->country, - } ) - || ! @expansion -) { - my($error)=($cust_main_county->delete); - die $error if $error; -} - -print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi"); - -%> diff --git a/httemplate/edit/process/cust_main_county.cgi b/httemplate/edit/process/cust_main_county.cgi index 9287ed150..2c3ebe866 100755 --- a/httemplate/edit/process/cust_main_county.cgi +++ b/httemplate/edit/process/cust_main_county.cgi @@ -1,30 +1,31 @@ -<% +% +% +%foreach ( grep { /^tax\d+$/ } $cgi->param ) { +% /^tax(\d+)$/ or die "Illegal form $_!"; +% my $taxnum = $1; +% my $old = qsearchs('cust_main_county', { 'taxnum' => $taxnum }) +% or die "Couldn't find taxnum $taxnum!"; +% next unless $old->tax != $cgi->param("tax$taxnum") +% || $old->exempt_amount != $cgi->param("exempt_amount$taxnum") +% || $old->taxname ne $cgi->param("taxname$taxnum") +% || $old->setuptax ne $cgi->param("setuptax$taxnum") +% || $old->recurtax ne $cgi->param("recurtax$taxnum"); +% my %hash = $old->hash; +% $hash{tax} = $cgi->param("tax$taxnum"); +% $hash{exempt_amount} = $cgi->param("exempt_amount$taxnum"); +% $hash{taxname} = $cgi->param("taxname$taxnum"); +% $hash{setuptax} = $cgi->param("setuptax$taxnum"); +% $hash{recurtax} = $cgi->param("recurtax$taxnum"); +% my $new = new FS::cust_main_county \%hash; +% my $error = $new->replace($old); +% if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "cust_main_county.cgi?". $cgi->query_string ); +% myexit(); +% } +%} +% +%print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi"); +% +% -foreach ( grep { /^tax\d+$/ } $cgi->param ) { - /^tax(\d+)$/ or die "Illegal form $_!"; - my $taxnum = $1; - my $old = qsearchs('cust_main_county', { 'taxnum' => $taxnum }) - or die "Couldn't find taxnum $taxnum!"; - next unless $old->tax != $cgi->param("tax$taxnum") - || $old->exempt_amount != $cgi->param("exempt_amount$taxnum") - || $old->taxname ne $cgi->param("taxname$taxnum") - || $old->setuptax ne $cgi->param("setuptax$taxnum") - || $old->recurtax ne $cgi->param("recurtax$taxnum"); - my %hash = $old->hash; - $hash{tax} = $cgi->param("tax$taxnum"); - $hash{exempt_amount} = $cgi->param("exempt_amount$taxnum"); - $hash{taxname} = $cgi->param("taxname$taxnum"); - $hash{setuptax} = $cgi->param("setuptax$taxnum"); - $hash{recurtax} = $cgi->param("recurtax$taxnum"); - my $new = new FS::cust_main_county \%hash; - my $error = $new->replace($old); - if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "cust_main_county.cgi?". $cgi->query_string ); - myexit(); - } -} - -print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi"); - -%> diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi index cecccb59e..68342ee04 100755 --- a/httemplate/edit/process/cust_pay.cgi +++ b/httemplate/edit/process/cust_pay.cgi @@ -1,54 +1,56 @@ -<% - -$cgi->param('linknum') =~ /^(\d+)$/ - or die "Illegal linknum: ". $cgi->param('linknum'); -my $linknum = $1; - -$cgi->param('link') =~ /^(custnum|invnum|popup)$/ - or die "Illegal link: ". $cgi->param('link'); -my $field = my $link = $1; -$field = 'custnum' if $field eq 'popup'; - -my $_date = str2time($cgi->param('_date')); - -my $new = new FS::cust_pay ( { - $field => $linknum, - _date => $_date, - map { - $_, scalar($cgi->param($_)); - } qw(paid payby payinfo paybatch) - #} fields('cust_pay') -} ); - -my $error = $new->insert; - -if ($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). 'cust_pay.cgi?'. $cgi->query_string ); -} elsif ( $field eq 'invnum' ) { - print $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum"); -} elsif ( $field eq 'custnum' ) { - if ( $cgi->param('apply') eq 'yes' ) { - my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum }) - or die "unknown custnum $linknum"; - $cust_main->apply_payments; - } - if ( $link eq 'popup' ) { - - %><%= header('Payment entered') %> +% +% +%$cgi->param('linknum') =~ /^(\d+)$/ +% or die "Illegal linknum: ". $cgi->param('linknum'); +%my $linknum = $1; +% +%$cgi->param('link') =~ /^(custnum|invnum|popup)$/ +% or die "Illegal link: ". $cgi->param('link'); +%my $field = my $link = $1; +%$field = 'custnum' if $field eq 'popup'; +% +%my $_date = str2time($cgi->param('_date')); +% +%my $new = new FS::cust_pay ( { +% $field => $linknum, +% _date => $_date, +% map { +% $_, scalar($cgi->param($_)); +% } qw(paid payby payinfo paybatch) +% #} fields('cust_pay') +%} ); +% +%my $error = $new->insert; +% +%if ($error) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). 'cust_pay.cgi?'. $cgi->query_string ); +%} elsif ( $field eq 'invnum' ) { +% print $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum"); +%} elsif ( $field eq 'custnum' ) { +% if ( $cgi->param('apply') eq 'yes' ) { +% my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum }) +% or die "unknown custnum $linknum"; +% $cust_main->apply_payments; +% } +% if ( $link eq 'popup' ) { +% +% +<% header('Payment entered') %> <SCRIPT TYPE="text/javascript"> window.top.location.reload(); </SCRIPT> </BODY></HTML> - <% - - } elsif ( $link eq 'custnum' ) { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum"); - } else { - die "unknown link $link"; - } - -} +% +% +% } elsif ( $link eq 'custnum' ) { +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum"); +% } else { +% die "unknown link $link"; +% } +% +%} +% +% -%> diff --git a/httemplate/edit/process/cust_pkg.cgi b/httemplate/edit/process/cust_pkg.cgi index df8471c27..817c88087 100755 --- a/httemplate/edit/process/cust_pkg.cgi +++ b/httemplate/edit/process/cust_pkg.cgi @@ -1,43 +1,44 @@ -<% +% +% +%my $error = ''; +% +%#untaint custnum +%$cgi->param('custnum') =~ /^(\d+)$/; +%my $custnum = $1; +% +%my @remove_pkgnums = map { +% /^(\d+)$/ or die "Illegal remove_pkg value!"; +% $1; +%} $cgi->param('remove_pkg'); +% +%my $error_redirect; +%my @pkgparts; +%if ( $cgi->param('new_pkgpart') =~ /^(\d+)$/ ) { #came from misc/change_pkg.cgi +% $error_redirect = "misc/change_pkg.cgi"; +% @pkgparts = ($1); +%} else { #came from edit/cust_pkg.cgi +% $error_redirect = "edit/cust_pkg.cgi"; +% foreach my $pkgpart ( map /^pkg(\d+)$/ ? $1 : (), $cgi->param ) { +% if ( $cgi->param("pkg$pkgpart") =~ /^(\d+)$/ ) { +% my $num_pkgs = $1; +% while ( $num_pkgs-- ) { +% push @pkgparts,$pkgpart; +% } +% } else { +% $error = "Illegal quantity"; +% last; +% } +% } +%} +% +%$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums); +% +%if ($error) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(3). $error_redirect. '?'. $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); +%} +% +% -my $error = ''; - -#untaint custnum -$cgi->param('custnum') =~ /^(\d+)$/; -my $custnum = $1; - -my @remove_pkgnums = map { - /^(\d+)$/ or die "Illegal remove_pkg value!"; - $1; -} $cgi->param('remove_pkg'); - -my $error_redirect; -my @pkgparts; -if ( $cgi->param('new_pkgpart') =~ /^(\d+)$/ ) { #came from misc/change_pkg.cgi - $error_redirect = "misc/change_pkg.cgi"; - @pkgparts = ($1); -} else { #came from edit/cust_pkg.cgi - $error_redirect = "edit/cust_pkg.cgi"; - foreach my $pkgpart ( map /^pkg(\d+)$/ ? $1 : (), $cgi->param ) { - if ( $cgi->param("pkg$pkgpart") =~ /^(\d+)$/ ) { - my $num_pkgs = $1; - while ( $num_pkgs-- ) { - push @pkgparts,$pkgpart; - } - } else { - $error = "Illegal quantity"; - last; - } - } -} - -$error ||= FS::cust_pkg::order($custnum,\@pkgparts,\@remove_pkgnums); - -if ($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(3). $error_redirect. '?'. $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); -} - -%> diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi index 7055d8ea6..fadfffb62 100755 --- a/httemplate/edit/process/cust_refund.cgi +++ b/httemplate/edit/process/cust_refund.cgi @@ -1,42 +1,43 @@ -<% +% +% +%$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!"; +%my $custnum = $1; +%my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) +% or die "unknown custnum $custnum"; +% +%my $error = ''; +%if ( $cgi->param('payby') =~ /^(CARD|CHEK)$/ ) { +% my %payby2bop = ( +% 'CARD' => 'CC', +% 'CHEK' => 'ECHECK', +% ); +% my $bop = $payby2bop{$1}; +% $cgi->param('refund') =~ /^(\d*)(\.\d{2})?$/ +% or die "illegal refund amount ". $cgi->param('refund'); +% my $refund = "$1$2"; +% $cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!"; +% my $paynum = $1; +% my $reason = $cgi->param('reason'); +% $error = $cust_main->realtime_refund_bop( $bop, 'amount' => $refund, +% 'paynum' => $paynum, +% 'reason' => $reason, ); +%} else { +% die 'unimplemented'; +% #my $new = new FS::cust_refund ( { +% # map { +% # $_, scalar($cgi->param($_)); +% # } ( fields('cust_refund'), 'paynum' ) +% #} ); +% #$error = $new->insert; +%} +% +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "cust_refund.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); +%} +% +% -$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!"; -my $custnum = $1; -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) - or die "unknown custnum $custnum"; - -my $error = ''; -if ( $cgi->param('payby') =~ /^(CARD|CHEK)$/ ) { - my %payby2bop = ( - 'CARD' => 'CC', - 'CHEK' => 'ECHECK', - ); - my $bop = $payby2bop{$1}; - $cgi->param('refund') =~ /^(\d*)(\.\d{2})?$/ - or die "illegal refund amount ". $cgi->param('refund'); - my $refund = "$1$2"; - $cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!"; - my $paynum = $1; - my $reason = $cgi->param('reason'); - $error = $cust_main->realtime_refund_bop( $bop, 'amount' => $refund, - 'paynum' => $paynum, - 'reason' => $reason, ); -} else { - die 'unimplemented'; - #my $new = new FS::cust_refund ( { - # map { - # $_, scalar($cgi->param($_)); - # } ( fields('cust_refund'), 'paynum' ) - #} ); - #$error = $new->insert; -} - - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "cust_refund.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); -} - -%> diff --git a/httemplate/edit/process/cust_svc.cgi b/httemplate/edit/process/cust_svc.cgi index 187ede5e5..3a07d1e7a 100644 --- a/httemplate/edit/process/cust_svc.cgi +++ b/httemplate/edit/process/cust_svc.cgi @@ -1,30 +1,30 @@ -<% - -my $svcnum = $cgi->param('svcnum'); - -my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}) if $svcnum; - -my $new = new FS::cust_svc ( { - map { - $_, scalar($cgi->param($_)); - } fields('cust_svc') -} ); - -my $error; -if ( $svcnum ) { - $error=$new->replace($old); -} else { - $error=$new->insert; - $svcnum=$new->getfield('svcnum'); -} - -if ( $error ) { - #$cgi->param('error', $error); - #print $cgi->redirect(popurl(2). "cust_svc.cgi?". $cgi->query_string ); - eidiot($error); -} else { - my $svcdb = $new->part_svc->svcdb; - print $cgi->redirect(popurl(3). "view/$svcdb.cgi?$svcnum"); -} - - +% +% +%my $svcnum = $cgi->param('svcnum'); +% +%my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}) if $svcnum; +% +%my $new = new FS::cust_svc ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('cust_svc') +%} ); +% +%my $error; +%if ( $svcnum ) { +% $error=$new->replace($old); +%} else { +% $error=$new->insert; +% $svcnum=$new->getfield('svcnum'); +%} +% +%if ( $error ) { +% #$cgi->param('error', $error); +% #print $cgi->redirect(popurl(2). "cust_svc.cgi?". $cgi->query_string ); +% eidiot($error); +%} else { +% my $svcdb = $new->part_svc->svcdb; +% print $cgi->redirect(popurl(3). "view/$svcdb.cgi?$svcnum"); +%} +% +% diff --git a/httemplate/edit/process/domain_record.cgi b/httemplate/edit/process/domain_record.cgi index b8c3f62a1..87bdf6835 100755 --- a/httemplate/edit/process/domain_record.cgi +++ b/httemplate/edit/process/domain_record.cgi @@ -1,34 +1,36 @@ -<% +% +% +%my $recnum = $cgi->param('recnum'); +% +%my $old = qsearchs('agent',{'recnum'=>$recnum}) if $recnum; +% +%my $new = new FS::domain_record ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('domain_record') +%} ); +% +%my $error; +%if ( $recnum ) { +% $error=$new->replace($old); +%} else { +% $error=$new->insert; +% $recnum=$new->getfield('recnum'); +%} +% +%if ( $error ) { +%# $cgi->param('error', $error); +%# print $cgi->redirect(popurl(2). "agent.cgi?". $cgi->query_string ); +% #no edit screen to send them back to +% -my $recnum = $cgi->param('recnum'); - -my $old = qsearchs('agent',{'recnum'=>$recnum}) if $recnum; - -my $new = new FS::domain_record ( { - map { - $_, scalar($cgi->param($_)); - } fields('domain_record') -} ); - -my $error; -if ( $recnum ) { - $error=$new->replace($old); -} else { - $error=$new->insert; - $recnum=$new->getfield('recnum'); -} - -if ( $error ) { -# $cgi->param('error', $error); -# print $cgi->redirect(popurl(2). "agent.cgi?". $cgi->query_string ); - #no edit screen to send them back to -%> <!-- mason kludge --> -<% - eidiot($error); -} else { - my $svcnum = $new->svcnum; - print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum"); -} +% +% eidiot($error); +%} else { +% my $svcnum = $new->svcnum; +% print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum"); +%} +% +% -%> diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html index 7cae78bfc..96d568754 100644 --- a/httemplate/edit/process/elements/process.html +++ b/httemplate/edit/process/elements/process.html @@ -1,91 +1,92 @@ -<% +% +% +% # options example... +% # +% ### +% ##req +% ## +% # +% # 'table' => +% # +% # #? 'primary_key' => #required when the dbdef doesn't know...??? +% # #? 'fields' => [] +% # +% ### +% ##opt +% ### +% # +% # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' +% # OR +% # 'redirect' => 'view/table.cgi?', # value of primary key is appended +% # +% # 'edit_ext' => 'html', #defaults to 'html', you might want 'cgi' while the +% # #naming is still inconsistent +% # +% # 'process_m2m' => { 'link_table' => 'link_table_name', +% # 'target_table' => 'target_table_name', +% # }, +% # 'process_m2name' => { 'link_table' => 'link_table_name', +% # 'link_static' => { 'column' => 'value' }, +% # 'num_col' => 'column', #if column name is different in +% # #link_table than source_table +% # 'name_col' => 'name_column', +% # 'names_list' => [ 'list', 'names' ], +% # }, +% +% my(%opt) = @_; +% +% #false laziness w/edit.html +% my $table = $opt{'table'}; +% my $class = "FS::$table"; +% my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || +% my $fields = $opt{'fields'} +% #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; +% || [ fields($table) ]; +% +% my $pkeyvalue = $cgi->param($pkey); +% +% my $old = qsearchs( $table, { $pkey => $pkeyvalue } ) if $pkeyvalue; +% +% my $new = $class->new( { +% map { +% $_, scalar($cgi->param($_)); +% } @$fields +% } ); +% +% my $error; +% if ( $pkeyvalue ) { +% $error = $new->replace($old); +% } else { +% $error = $new->insert; +% $pkeyvalue = $new->getfield($pkey); +% } +% +% if ( !$error && $opt{'process_m2m'} ) { +% $error = $new->process_m2m( %{ $opt{'process_m2m'} }, +% 'params' => scalar($cgi->Vars), +% ); +% } +% +% if ( !$error && $opt{'process_m2name'} ) { +% $error = $new->process_m2name( %{ $opt{'process_m2name'} }, +% 'params' => scalar($cgi->Vars), +% ); +% } +% +% # XXX print?!?! +% +% if ( $error ) { +% $cgi->param('error', $error); +% my $edit_ext = $opt{'edit_ext'} || 'html'; +% print $cgi->redirect(popurl(2). "$table.$edit_ext?". $cgi->query_string ); +% } elsif ( $opt{'redirect'} ) { +% print $cgi->redirect( $opt{'redirect'}. $pkeyvalue ); +% } else { +% print $cgi->redirect( popurl(3). +% ( $opt{'viewall_dir'} || 'search' ). +% "/$table.html" +% ); +% } +% +% - # options example... - # - ### - ##req - ## - # - # 'table' => - # - # #? 'primary_key' => #required when the dbdef doesn't know...??? - # #? 'fields' => [] - # - ### - ##opt - ### - # - # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' - # OR - # 'redirect' => 'view/table.cgi?', # value of primary key is appended - # - # 'edit_ext' => 'html', #defaults to 'html', you might want 'cgi' while the - # #naming is still inconsistent - # - # 'process_m2m' => { 'link_table' => 'link_table_name', - # 'target_table' => 'target_table_name', - # }, - # 'process_m2name' => { 'link_table' => 'link_table_name', - # 'link_static' => { 'column' => 'value' }, - # 'num_col' => 'column', #if column name is different in - # #link_table than source_table - # 'name_col' => 'name_column', - # 'names_list' => [ 'list', 'names' ], - # }, - - my(%opt) = @_; - - #false laziness w/edit.html - my $table = $opt{'table'}; - my $class = "FS::$table"; - my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || - my $fields = $opt{'fields'} - #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; - || [ fields($table) ]; - - my $pkeyvalue = $cgi->param($pkey); - - my $old = qsearchs( $table, { $pkey => $pkeyvalue } ) if $pkeyvalue; - - my $new = $class->new( { - map { - $_, scalar($cgi->param($_)); - } @$fields - } ); - - my $error; - if ( $pkeyvalue ) { - $error = $new->replace($old); - } else { - $error = $new->insert; - $pkeyvalue = $new->getfield($pkey); - } - - if ( !$error && $opt{'process_m2m'} ) { - $error = $new->process_m2m( %{ $opt{'process_m2m'} }, - 'params' => scalar($cgi->Vars), - ); - } - - if ( !$error && $opt{'process_m2name'} ) { - $error = $new->process_m2name( %{ $opt{'process_m2name'} }, - 'params' => scalar($cgi->Vars), - ); - } - - # XXX print?!?! - - if ( $error ) { - $cgi->param('error', $error); - my $edit_ext = $opt{'edit_ext'} || 'html'; - print $cgi->redirect(popurl(2). "$table.$edit_ext?". $cgi->query_string ); - } elsif ( $opt{'redirect'} ) { - print $cgi->redirect( $opt{'redirect'}. $pkeyvalue ); - } else { - print $cgi->redirect( popurl(3). - ( $opt{'viewall_dir'} || 'search' ). - "/$table.html" - ); - } - -%> diff --git a/httemplate/edit/process/elements/svc_Common.html b/httemplate/edit/process/elements/svc_Common.html index 1f8f8315e..8e8c99a42 100644 --- a/httemplate/edit/process/elements/svc_Common.html +++ b/httemplate/edit/process/elements/svc_Common.html @@ -1,11 +1,12 @@ -<% - - my %opt = @_; - my $table = $opt{'table'}; - $opt{'fields'} ||= [ fields($table) ]; - push @{ $opt{'fields'} }, qw( pkgnum svcpart ); - -%><%= include( 'process.html', +% +% +% my %opt = @_; +% my $table = $opt{'table'}; +% $opt{'fields'} ||= [ fields($table) ]; +% push @{ $opt{'fields'} }, qw( pkgnum svcpart ); +% +% +<% include( 'process.html', 'edit_ext' => 'cgi', 'redirect' => popurl(3)."view/$table.cgi?", %opt, diff --git a/httemplate/edit/process/generic.cgi b/httemplate/edit/process/generic.cgi index 9c54feb1d..82137c177 100644 --- a/httemplate/edit/process/generic.cgi +++ b/httemplate/edit/process/generic.cgi @@ -1,70 +1,71 @@ -<% +% +% +%# Welcome to generic.cgi. +%# +%# This script provides a generic edit/process/ backend for simple table +%# editing. All it knows how to do is take the values entered into +%# the script and insert them into the table specified by $cgi->param('table'). +%# If there's an existing record with the same primary key, it will be +%# replaced. (Deletion will be added in the future.) +%# +%# Special cgi params for this script: +%# table: the name of the table to be edited. The script will die horribly +%# if it can't find the table. +%# redirect_ok: URL to be displayed after a successful edit. The value of +%# the record's primary key will be passed as a keyword. +%# Defaults to (freeside root)/view/$table.cgi. +%# redirect_error: URL to be displayed if there's an error. The original +%# query string, plus the error message, will be passed. +%# Defaults to $cgi->referer() (i.e. go back where you +%# came from). +% +% +%use FS::Record qw(qsearchs dbdef); +%use DBIx::DBSchema; +%use DBIx::DBSchema::Table; +% +% +%my $error; +%my $p2 = popurl(2); +%my $p3 = popurl(3); +%my $table = $cgi->param('table'); +%my $dbdef = dbdef or die "Cannot fetch dbdef!"; +% +%my $dbdef_table = $dbdef->table($table) or die "Cannot fetch schema for $table"; +% +%my $pkey = $dbdef_table->primary_key or die "Cannot fetch pkey for $table"; +%my $pkey_val = $cgi->param($pkey); +% +% +%#warn "new FS::Record ( $table, (hashref) )"; +%my $new = FS::Record::new ( "FS::$table", { +% map { $_, scalar($cgi->param($_)) } fields($table) +%} ); +% +%#warn 'created $new of class '.ref($new); +% +%if($pkey_val and (my $old = qsearchs($table, { $pkey, $pkey_val} ))) { +% # edit +% $error = $new->replace($old); +%} else { +% #add +% $error = $new->insert; +% $pkey_val = $new->getfield($pkey); +% # New records usually don't have their primary keys set until after +% # they've been checked/inserted, so grab the new $pkey_val so we can +% # redirect to it. +%} +% +%my $redirect_ok = (($cgi->param('redirect_ok')) ? +% $cgi->param('redirect_ok') : $p3."browse/generic.cgi?$table"); +%my $redirect_error = (($cgi->param('redirect_error')) ? +% $cgi->param('redirect_error') : $cgi->referer()); +% +%if($error) { +% $cgi->param('error', $error); +% print $cgi->redirect($redirect_error . '?' . $cgi->query_string); +%} else { +% print $cgi->redirect($redirect_ok); +%} +% -# Welcome to generic.cgi. -# -# This script provides a generic edit/process/ backend for simple table -# editing. All it knows how to do is take the values entered into -# the script and insert them into the table specified by $cgi->param('table'). -# If there's an existing record with the same primary key, it will be -# replaced. (Deletion will be added in the future.) -# -# Special cgi params for this script: -# table: the name of the table to be edited. The script will die horribly -# if it can't find the table. -# redirect_ok: URL to be displayed after a successful edit. The value of -# the record's primary key will be passed as a keyword. -# Defaults to (freeside root)/view/$table.cgi. -# redirect_error: URL to be displayed if there's an error. The original -# query string, plus the error message, will be passed. -# Defaults to $cgi->referer() (i.e. go back where you -# came from). - - -use FS::Record qw(qsearchs dbdef); -use DBIx::DBSchema; -use DBIx::DBSchema::Table; - - -my $error; -my $p2 = popurl(2); -my $p3 = popurl(3); -my $table = $cgi->param('table'); -my $dbdef = dbdef or die "Cannot fetch dbdef!"; - -my $dbdef_table = $dbdef->table($table) or die "Cannot fetch schema for $table"; - -my $pkey = $dbdef_table->primary_key or die "Cannot fetch pkey for $table"; -my $pkey_val = $cgi->param($pkey); - - -#warn "new FS::Record ( $table, (hashref) )"; -my $new = FS::Record::new ( "FS::$table", { - map { $_, scalar($cgi->param($_)) } fields($table) -} ); - -#warn 'created $new of class '.ref($new); - -if($pkey_val and (my $old = qsearchs($table, { $pkey, $pkey_val} ))) { - # edit - $error = $new->replace($old); -} else { - #add - $error = $new->insert; - $pkey_val = $new->getfield($pkey); - # New records usually don't have their primary keys set until after - # they've been checked/inserted, so grab the new $pkey_val so we can - # redirect to it. -} - -my $redirect_ok = (($cgi->param('redirect_ok')) ? - $cgi->param('redirect_ok') : $p3."browse/generic.cgi?$table"); -my $redirect_error = (($cgi->param('redirect_error')) ? - $cgi->param('redirect_error') : $cgi->referer()); - -if($error) { - $cgi->param('error', $error); - print $cgi->redirect($redirect_error . '?' . $cgi->query_string); -} else { - print $cgi->redirect($redirect_ok); -} -%> diff --git a/httemplate/edit/process/inventory_class.html b/httemplate/edit/process/inventory_class.html index ab9efef48..c7be9e8dd 100644 --- a/httemplate/edit/process/inventory_class.html +++ b/httemplate/edit/process/inventory_class.html @@ -1,4 +1,4 @@ -<%= include( 'elements/process.html', +<% include( 'elements/process.html', 'table' => 'inventory_class', 'viewall_dir' => 'browse', ) diff --git a/httemplate/edit/process/msgcat.cgi b/httemplate/edit/process/msgcat.cgi index 1f94f6668..9711143d6 100644 --- a/httemplate/edit/process/msgcat.cgi +++ b/httemplate/edit/process/msgcat.cgi @@ -1,20 +1,21 @@ -<% +% +% +%my $error; +%foreach my $param ( grep { /^\d+$/ } $cgi->param ) { +% my $old = qsearchs('msgcat', { msgnum=>$param } ); +% next if $old->msg eq $cgi->param($param); #no need to update identical records +% my $new = new FS::msgcat { $old->hash }; +% $new->msg($cgi->param($param)); +% $error = $new->replace($old); +% last if $error; +%} +% +%if ( $error ) { +% $cgi->param('error',$error); +% print $cgi->redirect($p. "msgcat.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "browse/msgcat.cgi"); +%} +% +% -my $error; -foreach my $param ( grep { /^\d+$/ } $cgi->param ) { - my $old = qsearchs('msgcat', { msgnum=>$param } ); - next if $old->msg eq $cgi->param($param); #no need to update identical records - my $new = new FS::msgcat { $old->hash }; - $new->msg($cgi->param($param)); - $error = $new->replace($old); - last if $error; -} - -if ( $error ) { - $cgi->param('error',$error); - print $cgi->redirect($p. "msgcat.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "browse/msgcat.cgi"); -} - -%> diff --git a/httemplate/edit/process/part_bill_event.cgi b/httemplate/edit/process/part_bill_event.cgi index 77dcd242a..4811d9c9b 100755 --- a/httemplate/edit/process/part_bill_event.cgi +++ b/httemplate/edit/process/part_bill_event.cgi @@ -1,54 +1,55 @@ -<% +% +% +%my $eventpart = $cgi->param('eventpart'); +% +%my $old = qsearchs('part_bill_event',{'eventpart'=>$eventpart}) if $eventpart; +% +%#s/days/seconds/ +%$cgi->param('seconds', int( $cgi->param('days') * 86400 ) ); +% +%my $error; +%if ( ! $cgi->param('plan_weight_eventcode') ) { +% $error = "Must select an action"; +%} else { +% +% $cgi->param('plan_weight_eventcode') =~ /^([\w\-]+):(\d+):(.*)$/s +% or die "illegal plan_weight_eventcode:". +% $cgi->param('plan_weight_eventcode'); +% $cgi->param('plan', $1); +% $cgi->param('weight', $2); +% my $eventcode = $3; +% my $plandata = ''; +% while ( $eventcode =~ /%%%(\w+)%%%/ ) { +% my $field = $1; +% my $value = join(', ', $cgi->param($field) ); +% $cgi->param($field, $value); #in case it errors out +% $eventcode =~ s/%%%$field%%%/$value/; +% $plandata .= "$field $value\n"; +% } +% $cgi->param('eventcode', $eventcode); +% $cgi->param('plandata', $plandata); +% +% my $new = new FS::part_bill_event ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('part_bill_event'), +% } ); +% +% if ( $eventpart ) { +% $error = $new->replace($old); +% } else { +% $error = $new->insert; +% $eventpart = $new->getfield('eventpart'); +% } +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "part_bill_event.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3)."browse/part_bill_event.cgi"); +%} +% +% -my $eventpart = $cgi->param('eventpart'); - -my $old = qsearchs('part_bill_event',{'eventpart'=>$eventpart}) if $eventpart; - -#s/days/seconds/ -$cgi->param('seconds', int( $cgi->param('days') * 86400 ) ); - -my $error; -if ( ! $cgi->param('plan_weight_eventcode') ) { - $error = "Must select an action"; -} else { - - $cgi->param('plan_weight_eventcode') =~ /^([\w\-]+):(\d+):(.*)$/s - or die "illegal plan_weight_eventcode:". - $cgi->param('plan_weight_eventcode'); - $cgi->param('plan', $1); - $cgi->param('weight', $2); - my $eventcode = $3; - my $plandata = ''; - while ( $eventcode =~ /%%%(\w+)%%%/ ) { - my $field = $1; - my $value = join(', ', $cgi->param($field) ); - $cgi->param($field, $value); #in case it errors out - $eventcode =~ s/%%%$field%%%/$value/; - $plandata .= "$field $value\n"; - } - $cgi->param('eventcode', $eventcode); - $cgi->param('plandata', $plandata); - - my $new = new FS::part_bill_event ( { - map { - $_, scalar($cgi->param($_)); - } fields('part_bill_event'), - } ); - - if ( $eventpart ) { - $error = $new->replace($old); - } else { - $error = $new->insert; - $eventpart = $new->getfield('eventpart'); - } -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "part_bill_event.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3)."browse/part_bill_event.cgi"); -} - -%> diff --git a/httemplate/edit/process/part_export.cgi b/httemplate/edit/process/part_export.cgi index fa009edbb..0dd9eabae 100644 --- a/httemplate/edit/process/part_export.cgi +++ b/httemplate/edit/process/part_export.cgi @@ -1,39 +1,40 @@ -<% +% +% +%my $exportnum = $cgi->param('exportnum'); +% +%my $old = qsearchs('part_export', { 'exportnum'=>$exportnum } ) if $exportnum; +% +%#fixup options +%#warn join('-', split(',',$cgi->param('options'))); +%my %options = map { +% my $value = $cgi->param($_); +% $value =~ s/\r\n/\n/g; #browsers? (textarea) +% $_ => $value; +%} split(',', $cgi->param('options')); +% +%my $new = new FS::part_export ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('part_export') +%} ); +% +%my $error; +%if ( $exportnum ) { +% #warn $old; +% #warn $exportnum; +% #warn $new->machine; +% $error = $new->replace($old,\%options); +%} else { +% $error = $new->insert(\%options); +%# $exportnum = $new->exportnum; +%} +% +%if ( $error ) { +% $cgi->param('error', $error ); +% print $cgi->redirect(popurl(2). "part_export.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "browse/part_export.cgi"); +%} +% +% -my $exportnum = $cgi->param('exportnum'); - -my $old = qsearchs('part_export', { 'exportnum'=>$exportnum } ) if $exportnum; - -#fixup options -#warn join('-', split(',',$cgi->param('options'))); -my %options = map { - my $value = $cgi->param($_); - $value =~ s/\r\n/\n/g; #browsers? (textarea) - $_ => $value; -} split(',', $cgi->param('options')); - -my $new = new FS::part_export ( { - map { - $_, scalar($cgi->param($_)); - } fields('part_export') -} ); - -my $error; -if ( $exportnum ) { - #warn $old; - #warn $exportnum; - #warn $new->machine; - $error = $new->replace($old,\%options); -} else { - $error = $new->insert(\%options); -# $exportnum = $new->exportnum; -} - -if ( $error ) { - $cgi->param('error', $error ); - print $cgi->redirect(popurl(2). "part_export.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "browse/part_export.cgi"); -} - -%> diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 0d0a13491..204c751d9 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -1,61 +1,62 @@ -<% +% +% +%my $dbh = dbh; +% +%my $pkgpart = $cgi->param('pkgpart'); +% +%my $old = qsearchs('part_pkg',{'pkgpart'=>$pkgpart}) if $pkgpart; +% +%#fixup plandata +%my $plandata = $cgi->param('plandata'); +%my @plandata = split(',', $plandata); +%$cgi->param('plandata', +% join('', map { "$_=". join(', ', $cgi->param($_)). "\n" } @plandata ) +%); +% +%foreach (qw( setuptax recurtax disabled )) { +% $cgi->param($_, '') unless defined $cgi->param($_); +%} +% +%my $new = new FS::part_pkg ( { +% map { +% $_ => scalar($cgi->param($_)); +% } fields('part_pkg') +%} ); +% +%my %pkg_svc = map { $_ => scalar($cgi->param("pkg_svc$_")) } +% map { $_->svcpart } +% qsearch('part_svc', {} ); +% +%my $error; +%my $custnum = ''; +%if ( $cgi->param('taxclass') eq '(select)' ) { +% +% $error = 'Must select a tax class'; +% +%} elsif ( $pkgpart ) { +% +% $error = $new->replace( $old, +% pkg_svc => \%pkg_svc, +% primary_svc => scalar($cgi->param('pkg_svc_primary')), +% ); +%} else { +% +% $error = $new->insert( pkg_svc => \%pkg_svc, +% primary_svc => scalar($cgi->param('pkg_svc_primary')), +% cust_pkg => $cgi->param('pkgnum'), +% custnum_ref => \$custnum, +% ); +% $pkgpart = $new->pkgpart; +%} +% +%if ( $error ) { +% $cgi->param('error', $error ); +% print $cgi->redirect(popurl(2). "part_pkg.cgi?". $cgi->query_string ); +%} elsif ( $custnum ) { +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); +%} else { +% print $cgi->redirect(popurl(3). "browse/part_pkg.cgi"); +%} +% +% -my $dbh = dbh; - -my $pkgpart = $cgi->param('pkgpart'); - -my $old = qsearchs('part_pkg',{'pkgpart'=>$pkgpart}) if $pkgpart; - -#fixup plandata -my $plandata = $cgi->param('plandata'); -my @plandata = split(',', $plandata); -$cgi->param('plandata', - join('', map { "$_=". join(', ', $cgi->param($_)). "\n" } @plandata ) -); - -foreach (qw( setuptax recurtax disabled )) { - $cgi->param($_, '') unless defined $cgi->param($_); -} - -my $new = new FS::part_pkg ( { - map { - $_ => scalar($cgi->param($_)); - } fields('part_pkg') -} ); - -my %pkg_svc = map { $_ => scalar($cgi->param("pkg_svc$_")) } - map { $_->svcpart } - qsearch('part_svc', {} ); - -my $error; -my $custnum = ''; -if ( $cgi->param('taxclass') eq '(select)' ) { - - $error = 'Must select a tax class'; - -} elsif ( $pkgpart ) { - - $error = $new->replace( $old, - pkg_svc => \%pkg_svc, - primary_svc => scalar($cgi->param('pkg_svc_primary')), - ); -} else { - - $error = $new->insert( pkg_svc => \%pkg_svc, - primary_svc => scalar($cgi->param('pkg_svc_primary')), - cust_pkg => $cgi->param('pkgnum'), - custnum_ref => \$custnum, - ); - $pkgpart = $new->pkgpart; -} - -if ( $error ) { - $cgi->param('error', $error ); - print $cgi->redirect(popurl(2). "part_pkg.cgi?". $cgi->query_string ); -} elsif ( $custnum ) { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); -} else { - print $cgi->redirect(popurl(3). "browse/part_pkg.cgi"); -} - -%> diff --git a/httemplate/edit/process/part_referral.html b/httemplate/edit/process/part_referral.html index 0b5d959a0..14c1b7001 100755 --- a/httemplate/edit/process/part_referral.html +++ b/httemplate/edit/process/part_referral.html @@ -1,4 +1,4 @@ -<%= include( 'elements/process.html', +<% include( 'elements/process.html', 'table' => 'part_referral', 'viewall_dir' => 'browse', ) diff --git a/httemplate/edit/process/part_svc.cgi b/httemplate/edit/process/part_svc.cgi index b92b62739..97abc5baf 100755 --- a/httemplate/edit/process/part_svc.cgi +++ b/httemplate/edit/process/part_svc.cgi @@ -1,3 +1,4 @@ -<% - my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process', $cgi; -%><%= $server->process %> +% +% my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process', $cgi; +% +<% $server->process %> diff --git a/httemplate/edit/process/payment_gateway.html b/httemplate/edit/process/payment_gateway.html index 42205a02d..0b7e31395 100644 --- a/httemplate/edit/process/payment_gateway.html +++ b/httemplate/edit/process/payment_gateway.html @@ -1,33 +1,34 @@ -<% +% +% +%my $gatewaynum = $cgi->param('gatewaynum'); +% +%my $old = qsearchs('payment_gateway',{'gatewaynum'=>$gatewaynum}) if $gatewaynum; +% +%my $new = new FS::payment_gateway ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('payment_gateway') +%} ); +% +%my @options = split(/\r?\n/, $cgi->param('gateway_options') ); +%pop @options +% if scalar(@options) % 2 && $options[-1] =~ /^\s*$/; +%my %options = @options; +% +%my $error; +%if ( $gatewaynum ) { +% $error=$new->replace($old, \%options); +%} else { +% $error=$new->insert(\%options); +% $gatewaynum=$new->getfield('gatewaynum'); +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "payment_gateway.html?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "browse/payment_gateway.html"); +%} +% +% -my $gatewaynum = $cgi->param('gatewaynum'); - -my $old = qsearchs('payment_gateway',{'gatewaynum'=>$gatewaynum}) if $gatewaynum; - -my $new = new FS::payment_gateway ( { - map { - $_, scalar($cgi->param($_)); - } fields('payment_gateway') -} ); - -my @options = split(/\r?\n/, $cgi->param('gateway_options') ); -pop @options - if scalar(@options) % 2 && $options[-1] =~ /^\s*$/; -my %options = @options; - -my $error; -if ( $gatewaynum ) { - $error=$new->replace($old, \%options); -} else { - $error=$new->insert(\%options); - $gatewaynum=$new->getfield('gatewaynum'); -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "payment_gateway.html?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "browse/payment_gateway.html"); -} - -%> diff --git a/httemplate/edit/process/pkg_class.html b/httemplate/edit/process/pkg_class.html index 48e2b8009..183da805c 100644 --- a/httemplate/edit/process/pkg_class.html +++ b/httemplate/edit/process/pkg_class.html @@ -1,4 +1,4 @@ -<%= include( 'elements/process.html', +<% include( 'elements/process.html', 'table' => 'pkg_class', 'viewall_dir' => 'browse', ) diff --git a/httemplate/edit/process/prepay_credit.cgi b/httemplate/edit/process/prepay_credit.cgi index ca7472432..fb15fd8e4 100644 --- a/httemplate/edit/process/prepay_credit.cgi +++ b/httemplate/edit/process/prepay_credit.cgi @@ -1,51 +1,57 @@ +% +%my $hashref = {}; +% +%my $agent = ''; +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $agent = qsearchs('agent', { 'agentnum' => $hashref->{agentnum}=$1 } ); +%} +% +%my $error = ''; +% +%my $num = 0; +%if ( $cgi->param('num') =~ /^\s*(\d+)\s*$/ ) { +% $num = $1; +%} else { +% $error = 'Illegal number of prepaid cards: '. $cgi->param('num'); +%} +% +%$hashref->{amount} = $cgi->param('amount'); +%$hashref->{seconds} = $cgi->param('seconds') * $cgi->param('multiplier'); +% +%$error ||= FS::prepay_credit::generate( $num, +% scalar($cgi->param('type')), +% $hashref +% ); +% +%unless ( ref($error) ) { +% $cgi->param('error', $error ); +% <% -my $hashref = {}; - -my $agent = ''; -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $agent = qsearchs('agent', { 'agentnum' => $hashref->{agentnum}=$1 } ); -} - -my $error = ''; - -my $num = 0; -if ( $cgi->param('num') =~ /^\s*(\d+)\s*$/ ) { - $num = $1; -} else { - $error = 'Illegal number of prepaid cards: '. $cgi->param('num'); -} - -$hashref->{amount} = $cgi->param('amount'); -$hashref->{seconds} = $cgi->param('seconds') * $cgi->param('multiplier'); - -$error ||= FS::prepay_credit::generate( $num, - scalar($cgi->param('type')), - $hashref - ); - -unless ( ref($error) ) { - $cgi->param('error', $error ); -%><%= $cgi->redirect(popurl(3). "edit/prepay_credit.cgi?". $cgi->query_string ) -%><% } else { %> +%> +% } else { + -<%= include("/elements/header.html", "$num prepaid cards generated". +<% include("/elements/header.html", "$num prepaid cards generated". ( $agent ? ' for '.$agent->agent : '' ), menubar( 'Main menu' => popurl(3) ) ) %> <FONT SIZE="+1"> -<% foreach my $card ( @$error ) { %> - <code><%= $card %></code> +% foreach my $card ( @$error ) { + + <code><% $card %></code> - - <%= $hashref->{amount} ? sprintf('$%.2f', $hashref->{amount} ) : '' %> - <%= $hashref->{amount} && $hashref->{seconds} ? 'and' : '' %> - <%= $hashref->{seconds} ? duration_exact($hashref->{seconds}) : '' %> + <% $hashref->{amount} ? sprintf('$%.2f', $hashref->{amount} ) : '' %> + <% $hashref->{amount} && $hashref->{seconds} ? 'and' : '' %> + <% $hashref->{seconds} ? duration_exact($hashref->{seconds}) : '' %> <br> -<% } %> +% } + </FONT> </BODY></HTML> -<% } %> +% } + diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 928e3daad..70778c1cc 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -1,41 +1,43 @@ -<% +% +% +%#untaint custnum +%$cgi->param('custnum') =~ /^(\d+)$/ +% or die 'illegal custnum '. $cgi->param('custnum'); +%my $custnum = $1; +% +%$cgi->param('amount') =~ /^\s*(\d+(\.\d{1,2})?)\s*$/ +% or die 'illegal amount '. $cgi->param('amount'); +%my $amount = $1; +% +%my( $error, $cust_main); +%if ( $cgi->param('taxclass') eq '(select)' ) { +% +% +% $error = 'Must select a tax class'; +%} else { +% +% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) +% or die "unknown custnum $custnum"; +% +% $error = $cust_main->charge( +% $amount, +% $cgi->param('pkg'), +% '$'. sprintf("%.2f",$amount), +% $cgi->param('taxclass') +% ); +% +%} +% +%if ($error) { +% -#untaint custnum -$cgi->param('custnum') =~ /^(\d+)$/ - or die 'illegal custnum '. $cgi->param('custnum'); -my $custnum = $1; - -$cgi->param('amount') =~ /^\s*(\d+(\.\d{1,2})?)\s*$/ - or die 'illegal amount '. $cgi->param('amount'); -my $amount = $1; - -my( $error, $cust_main); -if ( $cgi->param('taxclass') eq '(select)' ) { - - - $error = 'Must select a tax class'; -} else { - - my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) - or die "unknown custnum $custnum"; - - $error = $cust_main->charge( - $amount, - $cgi->param('pkg'), - '$'. sprintf("%.2f",$amount), - $cgi->param('taxclass') - ); - -} - -if ($error) { -%> <!-- mason kludge --> -<% - eidiot($error); -} else { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum" ); -} +% +% eidiot($error); +%} else { +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum" ); +%} +% +% -%> diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index fd9e59472..7afc9f2bb 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -1,25 +1,27 @@ -<% +% +% +%#untaint custnum +%$cgi->param('custnum') =~ /^(\d+)$/ +% or die 'illegal custnum '. $cgi->param('custnum'); +%my $custnum = $1; +%$cgi->param('pkgpart') =~ /^(\d+)$/ +% or die 'illegal pkgpart '. $cgi->param('pkgpart'); +%my $pkgpart = $1; +% +%my @cust_pkg = (); +%my $error = FS::cust_pkg::order($custnum, [ $pkgpart ], [], \@cust_pkg, ); +% +%if ($error) { +% -#untaint custnum -$cgi->param('custnum') =~ /^(\d+)$/ - or die 'illegal custnum '. $cgi->param('custnum'); -my $custnum = $1; -$cgi->param('pkgpart') =~ /^(\d+)$/ - or die 'illegal pkgpart '. $cgi->param('pkgpart'); -my $pkgpart = $1; - -my @cust_pkg = (); -my $error = FS::cust_pkg::order($custnum, [ $pkgpart ], [], \@cust_pkg, ); - -if ($error) { -%> <!-- mason kludge --> -<% - eidiot($error); -} else { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". - "#cust_pkg". $cust_pkg[0]->pkgnum ); -} +% +% eidiot($error); +%} else { +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". +% "#cust_pkg". $cust_pkg[0]->pkgnum ); +%} +% +% -%> diff --git a/httemplate/edit/process/rate.cgi b/httemplate/edit/process/rate.cgi index 87c082d64..c81f883b7 100755 --- a/httemplate/edit/process/rate.cgi +++ b/httemplate/edit/process/rate.cgi @@ -1,3 +1,4 @@ -<% - my $server = new FS::UI::Web::JSRPC 'FS::rate::process', $cgi; -%><%= $server->process %> +% +% my $server = new FS::UI::Web::JSRPC 'FS::rate::process', $cgi; +% +<% $server->process %> diff --git a/httemplate/edit/process/rate_region.cgi b/httemplate/edit/process/rate_region.cgi index 09d3d2c42..753224565 100755 --- a/httemplate/edit/process/rate_region.cgi +++ b/httemplate/edit/process/rate_region.cgi @@ -1,51 +1,52 @@ -<% +% +% +%my $regionnum = $cgi->param('regionnum'); +% +%my $old = qsearchs('rate_region', { 'regionnum' => $regionnum } ) if $regionnum; +% +%my $new = new FS::rate_region ( { +% map { +% $_, scalar($cgi->param($_)); +% } ( fields('rate_region') ) +%} ); +% +%my $countrycode = $cgi->param('countrycode'); +%my @npa = split(/\s*,\s*/, $cgi->param('npa')); +%$npa[0] = '' unless @npa; +%my @rate_prefix = map { +% new FS::rate_prefix { +% 'countrycode' => $countrycode, +% 'npa' => $_, +% } +% } @npa; +% +%my @dest_detail = map { +% my $ratenum = $_->ratenum; +% new FS::rate_detail { +% 'ratenum' => $ratenum, +% map { $_ => $cgi->param("$_$ratenum") } +% qw( min_included min_charge sec_granularity ) +% }; +%} qsearch('rate', {} ); +% +% +%my $error; +%if ( $regionnum ) { +% $error = $new->replace($old, 'rate_prefix' => \@rate_prefix, +% 'dest_detail' => \@dest_detail, ); +%} else { +% $error = $new->insert( 'rate_prefix' => \@rate_prefix, +% 'dest_detail' => \@dest_detail, ); +% $regionnum = $new->getfield('regionnum'); +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "rate_region.cgi?". $cgi->query_string ); +%} else { +% #print $cgi->redirect(popurl(3). "browse/rate_region.cgi"); +% print $cgi->redirect(popurl(3). "browse/rate.cgi"); +%} +% +% -my $regionnum = $cgi->param('regionnum'); - -my $old = qsearchs('rate_region', { 'regionnum' => $regionnum } ) if $regionnum; - -my $new = new FS::rate_region ( { - map { - $_, scalar($cgi->param($_)); - } ( fields('rate_region') ) -} ); - -my $countrycode = $cgi->param('countrycode'); -my @npa = split(/\s*,\s*/, $cgi->param('npa')); -$npa[0] = '' unless @npa; -my @rate_prefix = map { - new FS::rate_prefix { - 'countrycode' => $countrycode, - 'npa' => $_, - } - } @npa; - -my @dest_detail = map { - my $ratenum = $_->ratenum; - new FS::rate_detail { - 'ratenum' => $ratenum, - map { $_ => $cgi->param("$_$ratenum") } - qw( min_included min_charge sec_granularity ) - }; -} qsearch('rate', {} ); - - -my $error; -if ( $regionnum ) { - $error = $new->replace($old, 'rate_prefix' => \@rate_prefix, - 'dest_detail' => \@dest_detail, ); -} else { - $error = $new->insert( 'rate_prefix' => \@rate_prefix, - 'dest_detail' => \@dest_detail, ); - $regionnum = $new->getfield('regionnum'); -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "rate_region.cgi?". $cgi->query_string ); -} else { - #print $cgi->redirect(popurl(3). "browse/rate_region.cgi"); - print $cgi->redirect(popurl(3). "browse/rate.cgi"); -} - -%> diff --git a/httemplate/edit/process/reg_code.cgi b/httemplate/edit/process/reg_code.cgi index a86c7383a..4fdea60fc 100644 --- a/httemplate/edit/process/reg_code.cgi +++ b/httemplate/edit/process/reg_code.cgi @@ -1,44 +1,50 @@ +% +% +%$cgi->param('agentnum') =~ /^(\d+)$/ +% or eidiot 'illegal agentnum '. $cgi->param('agentnum'); +%my $agentnum = $1; +%my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); +% +%my $error = ''; +% +%my $num = 0; +%if ( $cgi->param('num') =~ /^\s*(\d+)\s*$/ ) { +% $num = $1; +%} else { +% $error = 'Illegal number of codes: '. $cgi->param('num'); +%} +% +%my @pkgparts = +% map { /^pkgpart(.*)$/; $1 } +% grep { $cgi->param($_) } +% grep { /^pkgpart/ } +% $cgi->param; +% +%$error ||= $agent->generate_reg_codes($num, \@pkgparts); +% +%unless ( ref($error) ) { +% $cgi->param('error'. $error ); +% <% - -$cgi->param('agentnum') =~ /^(\d+)$/ - or eidiot 'illegal agentnum '. $cgi->param('agentnum'); -my $agentnum = $1; -my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); - -my $error = ''; - -my $num = 0; -if ( $cgi->param('num') =~ /^\s*(\d+)\s*$/ ) { - $num = $1; -} else { - $error = 'Illegal number of codes: '. $cgi->param('num'); -} - -my @pkgparts = - map { /^pkgpart(.*)$/; $1 } - grep { $cgi->param($_) } - grep { /^pkgpart/ } - $cgi->param; - -$error ||= $agent->generate_reg_codes($num, \@pkgparts); - -unless ( ref($error) ) { - $cgi->param('error'. $error ); -%><%= $cgi->redirect(popurl(3). "edit/reg_code.cgi?". $cgi->query_string ) -%><% } else { %> +%> +% } else { + -<%= include("/elements/header.html","$num registration codes generated for ". $agent->agent, menubar( +<% include("/elements/header.html","$num registration codes generated for ". $agent->agent, menubar( 'Main menu' => popurl(3), 'View all agents' => popurl(3). 'browse/agent.cgi', ) ) %> <PRE><FONT SIZE="+1"> -<% foreach my $code ( @$error ) { %> - <%= $code %> -<% } %> +% foreach my $code ( @$error ) { + + <% $code %> +% } + </FONT></PRE> </BODY></HTML> -<% } %> +% } + diff --git a/httemplate/edit/process/router.cgi b/httemplate/edit/process/router.cgi index a2fa46dd9..c69114ea4 100644 --- a/httemplate/edit/process/router.cgi +++ b/httemplate/edit/process/router.cgi @@ -1,67 +1,68 @@ -<% +% +% +%local $FS::UID::AutoCommit=0; +% +%sub check { +% my $error = shift; +% if($error) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(3) . "edit/router.cgi?". $cgi->query_string); +% dbh->rollback; +% exit; +% } +%} +% +%my $error = ''; +%my $routernum = $cgi->param('routernum'); +%my $routername = $cgi->param('routername'); +%my $old = qsearchs('router', { routernum => $routernum }); +%my @old_psr; +% +%my $new = new FS::router { +% map { +% ($_, scalar($cgi->param($_))); +% } fields('router') +%}; +% +%if($old) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $routernum = $new->routernum; +%} +% +%check($error); +% +%if ($old) { +% @old_psr = $old->part_svc_router; +% foreach my $psr (@old_psr) { +% if($cgi->param('svcpart_'.$psr->svcpart) eq 'ON') { +% # do nothing +% } else { +% $error = $psr->delete; +% } +% } +% check($error); +%} +% +%foreach($cgi->param) { +% if($cgi->param($_) eq 'ON' and /^svcpart_(\d+)$/) { +% my $svcpart = $1; +% if(grep {$_->svcpart == $svcpart} @old_psr) { +% # do nothing +% } else { +% my $new_psr = new FS::part_svc_router { svcpart => $svcpart, +% routernum => $routernum }; +% $error = $new_psr->insert; +% } +% check($error); +% } +%} +% +% +%# Yay, everything worked! +%dbh->commit or die dbh->errstr; +%print $cgi->redirect(popurl(3). "browse/router.cgi"); +% +% -local $FS::UID::AutoCommit=0; - -sub check { - my $error = shift; - if($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(3) . "edit/router.cgi?". $cgi->query_string); - dbh->rollback; - exit; - } -} - -my $error = ''; -my $routernum = $cgi->param('routernum'); -my $routername = $cgi->param('routername'); -my $old = qsearchs('router', { routernum => $routernum }); -my @old_psr; - -my $new = new FS::router { - map { - ($_, scalar($cgi->param($_))); - } fields('router') -}; - -if($old) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $routernum = $new->routernum; -} - -check($error); - -if ($old) { - @old_psr = $old->part_svc_router; - foreach my $psr (@old_psr) { - if($cgi->param('svcpart_'.$psr->svcpart) eq 'ON') { - # do nothing - } else { - $error = $psr->delete; - } - } - check($error); -} - -foreach($cgi->param) { - if($cgi->param($_) eq 'ON' and /^svcpart_(\d+)$/) { - my $svcpart = $1; - if(grep {$_->svcpart == $svcpart} @old_psr) { - # do nothing - } else { - my $new_psr = new FS::part_svc_router { svcpart => $svcpart, - routernum => $routernum }; - $error = $new_psr->insert; - } - check($error); - } -} - - -# Yay, everything worked! -dbh->commit or die dbh->errstr; -print $cgi->redirect(popurl(3). "browse/router.cgi"); - -%> diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index 950a8602f..247a5b446 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -1,49 +1,50 @@ -<% +% +% +%$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +%my $svcnum = $1; +% +%my $old; +%if ( $svcnum ) { +% $old = qsearchs('svc_acct', { 'svcnum' => $svcnum } ) +% or die "fatal: can't find account (svcnum $svcnum)!"; +%} else { +% $old = ''; +%} +% +%#unmunge popnum +%$cgi->param('popnum', (split(/:/, $cgi->param('popnum') ))[0] ); +% +%#unmunge passwd +%if ( $cgi->param('_password') eq '*HIDDEN*' ) { +% die "fatal: no previous account to recall hidden password from!" unless $old; +% $cgi->param('_password',$old->getfield('_password')); +%} +% +%#unmunge usergroup +%$cgi->param('usergroup', [ $cgi->param('radius_usergroup') ] ); +% +%my $new = new FS::svc_acct ( { +% map { +% $_, scalar($cgi->param($_)); +% #} qw(svcnum pkgnum svcpart username _password popnum uid gid finger dir +% # shell quota slipip) +% } ( fields('svc_acct'), qw( pkgnum svcpart usergroup ) ) +%} ); +% +%my $error; +%if ( $svcnum ) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $svcnum = $new->svcnum; +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "svc_acct.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/svc_acct.cgi?" . $svcnum ); +%} +% +% -$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; -my $svcnum = $1; - -my $old; -if ( $svcnum ) { - $old = qsearchs('svc_acct', { 'svcnum' => $svcnum } ) - or die "fatal: can't find account (svcnum $svcnum)!"; -} else { - $old = ''; -} - -#unmunge popnum -$cgi->param('popnum', (split(/:/, $cgi->param('popnum') ))[0] ); - -#unmunge passwd -if ( $cgi->param('_password') eq '*HIDDEN*' ) { - die "fatal: no previous account to recall hidden password from!" unless $old; - $cgi->param('_password',$old->getfield('_password')); -} - -#unmunge usergroup -$cgi->param('usergroup', [ $cgi->param('radius_usergroup') ] ); - -my $new = new FS::svc_acct ( { - map { - $_, scalar($cgi->param($_)); - #} qw(svcnum pkgnum svcpart username _password popnum uid gid finger dir - # shell quota slipip) - } ( fields('svc_acct'), qw( pkgnum svcpart usergroup ) ) -} ); - -my $error; -if ( $svcnum ) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $svcnum = $new->svcnum; -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "svc_acct.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/svc_acct.cgi?" . $svcnum ); -} - -%> diff --git a/httemplate/edit/process/svc_acct_pop.cgi b/httemplate/edit/process/svc_acct_pop.cgi index 46ad74d62..9e9df7bf0 100755 --- a/httemplate/edit/process/svc_acct_pop.cgi +++ b/httemplate/edit/process/svc_acct_pop.cgi @@ -1,28 +1,29 @@ -<% +% +% +%my $popnum = $cgi->param('popnum'); +% +%my $old = qsearchs('svc_acct_pop',{'popnum'=>$popnum}) if $popnum; +% +%my $new = new FS::svc_acct_pop ( { +% map { +% $_, scalar($cgi->param($_)); +% } fields('svc_acct_pop') +%} ); +% +%my $error = ''; +%if ( $popnum ) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $popnum=$new->getfield('popnum'); +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "svc_acct_pop.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "browse/svc_acct_pop.cgi"); +%} +% +% -my $popnum = $cgi->param('popnum'); - -my $old = qsearchs('svc_acct_pop',{'popnum'=>$popnum}) if $popnum; - -my $new = new FS::svc_acct_pop ( { - map { - $_, scalar($cgi->param($_)); - } fields('svc_acct_pop') -} ); - -my $error = ''; -if ( $popnum ) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $popnum=$new->getfield('popnum'); -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "svc_acct_pop.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "browse/svc_acct_pop.cgi"); -} - -%> diff --git a/httemplate/edit/process/svc_broadband.cgi b/httemplate/edit/process/svc_broadband.cgi index a009ba218..cf4604639 100644 --- a/httemplate/edit/process/svc_broadband.cgi +++ b/httemplate/edit/process/svc_broadband.cgi @@ -1,36 +1,37 @@ -<% +% +% +%$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +%my $svcnum = $1; +% +%my $old; +%if ( $svcnum ) { +% $old = qsearchs('svc_broadband', { 'svcnum' => $svcnum } ) +% or die "fatal: can't find broadband service (svcnum $svcnum)!"; +%} else { +% $old = ''; +%} +% +%my $new = new FS::svc_broadband ( { +% map { +% ($_, scalar($cgi->param($_))); +% } ( fields('svc_broadband'), qw( pkgnum svcpart ) ) +%} ); +% +%my $error; +%if ( $svcnum ) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $svcnum = $new->svcnum; +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% $cgi->param('ip_addr', $new->ip_addr); +% print $cgi->redirect(popurl(2). "svc_broadband.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/svc_broadband.cgi?" . $svcnum ); +%} +% +% -$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; -my $svcnum = $1; - -my $old; -if ( $svcnum ) { - $old = qsearchs('svc_broadband', { 'svcnum' => $svcnum } ) - or die "fatal: can't find broadband service (svcnum $svcnum)!"; -} else { - $old = ''; -} - -my $new = new FS::svc_broadband ( { - map { - ($_, scalar($cgi->param($_))); - } ( fields('svc_broadband'), qw( pkgnum svcpart ) ) -} ); - -my $error; -if ( $svcnum ) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $svcnum = $new->svcnum; -} - -if ( $error ) { - $cgi->param('error', $error); - $cgi->param('ip_addr', $new->ip_addr); - print $cgi->redirect(popurl(2). "svc_broadband.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/svc_broadband.cgi?" . $svcnum ); -} - -%> diff --git a/httemplate/edit/process/svc_domain.cgi b/httemplate/edit/process/svc_domain.cgi index 19f8eb4f8..773143fe3 100755 --- a/httemplate/edit/process/svc_domain.cgi +++ b/httemplate/edit/process/svc_domain.cgi @@ -1,31 +1,32 @@ -<% +% +% +%#remove this to actually test the domains! +%$FS::svc_domain::whois_hack = 1; +% +%$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +%my $svcnum = $1; +% +%my $new = new FS::svc_domain ( { +% map { +% $_, scalar($cgi->param($_)); +% #} qw(svcnum pkgnum svcpart domain action purpose) +% } ( fields('svc_domain'), qw( pkgnum svcpart action purpose ) ) +%} ); +% +%my $error = ''; +%if ($cgi->param('svcnum')) { +% $error="Can't modify a domain!"; +%} else { +% $error=$new->insert; +% $svcnum=$new->svcnum; +%} +% +%if ($error) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "svc_domain.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum"); +%} +% +% -#remove this to actually test the domains! -$FS::svc_domain::whois_hack = 1; - -$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; -my $svcnum = $1; - -my $new = new FS::svc_domain ( { - map { - $_, scalar($cgi->param($_)); - #} qw(svcnum pkgnum svcpart domain action purpose) - } ( fields('svc_domain'), qw( pkgnum svcpart action purpose ) ) -} ); - -my $error = ''; -if ($cgi->param('svcnum')) { - $error="Can't modify a domain!"; -} else { - $error=$new->insert; - $svcnum=$new->svcnum; -} - -if ($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "svc_domain.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum"); -} - -%> diff --git a/httemplate/edit/process/svc_external.cgi b/httemplate/edit/process/svc_external.cgi index 728cd2189..97da6ba87 100755 --- a/httemplate/edit/process/svc_external.cgi +++ b/httemplate/edit/process/svc_external.cgi @@ -1,29 +1,30 @@ -<% +% +% +%$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +%my $svcnum =$1; +% +%my $old = qsearchs('svc_external',{'svcnum'=>$svcnum}) if $svcnum; +% +%my $new = new FS::svc_external ( { +% map { +% ($_, scalar($cgi->param($_))); +% } ( fields('svc_external'), qw( pkgnum svcpart ) ) +%} ); +% +%my $error = ''; +%if ( $svcnum ) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $svcnum = $new->getfield('svcnum'); +%} +% +%if ($error) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "svc_external.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/svc_external.cgi?$svcnum"); +%} +% +% -$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; -my $svcnum =$1; - -my $old = qsearchs('svc_external',{'svcnum'=>$svcnum}) if $svcnum; - -my $new = new FS::svc_external ( { - map { - ($_, scalar($cgi->param($_))); - } ( fields('svc_external'), qw( pkgnum svcpart ) ) -} ); - -my $error = ''; -if ( $svcnum ) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $svcnum = $new->getfield('svcnum'); -} - -if ($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "svc_external.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/svc_external.cgi?$svcnum"); -} - -%> diff --git a/httemplate/edit/process/svc_forward.cgi b/httemplate/edit/process/svc_forward.cgi index bb066d8a6..3205312f1 100755 --- a/httemplate/edit/process/svc_forward.cgi +++ b/httemplate/edit/process/svc_forward.cgi @@ -1,29 +1,30 @@ -<% +% +% +%$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +%my $svcnum =$1; +% +%my $old = qsearchs('svc_forward',{'svcnum'=>$svcnum}) if $svcnum; +% +%my $new = new FS::svc_forward ( { +% map { +% ($_, scalar($cgi->param($_))); +% } ( fields('svc_forward'), qw( pkgnum svcpart ) ) +%} ); +% +%my $error = ''; +%if ( $svcnum ) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $svcnum = $new->getfield('svcnum'); +%} +% +%if ($error) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "svc_forward.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/svc_forward.cgi?$svcnum"); +%} +% +% -$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; -my $svcnum =$1; - -my $old = qsearchs('svc_forward',{'svcnum'=>$svcnum}) if $svcnum; - -my $new = new FS::svc_forward ( { - map { - ($_, scalar($cgi->param($_))); - } ( fields('svc_forward'), qw( pkgnum svcpart ) ) -} ); - -my $error = ''; -if ( $svcnum ) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $svcnum = $new->getfield('svcnum'); -} - -if ($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "svc_forward.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/svc_forward.cgi?$svcnum"); -} - -%> diff --git a/httemplate/edit/process/svc_phone.html b/httemplate/edit/process/svc_phone.html index c1d4b7547..44235de63 100644 --- a/httemplate/edit/process/svc_phone.html +++ b/httemplate/edit/process/svc_phone.html @@ -1,4 +1,4 @@ -<%= include( 'elements/svc_Common.html', +<% include( 'elements/svc_Common.html', 'table' => 'svc_phone', ) %> diff --git a/httemplate/edit/process/svc_www.cgi b/httemplate/edit/process/svc_www.cgi index 40913145a..e9a52aff2 100644 --- a/httemplate/edit/process/svc_www.cgi +++ b/httemplate/edit/process/svc_www.cgi @@ -1,36 +1,37 @@ -<% +% +% +%$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +%my $svcnum = $1; +% +%my $old; +%if ( $svcnum ) { +% $old = qsearchs('svc_www', { 'svcnum' => $svcnum } ) +% or die "fatal: can't find website (svcnum $svcnum)!"; +%} else { +% $old = ''; +%} +% +%my $new = new FS::svc_www ( { +% map { +% ($_, scalar($cgi->param($_))); +% #} qw(svcnum pkgnum svcpart recnum usersvc) +% } ( fields('svc_www'), qw( pkgnum svcpart ) ) +%} ); +% +%my $error; +%if ( $svcnum ) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $svcnum = $new->svcnum; +%} +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "svc_www.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/svc_www.cgi?" . $svcnum ); +%} +% +% -$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; -my $svcnum = $1; - -my $old; -if ( $svcnum ) { - $old = qsearchs('svc_www', { 'svcnum' => $svcnum } ) - or die "fatal: can't find website (svcnum $svcnum)!"; -} else { - $old = ''; -} - -my $new = new FS::svc_www ( { - map { - ($_, scalar($cgi->param($_))); - #} qw(svcnum pkgnum svcpart recnum usersvc) - } ( fields('svc_www'), qw( pkgnum svcpart ) ) -} ); - -my $error; -if ( $svcnum ) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $svcnum = $new->svcnum; -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "svc_www.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/svc_www.cgi?" . $svcnum ); -} - -%> diff --git a/httemplate/edit/rate.cgi b/httemplate/edit/rate.cgi index 9aa4e7291..72a04c339 100644 --- a/httemplate/edit/rate.cgi +++ b/httemplate/edit/rate.cgi @@ -1,40 +1,41 @@ -<% - -my $rate; -if ( $cgi->keywords ) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $rate = qsearchs( 'rate', { 'ratenum' => $1 } ); -} else { #adding - $rate = new FS::rate {}; -} -my $action = $rate->ratenum ? 'Edit' : 'Add'; - -my $p1 = popurl(1); - -my %granularity = ( - '1', => '1 second', - '6' => '6 second', - '30' => '30 second', # '1/2 minute', - '60' => 'minute', -); - -#my $nous = <<END; -# WHERE 0 < ( SELECT COUNT(*) FROM rate_prefix -# WHERE rate_region.regionnum = rate_prefix.regionnum -# AND countrycode != '1' -# ) -#END - -%> - -<%= include("/elements/header.html","$action Rate plan", menubar( +% +% +%my $rate; +%if ( $cgi->keywords ) { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $rate = qsearchs( 'rate', { 'ratenum' => $1 } ); +%} else { #adding +% $rate = new FS::rate {}; +%} +%my $action = $rate->ratenum ? 'Edit' : 'Add'; +% +%my $p1 = popurl(1); +% +%my %granularity = ( +% '1', => '1 second', +% '6' => '6 second', +% '30' => '30 second', # '1/2 minute', +% '60' => 'minute', +%); +% +%#my $nous = <<END; +%# WHERE 0 < ( SELECT COUNT(*) FROM rate_prefix +%# WHERE rate_region.regionnum = rate_prefix.regionnum +%# AND countrycode != '1' +%# ) +%#END +% +% + + +<% include("/elements/header.html","$action Rate plan", menubar( 'Main Menu' => $p, 'View all rate plans' => "${p}browse/rate.cgi", )) %> -<%= include('/elements/progress-init.html', +<% include('/elements/progress-init.html', 'OneTrueForm', [ 'rate', 'min_', 'sec_' ], 'process/rate.cgi', @@ -42,13 +43,13 @@ my %granularity = ( ) %> <FORM NAME="OneTrueForm"> -<INPUT TYPE="hidden" NAME="ratenum" VALUE="<%= $rate->ratenum %>"> +<INPUT TYPE="hidden" NAME="ratenum" VALUE="<% $rate->ratenum %>"> Rate plan -<INPUT TYPE="text" NAME="ratename" SIZE=32 VALUE="<%= $rate->ratename %>"> +<INPUT TYPE="text" NAME="ratename" SIZE=32 VALUE="<% $rate->ratename %>"> <BR><BR> -<%= table() %> +<% table() %> <TR> <TH>Region</TH> <TH>Prefix(es)</TH> @@ -56,54 +57,56 @@ Rate plan <TH><FONT SIZE=-1>Charge per<BR>minute</FONT></TH> <TH><FONT SIZE=-1>Granularity</FONT></TH> </TR> +% foreach my $rate_region ( +% sort { lc($a->regionname) cmp lc($b->regionname) } +% qsearch({ +% 'select' => 'DISTINCT ON ( regionnum ) rate_region.*', +% 'table' => 'rate_region', +% 'hashref' => {}, +% #'addl_from' => 'INNER JOIN rate_prefix USING ( regionnum )', +% #'extra_sql' => "WHERE countrycode != '1'", +% +% # 'ORDER BY regionname' +% # ERROR: SELECT DISTINCT ON expressions must +% # match initial ORDER BY expressions +% }) +% ) { +% my $n = $rate_region->regionnum; +% my $rate_detail = +% $rate->dest_detail($rate_region) +% || new FS::rate_detail { 'min_included' => 0, +% 'min_charge' => 0, +% 'sec_granularity' => '60' +% }; +% -<% foreach my $rate_region ( - sort { lc($a->regionname) cmp lc($b->regionname) } - qsearch({ - 'select' => 'DISTINCT ON ( regionnum ) rate_region.*', - 'table' => 'rate_region', - 'hashref' => {}, - #'addl_from' => 'INNER JOIN rate_prefix USING ( regionnum )', - #'extra_sql' => "WHERE countrycode != '1'", - - # 'ORDER BY regionname' - # ERROR: SELECT DISTINCT ON expressions must - # match initial ORDER BY expressions - }) - ) { - my $n = $rate_region->regionnum; - my $rate_detail = - $rate->dest_detail($rate_region) - || new FS::rate_detail { 'min_included' => 0, - 'min_charge' => 0, - 'sec_granularity' => '60' - }; -%> <TR> - <TD><A HREF="<%=$p%>edit/rate_region.cgi?<%= $rate_region->regionnum %>"><%= $rate_region->regionname %></A></TD> - <TD><%= $rate_region->prefixes_short %></TD> - <TD><INPUT TYPE="text" SIZE=5 NAME="min_included<%=$n%>" VALUE="<%= $cgi->param("min_included$n") || $rate_detail->min_included %>"></TD> - <TD>$<INPUT TYPE="text" SIZE=4 NAME="min_charge<%=$n%>" VALUE="<%= sprintf('%.2f', $cgi->param("min_charge$n") || $rate_detail->min_charge ) %>"></TD> + <TD><A HREF="<%$p%>edit/rate_region.cgi?<% $rate_region->regionnum %>"><% $rate_region->regionname %></A></TD> + <TD><% $rate_region->prefixes_short %></TD> + <TD><INPUT TYPE="text" SIZE=5 NAME="min_included<%$n%>" VALUE="<% $cgi->param("min_included$n") || $rate_detail->min_included %>"></TD> + <TD>$<INPUT TYPE="text" SIZE=4 NAME="min_charge<%$n%>" VALUE="<% sprintf('%.2f', $cgi->param("min_charge$n") || $rate_detail->min_charge ) %>"></TD> <TD> - <SELECT NAME="sec_granularity<%=$n%>"> - <% foreach my $granularity ( keys %granularity ) { %> - <OPTION VALUE="<%=$granularity%>"<%= $granularity == ( $cgi->param("sec_granularity$n") || $rate_detail->sec_granularity ) ? ' SELECTED' : '' %>><%=$granularity{$granularity}%> - <% } %> + <SELECT NAME="sec_granularity<%$n%>"> +% foreach my $granularity ( keys %granularity ) { + + <OPTION VALUE="<%$granularity%>"<% $granularity == ( $cgi->param("sec_granularity$n") || $rate_detail->sec_granularity ) ? ' SELECTED' : '' %>><%$granularity{$granularity}%> +% } + </SELECT> </TR> +% } -<% } %> <TR> <TD COLSPAN=5 ALIGN="center"> - <A HREF="<%=$p%>edit/rate_region.cgi"><I>Add a region</I></A> + <A HREF="<%$p%>edit/rate_region.cgi"><I>Add a region</I></A> </TD> </TR> </TABLE> -<BR><INPUT NAME="submit" TYPE="button" VALUE="<%= +<BR><INPUT NAME="submit" TYPE="button" VALUE="<% $rate->ratenum ? "Apply changes" : "Add rate plan" %>" onClick="document.OneTrueForm.submit.disabled=true; process();"> diff --git a/httemplate/edit/rate_region.cgi b/httemplate/edit/rate_region.cgi index 934fe8035..12cb180de 100644 --- a/httemplate/edit/rate_region.cgi +++ b/httemplate/edit/rate_region.cgi @@ -1,109 +1,114 @@ <!-- mason kludge --> -<% - -my $rate_region; -if ( $cgi->param('error') ) { - $rate_region = new FS::rate_region ( { - map { $_, scalar($cgi->param($_)) } fields('rate_region') - } ); -} elsif ( $cgi->keywords ) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $rate_region = qsearchs( 'rate_region', { 'regionnum' => $1 } ); -} else { #adding - $rate_region = new FS::rate_region {}; -} -my $action = $rate_region->regionnum ? 'Edit' : 'Add'; - -my $p1 = popurl(1); - -my %granularity = ( - '6' => '6 second', - '60' => 'minute', -); - -my @rate_prefix = $rate_region->rate_prefix; -my $countrycode = ''; -if ( @rate_prefix ) { - $countrycode = $rate_prefix[0]->countrycode; - foreach my $rate_prefix ( @rate_prefix ) { - eidiot 'multiple country codes per region not yet supported by web UI' - unless $rate_prefix->countrycode eq $countrycode; - } -} - -%> - -<%= include("/elements/header.html","$action Region", menubar( +% +% +%my $rate_region; +%if ( $cgi->param('error') ) { +% $rate_region = new FS::rate_region ( { +% map { $_, scalar($cgi->param($_)) } fields('rate_region') +% } ); +%} elsif ( $cgi->keywords ) { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $rate_region = qsearchs( 'rate_region', { 'regionnum' => $1 } ); +%} else { #adding +% $rate_region = new FS::rate_region {}; +%} +%my $action = $rate_region->regionnum ? 'Edit' : 'Add'; +% +%my $p1 = popurl(1); +% +%my %granularity = ( +% '6' => '6 second', +% '60' => 'minute', +%); +% +%my @rate_prefix = $rate_region->rate_prefix; +%my $countrycode = ''; +%if ( @rate_prefix ) { +% $countrycode = $rate_prefix[0]->countrycode; +% foreach my $rate_prefix ( @rate_prefix ) { +% eidiot 'multiple country codes per region not yet supported by web UI' +% unless $rate_prefix->countrycode eq $countrycode; +% } +%} +% +% + + +<% include("/elements/header.html","$action Region", menubar( 'Main Menu' => $p, #'View all regions' => "${p}browse/rate_region.cgi", )) %> +% if ( $cgi->param('error') ) { -<% if ( $cgi->param('error') ) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT><BR> -<% } %> +<FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT><BR> +% } -<FORM ACTION="<%=$p1%>process/rate_region.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="regionnum" VALUE="<%= $rate_region->regionnum %>"> +<FORM ACTION="<%$p1%>process/rate_region.cgi" METHOD=POST> -<%= ntable('#cccccc') %> +<INPUT TYPE="hidden" NAME="regionnum" VALUE="<% $rate_region->regionnum %>"> + +<% ntable('#cccccc') %> <TR> <TH ALIGN="right">Region name</TH> - <TD><INPUT TYPE="text" NAME="regionname" SIZE=32 VALUE="<%= $rate_region->regionname %>"></TR> + <TD><INPUT TYPE="text" NAME="regionname" SIZE=32 VALUE="<% $rate_region->regionname %>"></TR> </TR> <TR> <TH ALIGN="right">Country code</TH> - <TD><INPUT TYPE="text" NAME="countrycode" SIZE=4 MAXLENGTH=3 VALUE="<%= $countrycode %>"></TR> + <TD><INPUT TYPE="text" NAME="countrycode" SIZE=4 MAXLENGTH=3 VALUE="<% $countrycode %>"></TR> </TR> <TR> <TH ALIGN="right">Prefixes</TH> <TD> - <TEXTAREA NAME="npa" WRAP=SOFT><%= join(', ', map $_->npa, @rate_prefix ) %></TEXTAREA> + <TEXTAREA NAME="npa" WRAP=SOFT><% join(', ', map $_->npa, @rate_prefix ) %></TEXTAREA> </TD> </TR> </TABLE> <BR> -<%= table() %> +<% table() %> <TR> <TH>Rate plan</TH> <TH><FONT SIZE=-1>Included<BR>minutes</FONT></TH> <TH><FONT SIZE=-1>Charge per<BR>minute</FONT></TH> <TH><FONT SIZE=-1>Granularity</FONT></TH> </TR> +% foreach my $rate ( qsearch('rate', {}) ) { +% +% my $n = $rate->ratenum; +% my $rate_detail = $rate->dest_detail($rate_region) +% || new FS::rate_region { 'min_included' => 0, +% 'min_charge' => 0, +% 'sec_granularity' => '60' +% }; +% +% -<% foreach my $rate ( qsearch('rate', {}) ) { - - my $n = $rate->ratenum; - my $rate_detail = $rate->dest_detail($rate_region) - || new FS::rate_region { 'min_included' => 0, - 'min_charge' => 0, - 'sec_granularity' => '60' - }; - -%> <TR> - <TD><A HREF="<%=$p%>edit/rate.cgi?<%= $rate->ratenum %>"><%= $rate->ratename %></TD> - <TD><INPUT TYPE="text" SIZE=5 NAME="min_included<%=$n%>" VALUE="<%= $cgi->param("min_included$n") || $rate_detail->min_included %>"></TD> - <TD>$<INPUT TYPE="text" SIZE=4 NAME="min_charge<%=$n%>" VALUE="<%= sprintf('%.2f', $cgi->param("min_charge$n") || $rate_detail->min_charge ) %>"></TD> + <TD><A HREF="<%$p%>edit/rate.cgi?<% $rate->ratenum %>"><% $rate->ratename %></TD> + <TD><INPUT TYPE="text" SIZE=5 NAME="min_included<%$n%>" VALUE="<% $cgi->param("min_included$n") || $rate_detail->min_included %>"></TD> + <TD>$<INPUT TYPE="text" SIZE=4 NAME="min_charge<%$n%>" VALUE="<% sprintf('%.2f', $cgi->param("min_charge$n") || $rate_detail->min_charge ) %>"></TD> <TD> - <SELECT NAME="sec_granularity<%=$n%>"> - <% foreach my $granularity ( keys %granularity ) { %> - <OPTION VALUE="<%=$granularity%>"<%= $granularity == ( $cgi->param("sec_granularity$n") || $rate_detail->sec_granularity ) ? ' SELECTED' : '' %>><%=$granularity{$granularity}%> - <% } %> + <SELECT NAME="sec_granularity<%$n%>"> +% foreach my $granularity ( keys %granularity ) { + + <OPTION VALUE="<%$granularity%>"<% $granularity == ( $cgi->param("sec_granularity$n") || $rate_detail->sec_granularity ) ? ' SELECTED' : '' %>><%$granularity{$granularity}%> +% } + </SELECT> </TR> -<% } %> +% } + </TABLE> -<BR><BR><INPUT TYPE="submit" VALUE="<%= +<BR><BR><INPUT TYPE="submit" VALUE="<% $rate_region->regionnum ? "Apply changes" : "Add region" %>"> diff --git a/httemplate/edit/reg_code.cgi b/httemplate/edit/reg_code.cgi index 2fba39e00..06bef4879 100644 --- a/httemplate/edit/reg_code.cgi +++ b/httemplate/edit/reg_code.cgi @@ -1,33 +1,36 @@ -<% -my $agentnum = $cgi->param('agentnum'); -$agentnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum"; -$agentnum = $1; -my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); +% +%my $agentnum = $cgi->param('agentnum'); +%$agentnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum"; +%$agentnum = $1; +%my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); +% +% -%> -<%= include("/elements/header.html",'Generate registration codes for '. $agent->agent, menubar( +<% include("/elements/header.html",'Generate registration codes for '. $agent->agent, menubar( 'Main Menu' => $p, )) %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#FF0000">Error: <% $cgi->param('error') %></FONT> +% } -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#FF0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> -<FORM ACTION="<%=popurl(1)%>process/reg_code.cgi" METHOD="POST" NAME="OneTrueForm" onSubmit="document.OneTrueForm.submit.disabled=true"> -<INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agent->agentnum %>"> +<FORM ACTION="<%popurl(1)%>process/reg_code.cgi" METHOD="POST" NAME="OneTrueForm" onSubmit="document.OneTrueForm.submit.disabled=true"> +<INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agent->agentnum %>"> Generate -<INPUT TYPE="text" NAME="num" VALUE="<%= $cgi->param('num') %>" SIZE=5 MAXLENGTH=4> -registration codes for <B><%= $agent->agent %></B> allowing the following packages: +<INPUT TYPE="text" NAME="num" VALUE="<% $cgi->param('num') %>" SIZE=5 MAXLENGTH=4> +registration codes for <B><% $agent->agent %></B> allowing the following packages: <BR><BR> +% foreach my $part_pkg ( qsearch('part_pkg', { 'disabled' => '' } ) ) { -<% foreach my $part_pkg ( qsearch('part_pkg', { 'disabled' => '' } ) ) { %> - <INPUT TYPE="checkbox" NAME="pkgpart<%= $part_pkg->pkgpart %>"> - <%= $part_pkg->pkg %> - <%= $part_pkg->comment %> + <INPUT TYPE="checkbox" NAME="pkgpart<% $part_pkg->pkgpart %>"> + <% $part_pkg->pkg %> - <% $part_pkg->comment %> <BR> -<% } %> +% } + <BR> <INPUT TYPE="submit" NAME="submit" VALUE="Generate"> diff --git a/httemplate/edit/router.cgi b/httemplate/edit/router.cgi index a573c6504..0da45c00e 100755 --- a/httemplate/edit/router.cgi +++ b/httemplate/edit/router.cgi @@ -1,75 +1,76 @@ <HTML><BODY> - -<% - -my $router; -if ( $cgi->keywords ) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $router = qsearchs('router', { routernum => $1 }) - or print $cgi->redirect(popurl(2)."browse/router.cgi") ; -} else { - $router = new FS::router ( { - map { $_, scalar($cgi->param($_)) } fields('router') - } ); -} - -my $routernum = $router->routernum; -my $action = $routernum ? 'Edit' : 'Add'; - -print header("$action Router", menubar( - 'Main Menu' => "$p", - 'View all routers' => "${p}browse/router.cgi", -)); - -my $p3 = popurl(3); - -if($cgi->param('error')) { -%> <FONT SIZE="+1" COLOR="#ff0000">Error: <%=$cgi->param('error')%></FONT> -<% } %> - -<FORM ACTION="<%=popurl(1)%>process/router.cgi" METHOD=POST> +% +% +%my $router; +%if ( $cgi->keywords ) { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% $router = qsearchs('router', { routernum => $1 }) +% or print $cgi->redirect(popurl(2)."browse/router.cgi") ; +%} else { +% $router = new FS::router ( { +% map { $_, scalar($cgi->param($_)) } fields('router') +% } ); +%} +% +%my $routernum = $router->routernum; +%my $action = $routernum ? 'Edit' : 'Add'; +% +%print header("$action Router", menubar( +% 'Main Menu' => "$p", +% 'View all routers' => "${p}browse/router.cgi", +%)); +% +%my $p3 = popurl(3); +% +%if($cgi->param('error')) { +% + <FONT SIZE="+1" COLOR="#ff0000">Error: <%$cgi->param('error')%></FONT> +% } + + +<FORM ACTION="<%popurl(1)%>process/router.cgi" METHOD=POST> <INPUT TYPE="hidden" NAME="table" VALUE="router"> - <INPUT TYPE="hidden" NAME="redirect_ok" VALUE="<%=$p3%>/browse/router.cgi"> - <INPUT TYPE="hidden" NAME="redirect_error" VALUE="<%=$p3%>/edit/router.cgi"> - <INPUT TYPE="hidden" NAME="routernum" VALUE="<%=$routernum%>"> - <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%=$router->svcnum%>"> - Router #<%=$routernum or "(NEW)"%> + <INPUT TYPE="hidden" NAME="redirect_ok" VALUE="<%$p3%>/browse/router.cgi"> + <INPUT TYPE="hidden" NAME="redirect_error" VALUE="<%$p3%>/edit/router.cgi"> + <INPUT TYPE="hidden" NAME="routernum" VALUE="<%$routernum%>"> + <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$router->svcnum%>"> + Router #<%$routernum or "(NEW)"%> -<BR><BR>Name <INPUT TYPE="text" NAME="routername" SIZE=32 VALUE="<%=$router->routername%>"> +<BR><BR>Name <INPUT TYPE="text" NAME="routername" SIZE=32 VALUE="<%$router->routername%>"> <BR><BR> Custom fields: <BR> -<%=table() %> +<%table() %> +% +%foreach my $field ($router->virtual_fields) { +% print $router->pvf($field)->widget('HTML', 'edit', +% $router->getfield($field)); +%} +% -<% -foreach my $field ($router->virtual_fields) { - print $router->pvf($field)->widget('HTML', 'edit', - $router->getfield($field)); -} -%> </TABLE> +% +%unless ($router->svcnum) { +% - -<% -unless ($router->svcnum) { -%> <BR><BR>Select the service types available on this router<BR> -<% +% +% +% foreach my $part_svc ( qsearch('part_svc', { svcdb => 'svc_broadband', +% disabled => '' }) ) { +% - foreach my $part_svc ( qsearch('part_svc', { svcdb => 'svc_broadband', - disabled => '' }) ) { - %> <BR> - <INPUT TYPE="checkbox" NAME="svcpart_<%=$part_svc->svcpart%>"<%= + <INPUT TYPE="checkbox" NAME="svcpart_<%$part_svc->svcpart%>"<% qsearchs('part_svc_router', { svcpart => $part_svc->svcpart, routernum => $routernum } ) ? ' CHECKED' : ''%> VALUE="ON"> - <A HREF="<%=${p}%>edit/part_svc.cgi?<%=$part_svc->svcpart%>"> - <%=$part_svc->svcpart%>: <%=$part_svc->svc%></A> - <% } %> + <A HREF="<%${p}%>edit/part_svc.cgi?<%$part_svc->svcpart%>"> + <%$part_svc->svcpart%>: <%$part_svc->svc%></A> +% } +% } -<% } %> <BR><BR><INPUT TYPE="submit" VALUE="Apply changes"> </FORM> diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 71b324d99..60ca24d3e 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -1,446 +1,424 @@ -<% - -my $conf = new FS::Conf; -my @shells = $conf->config('shells'); - -my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups); -if ( $cgi->param('error') ) { - - $svc_acct = new FS::svc_acct ( { - map { $_, scalar($cgi->param($_)) } fields('svc_acct') - } ); - $svcnum = $svc_acct->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $cgi->param('svcpart'); - $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); - die "No part_svc entry for svcpart $svcpart!" unless $part_svc; - @groups = $cgi->param('radius_usergroup'); - -} else { - - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum}) - or die "Unknown (svc_acct) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); - die "No part_svc entry for svcpart $svcpart!" unless $part_svc; - - @groups = $svc_acct->radius_groups; - - } else { #adding - - foreach $_ (split(/-/,$query)) { - $pkgnum=$1 if /^pkgnum(\d+)$/; - $svcpart=$1 if /^svcpart(\d+)$/; - } - $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); - die "No part_svc entry for svcpart $svcpart!" unless $part_svc; - - $svc_acct = new FS::svc_acct({svcpart => $svcpart}); - - $svcnum=''; - - } -} - -my( $cust_pkg, $cust_main ) = ( '', '' ); -if ( $pkgnum ) { - $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } ); - $cust_main = $cust_pkg->cust_main; -} - -unless ( $svcnum || $cgi->param('error') ) { #adding - - #set gecos - if ($cust_main) { - unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) { - $svc_acct->setfield('finger', - $cust_main->getfield('first') . " " . $cust_main->getfield('last') - ); - } - } - - $svc_acct->set_default_and_fixed( { - #false laziness w/svc-acct::_fieldhandlers - 'usergroup' => sub { - my( $self, $groups ) = @_; - if ( ref($groups) eq 'ARRAY' ) { - @groups = @$groups; - $groups; - } elsif ( length($groups) ) { - @groups = split(/\s*,\s*/, $groups); - [ @groups ]; - } else { - @groups = (); - []; - } - } - } ); - -} - -#fixed radius groups always override & display -if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) { - @groups = split(',', $part_svc->part_svc_column('usergroup')->columnvalue); -} - -my $action = $svcnum ? 'Edit' : 'Add'; - -my $svc = $part_svc->getfield('svc'); - -my $otaker = getotaker; - -my $username = $svc_acct->username; -my $password; -if ( $svc_acct->_password ) { - if ( $conf->exists('showpasswords') || ! $svcnum ) { - $password = $svc_acct->_password; - } else { - $password = "*HIDDEN*"; - } -} else { - $password = ''; -} - -my $ulen = - $conf->exists('usernamemax') - ? $conf->config('usernamemax') - : dbdef->table('svc_acct')->column('username')->length; -my $ulen2 = $ulen+2; - -my $pmax = $conf->config('passwordmax') || 8; -my $pmax2 = $pmax+2; - -my $p1 = popurl(1); - -%> - -<%= include("/elements/header.html","$action $svc account") %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> +% +% +%my $conf = new FS::Conf; +%my @shells = $conf->config('shells'); +% +%my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups); +%if ( $cgi->param('error') ) { +% +% $svc_acct = new FS::svc_acct ( { +% map { $_, scalar($cgi->param($_)) } fields('svc_acct') +% } ); +% $svcnum = $svc_acct->svcnum; +% $pkgnum = $cgi->param('pkgnum'); +% $svcpart = $cgi->param('svcpart'); +% $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); +% die "No part_svc entry for svcpart $svcpart!" unless $part_svc; +% @groups = $cgi->param('radius_usergroup'); +% +%} else { +% +% my($query) = $cgi->keywords; +% if ( $query =~ /^(\d+)$/ ) { #editing +% $svcnum=$1; +% $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum}) +% or die "Unknown (svc_acct) svcnum!"; +% +% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) +% or die "Unknown (cust_svc) svcnum!"; +% +% $pkgnum=$cust_svc->pkgnum; +% $svcpart=$cust_svc->svcpart; +% +% $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); +% die "No part_svc entry for svcpart $svcpart!" unless $part_svc; +% +% @groups = $svc_acct->radius_groups; +% +% } else { #adding +% +% foreach $_ (split(/-/,$query)) { +% $pkgnum=$1 if /^pkgnum(\d+)$/; +% $svcpart=$1 if /^svcpart(\d+)$/; +% } +% $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); +% die "No part_svc entry for svcpart $svcpart!" unless $part_svc; +% +% $svc_acct = new FS::svc_acct({svcpart => $svcpart}); +% +% $svcnum=''; +% +% } +%} +% +%my( $cust_pkg, $cust_main ) = ( '', '' ); +%if ( $pkgnum ) { +% $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } ); +% $cust_main = $cust_pkg->cust_main; +%} +% +%unless ( $svcnum || $cgi->param('error') ) { #adding +% +% #set gecos +% if ($cust_main) { +% unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) { +% $svc_acct->setfield('finger', +% $cust_main->getfield('first') . " " . $cust_main->getfield('last') +% ); +% } +% } +% +% $svc_acct->set_default_and_fixed( { +% #false laziness w/svc-acct::_fieldhandlers +% 'usergroup' => sub { +% my( $self, $groups ) = @_; +% if ( ref($groups) eq 'ARRAY' ) { +% @groups = @$groups; +% $groups; +% } elsif ( length($groups) ) { +% @groups = split(/\s*,\s*/, $groups); +% [ @groups ]; +% } else { +% @groups = (); +% []; +% } +% } +% } ); +% +%} +% +%#fixed radius groups always override & display +%if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) { +% @groups = split(',', $part_svc->part_svc_column('usergroup')->columnvalue); +%} +% +%my $action = $svcnum ? 'Edit' : 'Add'; +% +%my $svc = $part_svc->getfield('svc'); +% +%my $otaker = getotaker; +% +%my $username = $svc_acct->username; +%my $password; +%if ( $svc_acct->_password ) { +% if ( $conf->exists('showpasswords') || ! $svcnum ) { +% $password = $svc_acct->_password; +% } else { +% $password = "*HIDDEN*"; +% } +%} else { +% $password = ''; +%} +% +%my $ulen = +% $conf->exists('usernamemax') +% ? $conf->config('usernamemax') +% : dbdef->table('svc_acct')->column('username')->length; +%my $ulen2 = $ulen+2; +% +%my $pmax = $conf->config('passwordmax') || 8; +%my $pmax2 = $pmax+2; +% +%my $p1 = popurl(1); +% +% + + +<% include("/elements/header.html","$action $svc account") %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> +% } +% if ( $cust_main ) { -<% if ( $cust_main ) { %> - <%= include( '/elements/small_custview.html', $cust_main, '', 1 ) %> + <% include( '/elements/small_custview.html', $cust_main, '', 1 ) %> <BR> -<% } %> +% } -<FORM NAME="OneTrueForm" ACTION="<%= $p1 %>process/svc_acct.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%= $svcnum %>"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> -<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>"> -Service # <%= $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR> +<FORM NAME="OneTrueForm" ACTION="<% $p1 %>process/svc_acct.cgi" METHOD=POST> +<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>"> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>"> +<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>"> -<%= ntable("#cccccc",2) %> +Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR> + +<% ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Service</TD> - <TD BGCOLOR="#eeeeee"><%= $part_svc->svc %></TD> + <TD BGCOLOR="#eeeeee"><% $part_svc->svc %></TD> </TR> <TR> <TD ALIGN="right">Username</TD> <TD> - <INPUT TYPE="text" NAME="username" VALUE="<%= $username %>" SIZE=<%= $ulen2 %> MAXLENGTH=<%= $ulen %>> + <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>> </TD> </TR> <TR> <TD ALIGN="right">Password</TD> <TD> - <INPUT TYPE="text" NAME="_password" VALUE="<%= $password %>" SIZE=<%= $pmax2 %> MAXLENGTH=<%= $pmax %>> + <INPUT TYPE="text" NAME="_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $pmax %>> (blank to generate) </TD> </TR> +% +%my $sec_phrase = $svc_acct->sec_phrase; +%if ( $conf->exists('security_phrase') ) { +% -<% -my $sec_phrase = $svc_acct->sec_phrase; -if ( $conf->exists('security_phrase') ) { -%> - <TR> <TD ALIGN="right">Security phrase</TD> <TD> - <INPUT TYPE="text" NAME="sec_phrase" VALUE="<%= $sec_phrase %>" SIZE=32> + <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32> (for forgotten passwords) </TD> </TD> +% } else { + + + <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<% $sec_phrase %>"> +% } +% +%#domain +%my $domsvc = $svc_acct->domsvc || 0; +%if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) { +% + + + <INPUT TYPE="hidden" NAME="domsvc" VALUE="<% $domsvc %>"> +% } else { +% +% my %svc_domain = (); +% +% if ( $domsvc ) { +% my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } ); +% if ( $svc_domain ) { +% $svc_domain{$svc_domain->svcnum} = $svc_domain; +% } else { +% warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc"; +% } +% } +% +% if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'D' ) { +% my $svc_domain = qsearchs('svc_domain', { +% 'svcnum' => $part_svc->part_svc_column('domsvc')->columnvalue, +% } ); +% if ( $svc_domain ) { +% $svc_domain{$svc_domain->svcnum} = $svc_domain; +% } else { +% warn "unknown svc_domain.svcnum for part_svc_column domsvc: ". +% $part_svc->part_svc_column('domsvc')->columnvalue; +% } +% } +% +% if ($cust_pkg && !$conf->exists('svc_acct-alldomains') ) { +% my @cust_svc = +% map { qsearch('cust_svc', { 'pkgnum' => $_->pkgnum } ) } +% qsearch('cust_pkg', { 'custnum' => $cust_pkg->custnum } ); +% foreach my $cust_svc ( @cust_svc ) { +% my $svc_domain = +% qsearchs('svc_domain', { 'svcnum' => $cust_svc->svcnum } ); +% $svc_domain{$svc_domain->svcnum} = $svc_domain if $svc_domain; +% } +% } else { +% %svc_domain = map { $_->svcnum => $_ } qsearch('svc_domain', {} ); +% } +% +% -<% } else { %> - - <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<%= $sec_phrase %>"> - -<% } %> - - -<% -#domain -my $domsvc = $svc_acct->domsvc || 0; -if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) { -%> - - <INPUT TYPE="hidden" NAME="domsvc" VALUE="<%= $domsvc %>"> - -<% } else { - - my %svc_domain = (); - - if ( $domsvc ) { - my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } ); - if ( $svc_domain ) { - $svc_domain{$svc_domain->svcnum} = $svc_domain; - } else { - warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc"; - } - } - - if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'D' ) { - my $svc_domain = qsearchs('svc_domain', { - 'svcnum' => $part_svc->part_svc_column('domsvc')->columnvalue, - } ); - if ( $svc_domain ) { - $svc_domain{$svc_domain->svcnum} = $svc_domain; - } else { - warn "unknown svc_domain.svcnum for part_svc_column domsvc: ". - $part_svc->part_svc_column('domsvc')->columnvalue; - } - } - - if ($cust_pkg && !$conf->exists('svc_acct-alldomains') ) { - my @cust_svc = - map { qsearch('cust_svc', { 'pkgnum' => $_->pkgnum } ) } - qsearch('cust_pkg', { 'custnum' => $cust_pkg->custnum } ); - foreach my $cust_svc ( @cust_svc ) { - my $svc_domain = - qsearchs('svc_domain', { 'svcnum' => $cust_svc->svcnum } ); - $svc_domain{$svc_domain->svcnum} = $svc_domain if $svc_domain; - } - } else { - %svc_domain = map { $_->svcnum => $_ } qsearch('svc_domain', {} ); - } - -%> <TR> <TD ALIGN="right">Domain</TD> <TD> <SELECT NAME="domsvc" SIZE=1> +% foreach my $svcnum ( +% sort { $svc_domain{$a}->domain cmp $svc_domain{$b}->domain } +% keys %svc_domain +% ) { +% my $svc_domain = $svc_domain{$svcnum}; +% - <% foreach my $svcnum ( - sort { $svc_domain{$a}->domain cmp $svc_domain{$b}->domain } - keys %svc_domain - ) { - my $svc_domain = $svc_domain{$svcnum}; - %> - <OPTION VALUE="<%= $svc_domain->svcnum %>" <%= $svc_domain->svcnum == $domsvc ? ' SELECTED' : '' %>><%= $svc_domain->domain %> + <OPTION VALUE="<% $svc_domain->svcnum %>" <% $svc_domain->svcnum == $domsvc ? ' SELECTED' : '' %>><% $svc_domain->domain %> +% } - <% } %> </SELECT> </TD> </TR> +% } +% +%#pop +%my $popnum = $svc_acct->popnum || 0; +%if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) { +% -<% } %> - - -<% -#pop -my $popnum = $svc_acct->popnum || 0; -if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) { -%> - <INPUT TYPE="hidden" NAME="popnum" VALUE="<%= $popnum %>"> + <INPUT TYPE="hidden" NAME="popnum" VALUE="<% $popnum %>"> +% } else { -<% } else { %> - <TR> <TD ALIGN="right">Access number</TD> - <TD><%= FS::svc_acct_pop::popselector($popnum) %></TD> + <TD><% FS::svc_acct_pop::popselector($popnum) %></TD> </TR> +% } +% #uid/gid +% foreach my $xid (qw( uid gid )) { +% +% if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/ +% || ! $conf->exists("svc_acct-edit_$xid") +% ) { +% +% if ( length($svc_acct->$xid()) ) { -<% } %> - - -<% #uid/gid %> -<% foreach my $xid (qw( uid gid )) { %> - - <% - if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/ - || ! $conf->exists("svc_acct-edit_$xid") - ) { - %> - - <% if ( length($svc_acct->$xid()) ) { %> <TR> - <TD ALIGN="right"><%= uc($xid) %></TD> - <TD BGCOLOR="#eeeeee"><%= $svc_acct->$xid() %></TD> + <TD ALIGN="right"><% uc($xid) %></TD> + <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD> <TD> </TD> </TR> +% } + - <% } %> - - <INPUT TYPE="hidden" NAME="<%= $xid %>" VALUE="<%= $svc_acct->$xid() %>"> - - <% } else { %> + <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>"> +% } else { + <TR> - <TD ALIGN="right"><%= uc($xid) %></TD> + <TD ALIGN="right"><% uc($xid) %></TD> <TD> - <INPUT TYPE="text" NAME="<%= $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<%= $svc_acct->$xid() %>"> + <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>"> </TD> </TR> - - <% } %> +% } +% } +% +%#finger +%if ( $part_svc->part_svc_column('uid')->columnflag eq 'F' +% && ! $svc_acct->finger ) { +% -<% } %> - - -<% -#finger -if ( $part_svc->part_svc_column('uid')->columnflag eq 'F' - && ! $svc_acct->finger ) { -%> <INPUT TYPE="hidden" NAME="finger" VALUE=""> +% } else { -<% } else { %> <TR> <TD ALIGN="right">GECOS</TD> <TD> - <INPUT TYPE="text" NAME="finger" VALUE="<%= $svc_acct->finger %>"> + <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>"> </TD> </TR> +% } -<% } %> -<INPUT TYPE="hidden" NAME="dir" VALUE="<%= $svc_acct->dir %>"> +<INPUT TYPE="hidden" NAME="dir" VALUE="<% $svc_acct->dir %>"> +% +%#shell +%my $shell = $svc_acct->shell; +%if ( $part_svc->part_svc_column('shell')->columnflag eq 'F' +% || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' ) +% ) { +% -<% -#shell -my $shell = $svc_acct->shell; -if ( $part_svc->part_svc_column('shell')->columnflag eq 'F' - || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' ) - ) { -%> + <INPUT TYPE="hidden" NAME="shell" VALUE="<% $shell %>"> +% } else { - <INPUT TYPE="hidden" NAME="shell" VALUE="<%= $shell %>"> - -<% } else { %> <TR> <TD ALIGN="right">Shell</TD> <TD> <SELECT NAME="shell" SIZE=1> +% +% my($etc_shell); +% foreach $etc_shell (@shells) { +% - <% - my($etc_shell); - foreach $etc_shell (@shells) { - %> - <OPTION<%= $etc_shell eq $shell ? ' SELECTED' : '' %>><%= $etc_shell %> + <OPTION<% $etc_shell eq $shell ? ' SELECTED' : '' %>><% $etc_shell %> +% } - <% } %> </SELECT> </TD> </TR> - -<% } %> +% } +% if ( $part_svc->part_svc_column('quota')->columnflag eq 'F' ) { -<% if ( $part_svc->part_svc_column('quota')->columnflag eq 'F' ) { %> + <INPUT TYPE="hidden" NAME="quota" VALUE="<% $svc_acct->quota %>"> +% } else { - <INPUT TYPE="hidden" NAME="quota" VALUE="<%= $svc_acct->quota %>"> - -<% } else { %> <TR> <TD ALIGN="right">Quota:</TD> - <TD><INPUT TYPE="text" NAME="quota" VALUE="<%= $svc_acct->quota %>"></TD> + <TD><INPUT TYPE="text" NAME="quota" VALUE="<% $svc_acct->quota %>"></TD> </TR> - -<% } %> - +% } +% if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) { -<% if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) { %> - <INPUT TYPE="hidden" NAME="slipip" VALUE="<%= $svc_acct->slipip %>"> + <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>"> +% } else { -<% } else { %> <TR> <TD ALIGN="right">IP</TD> - <TD><INPUT TYPE="text" NAME="slipip" VALUE="<%= $svc_acct->slipip %>"></TD> + <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD> </TR> +% } +% +%foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) { +% $r =~ /^^r(adius|[cr])_(.+)$/ or next; #? +% my $a = $2; +% +% if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) { -<% } %> + <INPUT TYPE="hidden" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"> +% } else { -<% -foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) { - $r =~ /^^r(adius|[cr])_(.+)$/ or next; #? - my $a = $2; -%> - - <% if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) { %> - - <INPUT TYPE="hidden" NAME="<%= $r %>" VALUE="<%= $svc_acct->getfield($r) %>"> - - <% } else { %> <TR> - <TD ALIGN="right"><%= $FS::raddb::attrib{$a} %></TD> - <TD><INPUT TYPE="text" NAME="<%= $r %>" VALUE="<%= $svc_acct->getfield($r) %>"></TD> + <TD ALIGN="right"><% $FS::raddb::attrib{$a} %></TD> + <TD><INPUT TYPE="text" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"></TD> </TR> +% } +% } - <% } %> - -<% } %> <TR> <TD ALIGN="right">RADIUS groups</TD> +% if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) { - <% if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) { %> - <TD BGCOLOR="#eeeeee"><%= join('<BR>', @groups) %></TD> + <TD BGCOLOR="#eeeeee"><% join('<BR>', @groups) %></TD> +% } else { - <% } else { %> - <TD><%= FS::svc_acct::radius_usergroup_selector( \@groups ) %></TD> + <TD><% FS::svc_acct::radius_usergroup_selector( \@groups ) %></TD> +% } - <% } %> </TR> +% foreach my $field ($svc_acct->virtual_fields) { +% # If the flag is X, it won't even show up in $svc_acct->virtual_fields. +% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { -<% foreach my $field ($svc_acct->virtual_fields) { %> - - <% # If the flag is X, it won't even show up in $svc_acct->virtual_fields. %> - <% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { %> - - <%= $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %> - <% } %> + <% $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %> +% } +% } -<% } %> </TABLE> <BR> diff --git a/httemplate/edit/svc_acct_pop.cgi b/httemplate/edit/svc_acct_pop.cgi index 399502a70..641aa0378 100755 --- a/httemplate/edit/svc_acct_pop.cgi +++ b/httemplate/edit/svc_acct_pop.cgi @@ -1,56 +1,57 @@ <!-- mason kludge --> -<% +% +% +%my $svc_acct_pop; +%if ( $cgi->param('error') ) { +% $svc_acct_pop = new FS::svc_acct_pop ( { +% map { $_, scalar($cgi->param($_)) } fields('svc_acct_pop') +% } ); +%} elsif ( $cgi->keywords ) { #editing +% my($query)=$cgi->keywords; +% $query =~ /^(\d+)$/; +% $svc_acct_pop=qsearchs('svc_acct_pop',{'popnum'=>$1}); +%} else { #adding +% $svc_acct_pop = new FS::svc_acct_pop {}; +%} +%my $action = $svc_acct_pop->popnum ? 'Edit' : 'Add'; +%my $hashref = $svc_acct_pop->hashref; +% +%my $p1 = popurl(1); +%print header("$action Access Number", menubar( +% 'Main Menu' => popurl(2), +% 'View all Access Numbers' => popurl(2). "browse/svc_acct_pop.cgi", +%)); +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT>" +% if $cgi->param('error'); +% +%print qq!<FORM ACTION="${p1}process/svc_acct_pop.cgi" METHOD=POST>!; +% +%#display +% +%print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$hashref->{popnum}">!, +% "POP #", $hashref->{popnum} ? $hashref->{popnum} : "(NEW)"; +% +%print <<END; +%<PRE> +%City <INPUT TYPE="text" NAME="city" SIZE=32 VALUE="$hashref->{city}"> +%State <INPUT TYPE="text" NAME="state" SIZE=16 MAXLENGTH=16 VALUE="$hashref->{state}"> +%Area Code <INPUT TYPE="text" NAME="ac" SIZE=4 MAXLENGTH=3 VALUE="$hashref->{ac}"> +%Exchange <INPUT TYPE="text" NAME="exch" SIZE=4 MAXLENGTH=3 VALUE="$hashref->{exch}"> +%Local <INPUT TYPE="text" NAME="loc" SIZE=5 MAXLENGTH=4 VALUE="$hashref->{loc}"> +%</PRE> +%END +% +%print qq!<BR><INPUT TYPE="submit" VALUE="!, +% $hashref->{popnum} ? "Apply changes" : "Add Access Number", +% qq!">!; +% +%print <<END; +% </FORM> +% </BODY> +%</HTML> +%END +% +% -my $svc_acct_pop; -if ( $cgi->param('error') ) { - $svc_acct_pop = new FS::svc_acct_pop ( { - map { $_, scalar($cgi->param($_)) } fields('svc_acct_pop') - } ); -} elsif ( $cgi->keywords ) { #editing - my($query)=$cgi->keywords; - $query =~ /^(\d+)$/; - $svc_acct_pop=qsearchs('svc_acct_pop',{'popnum'=>$1}); -} else { #adding - $svc_acct_pop = new FS::svc_acct_pop {}; -} -my $action = $svc_acct_pop->popnum ? 'Edit' : 'Add'; -my $hashref = $svc_acct_pop->hashref; - -my $p1 = popurl(1); -print header("$action Access Number", menubar( - 'Main Menu' => popurl(2), - 'View all Access Numbers' => popurl(2). "browse/svc_acct_pop.cgi", -)); - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); - -print qq!<FORM ACTION="${p1}process/svc_acct_pop.cgi" METHOD=POST>!; - -#display - -print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$hashref->{popnum}">!, - "POP #", $hashref->{popnum} ? $hashref->{popnum} : "(NEW)"; - -print <<END; -<PRE> -City <INPUT TYPE="text" NAME="city" SIZE=32 VALUE="$hashref->{city}"> -State <INPUT TYPE="text" NAME="state" SIZE=16 MAXLENGTH=16 VALUE="$hashref->{state}"> -Area Code <INPUT TYPE="text" NAME="ac" SIZE=4 MAXLENGTH=3 VALUE="$hashref->{ac}"> -Exchange <INPUT TYPE="text" NAME="exch" SIZE=4 MAXLENGTH=3 VALUE="$hashref->{exch}"> -Local <INPUT TYPE="text" NAME="loc" SIZE=5 MAXLENGTH=4 VALUE="$hashref->{loc}"> -</PRE> -END - -print qq!<BR><INPUT TYPE="submit" VALUE="!, - $hashref->{popnum} ? "Apply changes" : "Add Access Number", - qq!">!; - -print <<END; - </FORM> - </BODY> -</HTML> -END - -%> diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index d66cff690..2668bf419 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -1,164 +1,178 @@ <!-- mason kludge --> -<% - -# If it's stupid but it works, it's still stupid. -# -Kristian - - -use HTML::Widgets::SelectLayers; -use Tie::IxHash; - -my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_broadband ); -if ( $cgi->param('error') ) { - $svc_broadband = new FS::svc_broadband ( { - map { $_, scalar($cgi->param($_)) } fields('svc_broadband'), qw(svcpart) - } ); - $svcnum = $svc_broadband->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $svc_broadband->svcpart; - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; -} else { - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_broadband=qsearchs('svc_broadband',{'svcnum'=>$svcnum}) - or die "Unknown (svc_broadband) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - } else { #adding - - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart - $pkgnum=$1 if /^pkgnum(\d+)$/; - $svcpart=$1 if /^svcpart(\d+)$/; - } - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - $svc_broadband = new FS::svc_broadband({ svcpart => $svcpart }); - - $svcnum=''; - - $svc_broadband->set_default_and_fixed; - - } -} -my $action = $svc_broadband->svcnum ? 'Edit' : 'Add'; - -if ($pkgnum) { - - #Nothing? - -} elsif ( $action eq 'Edit' ) { - - #Nothing? - -} else { - die "\$action eq Add, but \$pkgnum is null!\n"; -} - -my $p1 = popurl(1); - -my ($ip_addr, $speed_up, $speed_down, $blocknum) = - ($svc_broadband->ip_addr, - $svc_broadband->speed_up, - $svc_broadband->speed_down, - $svc_broadband->blocknum); - -%> - -<%=include("/elements/header.html","Broadband Service $action", '')%> - -<% if ($cgi->param('error')) { %> -<FONT SIZE="+1" COLOR="#ff0000">Error: <%=$cgi->param('error')%></FONT><BR> -<% } %> - -Service #<B><%=$svcnum ? $svcnum : "(NEW)"%></B><BR><BR> - -<FORM ACTION="<%=${p1}%>process/svc_broadband.cgi" METHOD=POST> - <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%=$svcnum%>"> - <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%=$pkgnum%>"> - <INPUT TYPE="hidden" NAME="svcpart" VALUE="<%=$svcpart%>"> - - <%=&ntable("#cccccc",2)%> +% +% +%# If it's stupid but it works, it's still stupid. +%# -Kristian +% +% +%use HTML::Widgets::SelectLayers; +%use Tie::IxHash; +% +%my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_broadband ); +%if ( $cgi->param('error') ) { +% $svc_broadband = new FS::svc_broadband ( { +% map { $_, scalar($cgi->param($_)) } fields('svc_broadband'), qw(svcpart) +% } ); +% $svcnum = $svc_broadband->svcnum; +% $pkgnum = $cgi->param('pkgnum'); +% $svcpart = $svc_broadband->svcpart; +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +%} else { +% my($query) = $cgi->keywords; +% if ( $query =~ /^(\d+)$/ ) { #editing +% $svcnum=$1; +% $svc_broadband=qsearchs('svc_broadband',{'svcnum'=>$svcnum}) +% or die "Unknown (svc_broadband) svcnum!"; +% +% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) +% or die "Unknown (cust_svc) svcnum!"; +% +% $pkgnum=$cust_svc->pkgnum; +% $svcpart=$cust_svc->svcpart; +% +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% } else { #adding +% +% foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart +% $pkgnum=$1 if /^pkgnum(\d+)$/; +% $svcpart=$1 if /^svcpart(\d+)$/; +% } +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% $svc_broadband = new FS::svc_broadband({ svcpart => $svcpart }); +% +% $svcnum=''; +% +% $svc_broadband->set_default_and_fixed; +% +% } +%} +%my $action = $svc_broadband->svcnum ? 'Edit' : 'Add'; +% +%if ($pkgnum) { +% +% #Nothing? +% +%} elsif ( $action eq 'Edit' ) { +% +% #Nothing? +% +%} else { +% die "\$action eq Add, but \$pkgnum is null!\n"; +%} +% +%my $p1 = popurl(1); +% +%my ($ip_addr, $speed_up, $speed_down, $blocknum) = +% ($svc_broadband->ip_addr, +% $svc_broadband->speed_up, +% $svc_broadband->speed_down, +% $svc_broadband->blocknum); +% +% + + +<%include("/elements/header.html","Broadband Service $action", '')%> +% if ($cgi->param('error')) { + +<FONT SIZE="+1" COLOR="#ff0000">Error: <%$cgi->param('error')%></FONT><BR> +% } + + +Service #<B><%$svcnum ? $svcnum : "(NEW)"%></B><BR><BR> + +<FORM ACTION="<%${p1}%>process/svc_broadband.cgi" METHOD=POST> + <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>"> + <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%$pkgnum%>"> + <INPUT TYPE="hidden" NAME="svcpart" VALUE="<%$svcpart%>"> + + <%&ntable("#cccccc",2)%> <TR> <TD ALIGN="right">IP Address</TD> <TD BGCOLOR="#ffffff"> -<% if ( $part_svc->part_svc_column('ip_addr')->columnflag eq 'F' ) { %> - <INPUT TYPE="hidden" NAME="ip_addr" VALUE="<%=$ip_addr%>"><%=$ip_addr%> -<% } else { %> - <INPUT TYPE="text" NAME="ip_addr" VALUE="<%=$ip_addr%>"> -<% } %> +% if ( $part_svc->part_svc_column('ip_addr')->columnflag eq 'F' ) { + + <INPUT TYPE="hidden" NAME="ip_addr" VALUE="<%$ip_addr%>"><%$ip_addr%> +% } else { + + <INPUT TYPE="text" NAME="ip_addr" VALUE="<%$ip_addr%>"> +% } + </TD> </TR> <TR> <TD ALIGN="right">Download speed</TD> <TD BGCOLOR="#ffffff"> -<% if ( $part_svc->part_svc_column('speed_down')->columnflag eq 'F' ) { %> - <INPUT TYPE="hidden" NAME="speed_down" VALUE="<%=$speed_down%>"><%=$speed_down%>Kbps -<% } else { %> - <INPUT TYPE="text" NAME="speed_down" SIZE=5 VALUE="<%=$speed_down%>">Kbps -<% } %> +% if ( $part_svc->part_svc_column('speed_down')->columnflag eq 'F' ) { + + <INPUT TYPE="hidden" NAME="speed_down" VALUE="<%$speed_down%>"><%$speed_down%>Kbps +% } else { + + <INPUT TYPE="text" NAME="speed_down" SIZE=5 VALUE="<%$speed_down%>">Kbps +% } + </TD> </TR> <TR> <TD ALIGN="right">Upload speed</TD> <TD BGCOLOR="#ffffff"> -<% if ( $part_svc->part_svc_column('speed_up')->columnflag eq 'F' ) { %> - <INPUT TYPE="hidden" NAME="speed_up" VALUE="<%=$speed_up%>"><%=$speed_up%>Kbps -<% } else { %> - <INPUT TYPE="text" NAME="speed_up" SIZE=5 VALUE="<%=$speed_up%>">Kbps -<% } %> +% if ( $part_svc->part_svc_column('speed_up')->columnflag eq 'F' ) { + + <INPUT TYPE="hidden" NAME="speed_up" VALUE="<%$speed_up%>"><%$speed_up%>Kbps +% } else { + + <INPUT TYPE="text" NAME="speed_up" SIZE=5 VALUE="<%$speed_up%>">Kbps +% } + </TD> </TR> -<% if ($action eq 'Add') { %> +% if ($action eq 'Add') { + <TR> <TD ALIGN="right">Router/Block</TD> <TD BGCOLOR="#ffffff"> <SELECT NAME="blocknum"> -<% - warn $svc_broadband->svcpart; - foreach my $router ($svc_broadband->allowed_routers) { - warn $router->routername; - foreach my $addr_block ($router->addr_block) { -%> - <OPTION VALUE="<%=$addr_block->blocknum%>"<%=($addr_block->blocknum eq $blocknum) ? ' SELECTED' : ''%>> - <%=$router->routername%>:<%=$addr_block->ip_gateway%>/<%=$addr_block->ip_netmask%></OPTION> -<% - } - } -%> +% +% warn $svc_broadband->svcpart; +% foreach my $router ($svc_broadband->allowed_routers) { +% warn $router->routername; +% foreach my $addr_block ($router->addr_block) { +% + + <OPTION VALUE="<%$addr_block->blocknum%>"<%($addr_block->blocknum eq $blocknum) ? ' SELECTED' : ''%>> + <%$router->routername%>:<%$addr_block->ip_gateway%>/<%$addr_block->ip_netmask%></OPTION> +% +% } +% } +% + </SELECT> </TD> </TR> -<% } else { %> +% } else { + <TR> <TD ALIGN="right">Router/Block</TD> <TD BGCOLOR="#ffffff"> - <%=$svc_broadband->addr_block->router->routername%>:<%=$svc_broadband->addr_block->NetAddr%> - <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%=$svc_broadband->blocknum%>"> + <%$svc_broadband->addr_block->router->routername%>:<%$svc_broadband->addr_block->NetAddr%> + <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%$svc_broadband->blocknum%>"> </TD> </TR> +% } +% +%foreach my $field ($svc_broadband->virtual_fields) { +% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' && +% $part_svc->part_svc_column($field)->columnflag ne 'X') { +% print $svc_broadband->pvf($field)->widget('HTML', 'edit', +% $svc_broadband->getfield($field)); +% } +%} -<% } %> - -<% -foreach my $field ($svc_broadband->virtual_fields) { - if ( $part_svc->part_svc_column($field)->columnflag ne 'F' && - $part_svc->part_svc_column($field)->columnflag ne 'X') { - print $svc_broadband->pvf($field)->widget('HTML', 'edit', - $svc_broadband->getfield($field)); - } -} %> </TABLE> <BR> <INPUT TYPE="submit" NAME="submit" VALUE="Submit"> diff --git a/httemplate/edit/svc_domain.cgi b/httemplate/edit/svc_domain.cgi index 1156bf0ba..19e0e1285 100755 --- a/httemplate/edit/svc_domain.cgi +++ b/httemplate/edit/svc_domain.cgi @@ -1,88 +1,90 @@ -<% - -my($svcnum, $pkgnum, $svcpart, $kludge_action, $purpose, $part_svc, - $svc_domain); -if ( $cgi->param('error') ) { - $svc_domain = new FS::svc_domain ( { - map { $_, scalar($cgi->param($_)) } fields('svc_domain') - } ); - $svcnum = $svc_domain->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $cgi->param('svcpart'); - $kludge_action = $cgi->param('action'); - $purpose = $cgi->param('purpose'); - $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } ); - die "No part_svc entry!" unless $part_svc; -} else { - $kludge_action = ''; - $purpose = ''; - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum}) - or die "Unknown (svc_domain) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - } else { #adding - - $svc_domain = new FS::svc_domain({}); - - foreach $_ (split(/-/,$query)) { - $pkgnum=$1 if /^pkgnum(\d+)$/; - $svcpart=$1 if /^svcpart(\d+)$/; - } - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - $svcnum=''; - - $svc_domain->set_default_and_fixed; - - } - -} -my $action = $svcnum ? 'Edit' : 'Add'; - -my $svc = $part_svc->getfield('svc'); - -my $otaker = getotaker; - -my $domain = $svc_domain->domain; - -my $p1 = popurl(1); - -%> - -<%= include('/elements/header.html', "$action $svc", '') %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> -<% } %> - -<FORM ACTION="<%= $p1 %>process/svc_domain.cgi" METHOD=POST> -<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%= $svcnum %>"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> -<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>"> - -<INPUT TYPE="radio" NAME="action" VALUE="N"<%= $kludge_action eq 'N' ? ' CHECKED' : '' %>>New +% +% +%my($svcnum, $pkgnum, $svcpart, $kludge_action, $purpose, $part_svc, +% $svc_domain); +%if ( $cgi->param('error') ) { +% $svc_domain = new FS::svc_domain ( { +% map { $_, scalar($cgi->param($_)) } fields('svc_domain') +% } ); +% $svcnum = $svc_domain->svcnum; +% $pkgnum = $cgi->param('pkgnum'); +% $svcpart = $cgi->param('svcpart'); +% $kludge_action = $cgi->param('action'); +% $purpose = $cgi->param('purpose'); +% $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } ); +% die "No part_svc entry!" unless $part_svc; +%} else { +% $kludge_action = ''; +% $purpose = ''; +% my($query) = $cgi->keywords; +% if ( $query =~ /^(\d+)$/ ) { #editing +% $svcnum=$1; +% $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum}) +% or die "Unknown (svc_domain) svcnum!"; +% +% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) +% or die "Unknown (cust_svc) svcnum!"; +% +% $pkgnum=$cust_svc->pkgnum; +% $svcpart=$cust_svc->svcpart; +% +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% } else { #adding +% +% $svc_domain = new FS::svc_domain({}); +% +% foreach $_ (split(/-/,$query)) { +% $pkgnum=$1 if /^pkgnum(\d+)$/; +% $svcpart=$1 if /^svcpart(\d+)$/; +% } +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% $svcnum=''; +% +% $svc_domain->set_default_and_fixed; +% +% } +% +%} +%my $action = $svcnum ? 'Edit' : 'Add'; +% +%my $svc = $part_svc->getfield('svc'); +% +%my $otaker = getotaker; +% +%my $domain = $svc_domain->domain; +% +%my $p1 = popurl(1); +% +% + + +<% include('/elements/header.html', "$action $svc", '') %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> +% } + + +<FORM ACTION="<% $p1 %>process/svc_domain.cgi" METHOD=POST> +<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>"> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>"> +<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>"> + +<INPUT TYPE="radio" NAME="action" VALUE="N"<% $kludge_action eq 'N' ? ' CHECKED' : '' %>>New <BR> -<INPUT TYPE="radio" NAME="action" VALUE="M"<%= $kludge_action eq 'M' ? ' CHECKED' : '' %>>Transfer +<INPUT TYPE="radio" NAME="action" VALUE="M"<% $kludge_action eq 'M' ? ' CHECKED' : '' %>>Transfer -<P>Domain <INPUT TYPE="text" NAME="domain" VALUE="<%= $domain %>" SIZE=28 MAXLENGTH=63> +<P>Domain <INPUT TYPE="text" NAME="domain" VALUE="<% $domain %>" SIZE=28 MAXLENGTH=63> -<BR>Purpose/Description: <INPUT TYPE="text" NAME="purpose" VALUE="<%= $purpose %>" SIZE=64> +<BR>Purpose/Description: <INPUT TYPE="text" NAME="purpose" VALUE="<% $purpose %>" SIZE=64> <P><INPUT TYPE="submit" VALUE="Submit"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/edit/svc_external.cgi b/httemplate/edit/svc_external.cgi index 38b3ce1a4..1230340ac 100644 --- a/httemplate/edit/svc_external.cgi +++ b/httemplate/edit/svc_external.cgi @@ -1,95 +1,96 @@ <!-- mason kludge --> -<% +% +% +%my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_external ); +%if ( $cgi->param('error') ) { +% $svc_external = new FS::svc_external ( { +% map { $_, scalar($cgi->param($_)) } fields('svc_external') +% } ); +% $svcnum = $svc_external->svcnum; +% $pkgnum = $cgi->param('pkgnum'); +% $svcpart = $cgi->param('svcpart'); +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +%} else { +% my($query) = $cgi->keywords; +% if ( $query =~ /^(\d+)$/ ) { #editing +% $svcnum=$1; +% $svc_external=qsearchs('svc_external',{'svcnum'=>$svcnum}) +% or die "Unknown (svc_external) svcnum!"; +% +% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) +% or die "Unknown (cust_svc) svcnum!"; +% +% $pkgnum=$cust_svc->pkgnum; +% $svcpart=$cust_svc->svcpart; +% +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% } else { #adding +% +% foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart +% $pkgnum=$1 if /^pkgnum(\d+)$/; +% $svcpart=$1 if /^svcpart(\d+)$/; +% } +% $svc_external = new FS::svc_external { svcpart => $svcpart }; +% +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% $svcnum=''; +% +% $svc_external->set_default_and_fixed; +% +% } +%} +%my $action = $svc_external->svcnum ? 'Edit' : 'Add'; +% +%my $p1 = popurl(1); +%print header("External service $action", ''); +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT>" +% if $cgi->param('error'); +% +%print qq!<FORM ACTION="${p1}process/svc_external.cgi" METHOD=POST>!; +% +%#display +% +% +%#svcnum +%print qq!<INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">!; +%print qq!Service #<B>!, $svcnum ? $svcnum : "(NEW)", "</B><BR><BR>"; +% +%#pkgnum +%print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!; +% +%#svcpart +%print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!; +% +%my($id,$title)=( +% $svc_external->id, +% $svc_external->title, +%); +% +%print &ntable("#cccccc",2), +% '<TR><TD ALIGN="right">External ID</TD><TD>'. +% qq!<INPUT TYPE="text" NAME="id" VALUE="$id">!. +% '</TD></TR>'. +% '<TR><TD ALIGN="right">Title</TD><TD>'. +% qq!<INPUT TYPE="text" NAME="title" VALUE="$title">!. +% '</TD></TR>'; +% +%foreach my $field ($svc_external->virtual_fields) { +% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { +% # If the flag is X, it won't even show up in $svc_acct->virtual_fields. +% print $svc_external->pvf($field)->widget('HTML', 'edit', +% $svc_external->getfield($field)); +% } +%} +% +% -my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_external ); -if ( $cgi->param('error') ) { - $svc_external = new FS::svc_external ( { - map { $_, scalar($cgi->param($_)) } fields('svc_external') - } ); - $svcnum = $svc_external->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $cgi->param('svcpart'); - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; -} else { - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_external=qsearchs('svc_external',{'svcnum'=>$svcnum}) - or die "Unknown (svc_external) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - } else { #adding - - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart - $pkgnum=$1 if /^pkgnum(\d+)$/; - $svcpart=$1 if /^svcpart(\d+)$/; - } - $svc_external = new FS::svc_external { svcpart => $svcpart }; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - $svcnum=''; - - $svc_external->set_default_and_fixed; - - } -} -my $action = $svc_external->svcnum ? 'Edit' : 'Add'; - -my $p1 = popurl(1); -print header("External service $action", ''); - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); - -print qq!<FORM ACTION="${p1}process/svc_external.cgi" METHOD=POST>!; - -#display - - -#svcnum -print qq!<INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">!; -print qq!Service #<B>!, $svcnum ? $svcnum : "(NEW)", "</B><BR><BR>"; - -#pkgnum -print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!; - -#svcpart -print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!; - -my($id,$title)=( - $svc_external->id, - $svc_external->title, -); - -print &ntable("#cccccc",2), - '<TR><TD ALIGN="right">External ID</TD><TD>'. - qq!<INPUT TYPE="text" NAME="id" VALUE="$id">!. - '</TD></TR>'. - '<TR><TD ALIGN="right">Title</TD><TD>'. - qq!<INPUT TYPE="text" NAME="title" VALUE="$title">!. - '</TD></TR>'; - -foreach my $field ($svc_external->virtual_fields) { - if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { - # If the flag is X, it won't even show up in $svc_acct->virtual_fields. - print $svc_external->pvf($field)->widget('HTML', 'edit', - $svc_external->getfield($field)); - } -} - -%> </TABLE><BR><INPUT TYPE="submit" VALUE="Submit"> </FORM> diff --git a/httemplate/edit/svc_forward.cgi b/httemplate/edit/svc_forward.cgi index c32fbd7c1..73b32dc7b 100755 --- a/httemplate/edit/svc_forward.cgi +++ b/httemplate/edit/svc_forward.cgi @@ -1,122 +1,124 @@ <!-- mason kludge --> -<% - -my $conf = new FS::Conf; - -my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_forward); -if ( $cgi->param('error') ) { - $svc_forward = new FS::svc_forward ( { - map { $_, scalar($cgi->param($_)) } fields('svc_forward') - } ); - $svcnum = $svc_forward->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $cgi->param('svcpart'); - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; -} else { - - my($query) = $cgi->keywords; - - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_forward=qsearchs('svc_forward',{'svcnum'=>$svcnum}) - or die "Unknown (svc_forward) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - } else { #adding - - $svc_forward = new FS::svc_forward({}); - - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart - $pkgnum=$1 if /^pkgnum(\d+)$/; - $svcpart=$1 if /^svcpart(\d+)$/; - } - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - $svcnum=''; - - $svc_forward->set_default_and_fixed; - } - -} -my $action = $svc_forward->svcnum ? 'Edit' : 'Add'; - -my %email; - -#starting with those currently attached -foreach my $method (qw( srcsvc_acct dstsvc_acct )) { - my $svc_acct = $svc_forward->$method(); - $email{$svc_acct->svcnum} = $svc_acct->email if $svc_acct; -} - -if ($pkgnum) { - - #find all possible user svcnums (and emails) - - #and including the rest for this customer - my($u_part_svc,@u_acct_svcparts); - foreach $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) { - push @u_acct_svcparts,$u_part_svc->getfield('svcpart'); - } - - my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - my($custnum)=$cust_pkg->getfield('custnum'); - my($i_cust_pkg); - foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { - my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); - my($acct_svcpart); - foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding - #record(s) in cust_svc ( for this - #pkgnum ! ) - foreach my $i_cust_svc ( - qsearch( 'cust_svc', { 'pkgnum' => $cust_pkgnum, - 'svcpart' => $acct_svcpart } ) - ) { - my $svc_acct = - qsearchs( 'svc_acct', { 'svcnum' => $i_cust_svc->svcnum } ); - $email{$svc_acct->svcnum} = $svc_acct->email; - } - } - } - -} elsif ( $action eq 'Add' ) { - die "\$action eq Add, but \$pkgnum is null!\n"; -} - -my($srcsvc,$dstsvc,$dst)=( - $svc_forward->srcsvc, - $svc_forward->dstsvc, - $svc_forward->dst, -); -my $src = $svc_forward->dbdef_table->column('src') ? $svc_forward->src : ''; - -#display - -%> - -<%= include("/elements/header.html","Mail Forward $action") %> - -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> +% +% +%my $conf = new FS::Conf; +% +%my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_forward); +%if ( $cgi->param('error') ) { +% $svc_forward = new FS::svc_forward ( { +% map { $_, scalar($cgi->param($_)) } fields('svc_forward') +% } ); +% $svcnum = $svc_forward->svcnum; +% $pkgnum = $cgi->param('pkgnum'); +% $svcpart = $cgi->param('svcpart'); +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +%} else { +% +% my($query) = $cgi->keywords; +% +% if ( $query =~ /^(\d+)$/ ) { #editing +% $svcnum=$1; +% $svc_forward=qsearchs('svc_forward',{'svcnum'=>$svcnum}) +% or die "Unknown (svc_forward) svcnum!"; +% +% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) +% or die "Unknown (cust_svc) svcnum!"; +% +% $pkgnum=$cust_svc->pkgnum; +% $svcpart=$cust_svc->svcpart; +% +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% } else { #adding +% +% $svc_forward = new FS::svc_forward({}); +% +% foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart +% $pkgnum=$1 if /^pkgnum(\d+)$/; +% $svcpart=$1 if /^svcpart(\d+)$/; +% } +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% $svcnum=''; +% +% $svc_forward->set_default_and_fixed; +% } +% +%} +%my $action = $svc_forward->svcnum ? 'Edit' : 'Add'; +% +%my %email; +% +%#starting with those currently attached +%foreach my $method (qw( srcsvc_acct dstsvc_acct )) { +% my $svc_acct = $svc_forward->$method(); +% $email{$svc_acct->svcnum} = $svc_acct->email if $svc_acct; +%} +% +%if ($pkgnum) { +% +% #find all possible user svcnums (and emails) +% +% #and including the rest for this customer +% my($u_part_svc,@u_acct_svcparts); +% foreach $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) { +% push @u_acct_svcparts,$u_part_svc->getfield('svcpart'); +% } +% +% my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +% my($custnum)=$cust_pkg->getfield('custnum'); +% my($i_cust_pkg); +% foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { +% my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); +% my($acct_svcpart); +% foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding +% #record(s) in cust_svc ( for this +% #pkgnum ! ) +% foreach my $i_cust_svc ( +% qsearch( 'cust_svc', { 'pkgnum' => $cust_pkgnum, +% 'svcpart' => $acct_svcpart } ) +% ) { +% my $svc_acct = +% qsearchs( 'svc_acct', { 'svcnum' => $i_cust_svc->svcnum } ); +% $email{$svc_acct->svcnum} = $svc_acct->email; +% } +% } +% } +% +%} elsif ( $action eq 'Add' ) { +% die "\$action eq Add, but \$pkgnum is null!\n"; +%} +% +%my($srcsvc,$dstsvc,$dst)=( +% $svc_forward->srcsvc, +% $svc_forward->dstsvc, +% $svc_forward->dst, +%); +%my $src = $svc_forward->dbdef_table->column('src') ? $svc_forward->src : ''; +% +%#display +% +% + + +<% include("/elements/header.html","Mail Forward $action") %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> <BR><BR> -<% } %> +% } + -Service #<%= $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR> -Service: <B><%= $part_svc->svc %></B><BR><BR> +Service #<% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR> +Service: <B><% $part_svc->svc %></B><BR><BR> <FORM ACTION="process/svc_forward.cgi" METHOD="POST"> -<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%= $svcnum %>"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> -<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>"> +<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>"> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>"> +<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>"> <SCRIPT TYPE="text/javascript"> function srcchanged(what) { @@ -139,29 +141,36 @@ function dstchanged(what) { } </SCRIPT> -<%= ntable("#cccccc",2) %> +<% ntable("#cccccc",2) %> <TR><TD ALIGN="right">Email to</TD> <TD><SELECT NAME="srcsvc" SIZE=1 onChange="srcchanged(this)"> -<% foreach $_ (keys %email) { %> - <OPTION<%= $_ eq $srcsvc ? " SELECTED" : "" %> VALUE="<%= $_ %>"><%= $email{$_} %></OPTION> -<% } %> -<% if ( $svc_forward->dbdef_table->column('src') ) { %> - <OPTION <%= $src ? 'SELECTED' : '' %> VALUE="0">(other email address)</OPTION> -<% } %> +% foreach $_ (keys %email) { + + <OPTION<% $_ eq $srcsvc ? " SELECTED" : "" %> VALUE="<% $_ %>"><% $email{$_} %></OPTION> +% } +% if ( $svc_forward->dbdef_table->column('src') ) { + + <OPTION <% $src ? 'SELECTED' : '' %> VALUE="0">(other email address)</OPTION> +% } + </SELECT> -<% if ( $svc_forward->dbdef_table->column('src') ) { %> -<INPUT TYPE="text" NAME="src" VALUE="<%= $src %>" <%= ( $src || !scalar(%email) ) ? '' : 'DISABLED STYLE="background-color: lightgrey"' %>> -<% } %> +% if ( $svc_forward->dbdef_table->column('src') ) { + +<INPUT TYPE="text" NAME="src" VALUE="<% $src %>" <% ( $src || !scalar(%email) ) ? '' : 'DISABLED STYLE="background-color: lightgrey"' %>> +% } + </TD></TR> <TR><TD ALIGN="right">Forwards to</TD> <TD><SELECT NAME="dstsvc" SIZE=1 onChange="dstchanged(this)"> -<% foreach $_ (keys %email) { %> - <OPTION<%= $_ eq $dstsvc ? " SELECTED" : "" %> VALUE="<%= $_ %>"><%= $email{$_} %></OPTION> -<% } %> -<OPTION <%= $dst ? 'SELECTED' : '' %> VALUE="0">(other email address)</OPTION> +% foreach $_ (keys %email) { + + <OPTION<% $_ eq $dstsvc ? " SELECTED" : "" %> VALUE="<% $_ %>"><% $email{$_} %></OPTION> +% } + +<OPTION <% $dst ? 'SELECTED' : '' %> VALUE="0">(other email address)</OPTION> </SELECT> -<INPUT TYPE="text" NAME="dst" VALUE="<%= $dst %>" <%= ( $dst || !scalar(%email) ) ? '' : 'DISABLED STYLE="background-color: lightgrey"' %>> +<INPUT TYPE="text" NAME="dst" VALUE="<% $dst %>" <% ( $dst || !scalar(%email) ) ? '' : 'DISABLED STYLE="background-color: lightgrey"' %>> </TD></TR> </TABLE> <BR><INPUT TYPE="submit" VALUE="Submit"> diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi index 77b4975a1..ca62b6416 100644 --- a/httemplate/edit/svc_phone.cgi +++ b/httemplate/edit/svc_phone.cgi @@ -1,4 +1,4 @@ -<%= include( 'elements/svc_Common.html', +<% include( 'elements/svc_Common.html', 'name' => 'Phone number', 'table' => 'svc_phone', 'fields' => [qw( countrycode phonenum )], #pin diff --git a/httemplate/edit/svc_www.cgi b/httemplate/edit/svc_www.cgi index 280346bb4..ad69d4db6 100644 --- a/httemplate/edit/svc_www.cgi +++ b/httemplate/edit/svc_www.cgi @@ -1,215 +1,216 @@ <!-- mason kludge --> -<% +% +% +%my $conf = new FS::Conf; +% +%my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_www ); +%if ( $cgi->param('error') ) { +% $svc_www = new FS::svc_www ( { +% map { $_, scalar($cgi->param($_)) } fields('svc_www') +% } ); +% $svcnum = $svc_www->svcnum; +% $pkgnum = $cgi->param('pkgnum'); +% $svcpart = $cgi->param('svcpart'); +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +%} else { +% my($query) = $cgi->keywords; +% if ( $query =~ /^(\d+)$/ ) { #editing +% $svcnum=$1; +% $svc_www=qsearchs('svc_www',{'svcnum'=>$svcnum}) +% or die "Unknown (svc_www) svcnum!"; +% +% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) +% or die "Unknown (cust_svc) svcnum!"; +% +% $pkgnum=$cust_svc->pkgnum; +% $svcpart=$cust_svc->svcpart; +% +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% } else { #adding +% +% foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart +% $pkgnum=$1 if /^pkgnum(\d+)$/; +% $svcpart=$1 if /^svcpart(\d+)$/; +% } +% $svc_www = new FS::svc_www { svcpart => $svcpart }; +% +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% $svcnum=''; +% +% $svc_www->set_default_and_fixed; +% +% } +%} +%my $action = $svc_www->svcnum ? 'Edit' : 'Add'; +% +%my( %svc_acct, %arec ); +%if ($pkgnum) { +% +% my @u_acct_svcparts; +% foreach my $svcpart ( +% map { $_->svcpart } qsearch( 'part_svc', { 'svcdb' => 'svc_acct' } ) +% ) { +% next if $conf->exists('svc_www-usersvc_svcpart') +% && ! grep { $svcpart == $_ } +% $conf->config('svc_www-usersvc_svcpart'); +% push @u_acct_svcparts, $svcpart; +% } +% +% my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +% my($custnum)=$cust_pkg->getfield('custnum'); +% my($i_cust_pkg); +% foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { +% my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); +% my($acct_svcpart); +% foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding +% #record(s) in cust_svc ( for this +% #pkgnum ! ) +% my($i_cust_svc); +% foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) { +% my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')}); +% $svc_acct{$svc_acct->getfield('svcnum')}= +% $svc_acct->cust_svc->part_svc->svc. ': '. $svc_acct->email; +% } +% } +% } +% +% +% my($d_part_svc,@d_acct_svcparts); +% foreach $d_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_domain'}) ) { +% push @d_acct_svcparts,$d_part_svc->getfield('svcpart'); +% } +% +% foreach $i_cust_pkg ( qsearch( 'cust_pkg', { 'custnum' => $custnum } ) ) { +% my $cust_pkgnum = $i_cust_pkg->pkgnum; +% +% foreach my $acct_svcpart (@d_acct_svcparts) { +% +% foreach my $i_cust_svc ( +% qsearch( 'cust_svc', { 'pkgnum' => $cust_pkgnum, +% 'svcpart' => $acct_svcpart } ) +% ) { +% my $svc_domain = +% qsearchs( 'svc_domain', { 'svcnum' => $i_cust_svc->svcnum } ); +% +% my $extra_sql = "AND ( rectype = 'A' OR rectype = 'CNAME' )"; +% unless ( $conf->exists('svc_www-enable_subdomains') ) { +% $extra_sql .= " AND ( reczone = '\@' OR reczone = '". +% $svc_domain->domain. ".' )"; +% } +% +% foreach my $domain_rec ( +% qsearch( 'domain_record', +% { +% 'svcnum' => $svc_domain->svcnum, +% }, +% '', +% $extra_sql, +% ) +% ) { +% $arec{$domain_rec->recnum} = $domain_rec->zone; +% } +% +% if ( $conf->exists('svc_www-enable_subdomains') ) { +% $arec{'www.'. $svc_domain->domain} = 'www.'. $svc_domain->domain +% unless qsearchs( 'domain_record', { +% svcnum => $svc_domain->svcnum, +% reczone => 'www', +% } ) +% || qsearchs( 'domain_record', { +% svcnum => $svc_domain->svcnum, +% reczone => 'www.'.$svc_domain->domain.'.', +% } ); +% } +% +% $arec{'@.'. $svc_domain->domain} = $svc_domain->domain +% unless qsearchs('domain_record', { +% svcnum => $svc_domain->svcnum, +% reczone => '@', +% } ) +% || qsearchs('domain_record', { +% svcnum => $svc_domain->svcnum, +% reczone => $svc_domain->domain.'.', +% } ); +% +% } +% +% } +% } +% +%} elsif ( $action eq 'Edit' ) { +% +% my($domain_rec) = qsearchs('domain_record', { 'recnum'=>$svc_www->recnum }); +% $arec{$svc_www->recnum} = join '.', $domain_rec->recdata, $domain_rec->reczone; +% +%} else { +% die "\$action eq Add, but \$pkgnum is null!\n"; +%} +% +% +%my $p1 = popurl(1); +%print header("Web Hosting $action", ''); +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT>" +% if $cgi->param('error'); +% +%print qq!<FORM ACTION="${p1}process/svc_www.cgi" METHOD=POST>!; +% +%#display +% +% +% +%#svcnum +%print qq!<INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">!; +%print qq!Service #<B>!, $svcnum ? $svcnum : "(NEW)", "</B><BR><BR>"; +% +%#pkgnum +%print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!; +% +%#svcpart +%print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!; +% +%my($recnum,$usersvc)=( +% $svc_www->recnum, +% $svc_www->usersvc, +%); +% +%print &ntable("#cccccc",2), +% '<TR><TD ALIGN="right">Zone</TD><TD><SELECT NAME="recnum" SIZE=1>'; +%foreach $_ (keys %arec) { +% print "<OPTION", $_ eq $recnum ? " SELECTED" : "", +% qq! VALUE="$_">$arec{$_}!; +%} +%print "</SELECT></TD></TR>"; +% +%print '<TR><TD ALIGN="right">Username</TD><TD><SELECT NAME="usersvc" SIZE=1>'; +%print '<OPTION VALUE="">(none)'; +%foreach $_ (keys %svc_acct) { +% print "<OPTION", ($_ eq $usersvc) ? " SELECTED" : "", +% qq! VALUE="$_">$svc_acct{$_}!; +%} +%print "</SELECT></TD></TR>"; +% +%foreach my $field ($svc_www->virtual_fields) { +% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { +% # If the flag is X, it won't even show up in $svc_acct->virtual_fields. +% print $svc_www->pvf($field)->widget('HTML', 'edit', +% $svc_www->getfield($field)); +% } +%} +% +%print '</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">'; +% +%print <<END; +% +% </FORM> +% </BODY> +%</HTML> +%END +% -my $conf = new FS::Conf; - -my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_www ); -if ( $cgi->param('error') ) { - $svc_www = new FS::svc_www ( { - map { $_, scalar($cgi->param($_)) } fields('svc_www') - } ); - $svcnum = $svc_www->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $cgi->param('svcpart'); - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; -} else { - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_www=qsearchs('svc_www',{'svcnum'=>$svcnum}) - or die "Unknown (svc_www) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - } else { #adding - - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart - $pkgnum=$1 if /^pkgnum(\d+)$/; - $svcpart=$1 if /^svcpart(\d+)$/; - } - $svc_www = new FS::svc_www { svcpart => $svcpart }; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - $svcnum=''; - - $svc_www->set_default_and_fixed; - - } -} -my $action = $svc_www->svcnum ? 'Edit' : 'Add'; - -my( %svc_acct, %arec ); -if ($pkgnum) { - - my @u_acct_svcparts; - foreach my $svcpart ( - map { $_->svcpart } qsearch( 'part_svc', { 'svcdb' => 'svc_acct' } ) - ) { - next if $conf->exists('svc_www-usersvc_svcpart') - && ! grep { $svcpart == $_ } - $conf->config('svc_www-usersvc_svcpart'); - push @u_acct_svcparts, $svcpart; - } - - my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - my($custnum)=$cust_pkg->getfield('custnum'); - my($i_cust_pkg); - foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { - my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); - my($acct_svcpart); - foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding - #record(s) in cust_svc ( for this - #pkgnum ! ) - my($i_cust_svc); - foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) { - my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')}); - $svc_acct{$svc_acct->getfield('svcnum')}= - $svc_acct->cust_svc->part_svc->svc. ': '. $svc_acct->email; - } - } - } - - - my($d_part_svc,@d_acct_svcparts); - foreach $d_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_domain'}) ) { - push @d_acct_svcparts,$d_part_svc->getfield('svcpart'); - } - - foreach $i_cust_pkg ( qsearch( 'cust_pkg', { 'custnum' => $custnum } ) ) { - my $cust_pkgnum = $i_cust_pkg->pkgnum; - - foreach my $acct_svcpart (@d_acct_svcparts) { - - foreach my $i_cust_svc ( - qsearch( 'cust_svc', { 'pkgnum' => $cust_pkgnum, - 'svcpart' => $acct_svcpart } ) - ) { - my $svc_domain = - qsearchs( 'svc_domain', { 'svcnum' => $i_cust_svc->svcnum } ); - - my $extra_sql = "AND ( rectype = 'A' OR rectype = 'CNAME' )"; - unless ( $conf->exists('svc_www-enable_subdomains') ) { - $extra_sql .= " AND ( reczone = '\@' OR reczone = '". - $svc_domain->domain. ".' )"; - } - - foreach my $domain_rec ( - qsearch( 'domain_record', - { - 'svcnum' => $svc_domain->svcnum, - }, - '', - $extra_sql, - ) - ) { - $arec{$domain_rec->recnum} = $domain_rec->zone; - } - - if ( $conf->exists('svc_www-enable_subdomains') ) { - $arec{'www.'. $svc_domain->domain} = 'www.'. $svc_domain->domain - unless qsearchs( 'domain_record', { - svcnum => $svc_domain->svcnum, - reczone => 'www', - } ) - || qsearchs( 'domain_record', { - svcnum => $svc_domain->svcnum, - reczone => 'www.'.$svc_domain->domain.'.', - } ); - } - - $arec{'@.'. $svc_domain->domain} = $svc_domain->domain - unless qsearchs('domain_record', { - svcnum => $svc_domain->svcnum, - reczone => '@', - } ) - || qsearchs('domain_record', { - svcnum => $svc_domain->svcnum, - reczone => $svc_domain->domain.'.', - } ); - - } - - } - } - -} elsif ( $action eq 'Edit' ) { - - my($domain_rec) = qsearchs('domain_record', { 'recnum'=>$svc_www->recnum }); - $arec{$svc_www->recnum} = join '.', $domain_rec->recdata, $domain_rec->reczone; - -} else { - die "\$action eq Add, but \$pkgnum is null!\n"; -} - - -my $p1 = popurl(1); -print header("Web Hosting $action", ''); - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); - -print qq!<FORM ACTION="${p1}process/svc_www.cgi" METHOD=POST>!; - -#display - - - -#svcnum -print qq!<INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">!; -print qq!Service #<B>!, $svcnum ? $svcnum : "(NEW)", "</B><BR><BR>"; - -#pkgnum -print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!; - -#svcpart -print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!; - -my($recnum,$usersvc)=( - $svc_www->recnum, - $svc_www->usersvc, -); - -print &ntable("#cccccc",2), - '<TR><TD ALIGN="right">Zone</TD><TD><SELECT NAME="recnum" SIZE=1>'; -foreach $_ (keys %arec) { - print "<OPTION", $_ eq $recnum ? " SELECTED" : "", - qq! VALUE="$_">$arec{$_}!; -} -print "</SELECT></TD></TR>"; - -print '<TR><TD ALIGN="right">Username</TD><TD><SELECT NAME="usersvc" SIZE=1>'; -print '<OPTION VALUE="">(none)'; -foreach $_ (keys %svc_acct) { - print "<OPTION", ($_ eq $usersvc) ? " SELECTED" : "", - qq! VALUE="$_">$svc_acct{$_}!; -} -print "</SELECT></TD></TR>"; - -foreach my $field ($svc_www->virtual_fields) { - if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { - # If the flag is X, it won't even show up in $svc_acct->virtual_fields. - print $svc_www->pvf($field)->widget('HTML', 'edit', - $svc_www->getfield($field)); - } -} - -print '</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">'; - -print <<END; - - </FORM> - </BODY> -</HTML> -END -%> diff --git a/httemplate/elements/checkboxes-table-name.html b/httemplate/elements/checkboxes-table-name.html index 8e9dd29d2..0a92e4548 100644 --- a/httemplate/elements/checkboxes-table-name.html +++ b/httemplate/elements/checkboxes-table-name.html @@ -1,85 +1,85 @@ -<% - - ## - # required - ## - # 'link_table' => 'table_name', - # - # 'name_col' => 'name_column', - # #or - # 'name_callback' => sub { }, - # - # 'names_list' => [ 'value', 'other value' ], - # - ## - # recommended (required?) - ## - # 'source_obj' => $obj, - # #or? - # #'source_table' => 'table_name', - # #'sourcenum' => '4', #current value of primary key in source_table - # # # (none is okay, just pass it if you have it) - ## - # optional - ## - # 'num_col' => 'col_name' #if column name is different in link_table than - # #source_table - # 'link_static' => { 'column' => 'value' }, - - my( %opt ) = @_; - - my( $source_pkey, $sourcenum, $source_obj ); - if ( $opt{'source_obj'} ) { - - $source_obj = $opt{'source_obj'}; - #$source_table = $source_obj->dbdef_table->table; - $source_pkey = $source_obj->dbdef_table->primary_key; - $sourcenum = $source_obj->$source_pkey(); - - } else { - - #$source_obj? - $source_pkey = $opt{'source_table'} - ? dbdef->table($opt{'source_table'})->primary_key - : ''; - $sourcenum = $opt{'sourcenum'}; - } - - $source_pkey = $opt{'num_col'} || $source_pkey; - - my $link_static = $opt{'link_static'} || {}; - -%> - -<% foreach my $name ( @{ $opt{'names_list'} } ) { - - my $checked; - if ( $cgi->param('error') ) { - - $checked = $cgi->param($opt{'link_table'}. ".$name" ) - ? 'CHECKED' - : ''; - - } else { - - $checked = - qsearchs( $opt{'link_table'}, { - $source_pkey => $sourcenum, - $opt{'name_col'} => $name, - %$link_static, - } ) - ? 'CHECKED' - : '' - - } - -%> - - <INPUT TYPE="checkbox" NAME="<%= $opt{'link_table'}. ".$name" %>" <%= $checked %> VALUE="ON"> - - <%= $name %> +% +% +% ## +% # required +% ## +% # 'link_table' => 'table_name', +% # +% # 'name_col' => 'name_column', +% # #or +% # 'name_callback' => sub { }, +% # +% # 'names_list' => [ 'value', 'other value' ], +% # +% ## +% # recommended (required?) +% ## +% # 'source_obj' => $obj, +% # #or? +% # #'source_table' => 'table_name', +% # #'sourcenum' => '4', #current value of primary key in source_table +% # # # (none is okay, just pass it if you have it) +% ## +% # optional +% ## +% # 'num_col' => 'col_name' #if column name is different in link_table than +% # #source_table +% # 'link_static' => { 'column' => 'value' }, +% +% my( %opt ) = @_; +% +% my( $source_pkey, $sourcenum, $source_obj ); +% if ( $opt{'source_obj'} ) { +% +% $source_obj = $opt{'source_obj'}; +% #$source_table = $source_obj->dbdef_table->table; +% $source_pkey = $source_obj->dbdef_table->primary_key; +% $sourcenum = $source_obj->$source_pkey(); +% +% } else { +% +% #$source_obj? +% $source_pkey = $opt{'source_table'} +% ? dbdef->table($opt{'source_table'})->primary_key +% : ''; +% $sourcenum = $opt{'sourcenum'}; +% } +% +% $source_pkey = $opt{'num_col'} || $source_pkey; +% +% my $link_static = $opt{'link_static'} || {}; +% +% +% foreach my $name ( @{ $opt{'names_list'} } ) { +% +% my $checked; +% if ( $cgi->param('error') ) { +% +% $checked = $cgi->param($opt{'link_table'}. ".$name" ) +% ? 'CHECKED' +% : ''; +% +% } else { +% +% $checked = +% qsearchs( $opt{'link_table'}, { +% $source_pkey => $sourcenum, +% $opt{'name_col'} => $name, +% %$link_static, +% } ) +% ? 'CHECKED' +% : '' +% +% } +% +% + + + <INPUT TYPE="checkbox" NAME="<% $opt{'link_table'}. ".$name" %>" <% $checked %> VALUE="ON"> + + <% $name %> <BR> +% } -<% } %> diff --git a/httemplate/elements/checkboxes-table.html b/httemplate/elements/checkboxes-table.html index 16376fa3d..cdfa58eca 100644 --- a/httemplate/elements/checkboxes-table.html +++ b/httemplate/elements/checkboxes-table.html @@ -1,122 +1,123 @@ -<% +% +% +% ## +% # required +% ## +% # 'target_table' => 'table_name', +% # 'link_table' => 'table_name', +% # +% # 'name_col' => 'name_column', +% # #or +% # 'name_callback' => sub { }, +% # +% ## +% # recommended (required?) +% ## +% # 'source_obj' => $obj, +% # #or? +% # #'source_table' => 'table_name', +% # #'sourcenum' => '4', #current value of primary key in source_table +% # # # (none is okay, just pass it if you have it) +% ## +% # optional +% ## +% # 'disable-able' => 1, +% +% my( %opt ) = @_; +% +% my $target_pkey = dbdef->table($opt{'target_table'})->primary_key; +% +% my( $source_pkey, $sourcenum, $source_obj ); +% if ( $opt{'source_obj'} ) { +% +% $source_obj = $opt{'source_obj'}; +% #$source_table = $source_obj->dbdef_table->table; +% $source_pkey = $source_obj->dbdef_table->primary_key; +% $sourcenum = $source_obj->$source_pkey(); +% +% } else { +% +% #$source_obj? +% $source_pkey = $opt{'source_table'} +% ? dbdef->table($opt{'source_table'})->primary_key +% : ''; +% $sourcenum = $opt{'sourcenum'}; +% } +% +% my $hashref = $opt{'hashref'} || {}; +% +% my $extra_sql = ''; +% +% if ( $opt{'disable-able'} ) { +% $hashref->{'disabled'} = ''; +% +% $extra_sql .= ( $sourcenum && $source_pkey ) +% ? "OR $source_pkey = $sourcenum" +% : ''; +% } +% +% +% foreach my $target_obj ( +% qsearch({ 'table' => $opt{'target_table'}, +% 'hashref' => $hashref, +% 'select' => $opt{'target_table'}. '.*', +% 'addl_from' => "LEFT JOIN $opt{'link_table'} USING ( $target_pkey )", +% 'extra_sql' => $extra_sql, +% }) +% ) { +% +% my $targetnum = $target_obj->$target_pkey(); +% +% my $checked; +% if ( $cgi->param('error') ) { +% +% $checked = $cgi->param($target_pkey.$targetnum) +% ? 'CHECKED' +% : ''; +% +% } else { +% +% $checked = qsearchs( $opt{'link_table'}, { +% $source_pkey => $sourcenum, +% $target_pkey => $targetnum, +% } ) +% ? 'CHECKED' +% : '' +% +% } +% +% + + + <INPUT TYPE="checkbox" NAME="<% $target_pkey. $targetnum %>" <% $checked %> VALUE="ON"> +% if ( $opt{'target_link'} ) { + + + <A HREF="<% $opt{'target_link'} %><% $targetnum %>"> +% +% +% } +% +<% $targetnum %>: +% if ( $opt{'name_callback'} ) { + + + <% &{ $opt{'name_callback'} }( $target_obj ) %><% $opt{'target_link'} ? '</A>' : '' %> +% } else { +% my $name_col = $opt{'name_col'}; +% + + + <% $target_obj->$name_col() %><% $opt{'target_link'} ? '</A>' : '' %> +% } +% if ( $opt{'disable-able'} ) { + + + <% $target_obj->disabled =~ /^Y/i ? ' (DISABLED)' : '' %> +% } - ## - # required - ## - # 'target_table' => 'table_name', - # 'link_table' => 'table_name', - # - # 'name_col' => 'name_column', - # #or - # 'name_callback' => sub { }, - # - ## - # recommended (required?) - ## - # 'source_obj' => $obj, - # #or? - # #'source_table' => 'table_name', - # #'sourcenum' => '4', #current value of primary key in source_table - # # # (none is okay, just pass it if you have it) - ## - # optional - ## - # 'disable-able' => 1, - - my( %opt ) = @_; - - my $target_pkey = dbdef->table($opt{'target_table'})->primary_key; - - my( $source_pkey, $sourcenum, $source_obj ); - if ( $opt{'source_obj'} ) { - - $source_obj = $opt{'source_obj'}; - #$source_table = $source_obj->dbdef_table->table; - $source_pkey = $source_obj->dbdef_table->primary_key; - $sourcenum = $source_obj->$source_pkey(); - - } else { - - #$source_obj? - $source_pkey = $opt{'source_table'} - ? dbdef->table($opt{'source_table'})->primary_key - : ''; - $sourcenum = $opt{'sourcenum'}; - } - - my $hashref = $opt{'hashref'} || {}; - - my $extra_sql = ''; - - if ( $opt{'disable-able'} ) { - $hashref->{'disabled'} = ''; - - $extra_sql .= ( $sourcenum && $source_pkey ) - ? "OR $source_pkey = $sourcenum" - : ''; - } - -%> - -<% foreach my $target_obj ( - qsearch({ 'table' => $opt{'target_table'}, - 'hashref' => $hashref, - 'select' => $opt{'target_table'}. '.*', - 'addl_from' => "LEFT JOIN $opt{'link_table'} USING ( $target_pkey )", - 'extra_sql' => $extra_sql, - }) - ) { - - my $targetnum = $target_obj->$target_pkey(); - - my $checked; - if ( $cgi->param('error') ) { - - $checked = $cgi->param($target_pkey.$targetnum) - ? 'CHECKED' - : ''; - - } else { - - $checked = qsearchs( $opt{'link_table'}, { - $source_pkey => $sourcenum, - $target_pkey => $targetnum, - } ) - ? 'CHECKED' - : '' - - } - -%> - - <INPUT TYPE="checkbox" NAME="<%= $target_pkey. $targetnum %>" <%= $checked %> VALUE="ON"> - - <% if ( $opt{'target_link'} ) { %> - - <A HREF="<%= $opt{'target_link'} %><%= $targetnum %>"><% - - } - %><%= $targetnum %>: - - <% if ( $opt{'name_callback'} ) { %> - - <%= &{ $opt{'name_callback'} }( $target_obj ) %><%= $opt{'target_link'} ? '</A>' : '' %> - - <% } else { - my $name_col = $opt{'name_col'}; - %> - - <%= $target_obj->$name_col() %><%= $opt{'target_link'} ? '</A>' : '' %> - - <% } %> - - <% if ( $opt{'disable-able'} ) { %> - - <%= $target_obj->disabled =~ /^Y/i ? ' (DISABLED)' : '' %> - - <% } %> <BR> +% } -<% } %> diff --git a/httemplate/elements/header-popup.html b/httemplate/elements/header-popup.html index 73377abfe..43d9bc3af 100644 --- a/httemplate/elements/header-popup.html +++ b/httemplate/elements/header-popup.html @@ -1,22 +1,23 @@ -<% - my($title, $menubar) = ( shift, shift ); #$menubar is unused here though - my $etc = @_ ? shift : ''; #$etc is for things like onLoad= etc. - my $head = @_ ? shift : ''; #$head is for things that go in the <HEAD> section - my $conf = new FS::Conf; -%> +% +% my($title, $menubar) = ( shift, shift ); #$menubar is unused here though +% my $etc = @_ ? shift : ''; #$etc is for things like onLoad= etc. +% my $head = @_ ? shift : ''; #$head is for things that go in the <HEAD> section +% my $conf = new FS::Conf; +% + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD> <TITLE> - <%= $title %> + <% $title %> </TITLE> <META HTTP-Equiv="Cache-Control" Content="no-cache"> <META HTTP-Equiv="Pragma" Content="no-cache"> <META HTTP-Equiv="Expires" Content="0"> - <%= $head %> + <% $head %> </HEAD> - <BODY BGCOLOR="#e8e8e8" <%= $etc %>> + <BODY BGCOLOR="#e8e8e8" <% $etc %>> <FONT SIZE=6> - <CENTER><%= $title %></CENTER> + <CENTER><% $title %></CENTER> </FONT> <BR><!--<BR>--> diff --git a/httemplate/elements/header.html b/httemplate/elements/header.html index ea8c418c3..ca74ca5b9 100644 --- a/httemplate/elements/header.html +++ b/httemplate/elements/header.html @@ -1,21 +1,22 @@ -<% - my($title, $menubar) = ( shift, shift ); - my $etc = @_ ? shift : ''; #$etc is for things like onLoad= etc. - my $head = @_ ? shift : ''; #$head is for things that go in the <HEAD> section - my $conf = new FS::Conf; +% +% my($title, $menubar) = ( shift, shift ); +% my $etc = @_ ? shift : ''; #$etc is for things like onLoad= etc. +% my $head = @_ ? shift : ''; #$head is for things that go in the <HEAD> section +% my $conf = new FS::Conf; +% +% -%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD> <TITLE> - <%= $title %> + <% $title %> </TITLE> <META HTTP-Equiv="Cache-Control" Content="no-cache"> <META HTTP-Equiv="Pragma" Content="no-cache"> <META HTTP-Equiv="Expires" Content="0"> - <%= include('menu.html', 'freeside_baseurl' => $fsurl ) %> + <% include('menu.html', 'freeside_baseurl' => $fsurl ) %> <SCRIPT TYPE="text/javascript"> function clearhint_search_cust (what) { @@ -39,17 +40,17 @@ } </SCRIPT> - <%= $head %> + <% $head %> </HEAD> - <BODY BACKGROUND="<%=$fsurl%>images/background-cheat.png" <%= $etc %> STYLE="margin-top:0; margin-bottom:0; margin-left:0; margin-right:0"> + <BODY BACKGROUND="<%$fsurl%>images/background-cheat.png" <% $etc %> STYLE="margin-top:0; margin-bottom:0; margin-left:0; margin-right:0"> <table width="100%" CELLPADDING=0 CELLSPACING=0 STYLE="padding-left:0; padding-right:4"> <tr> - <td rowspan=2 BGCOLOR="#ffffff"><IMG BORDER=0 ALT="freeside" SRC="<%=$fsurl%>images/small-logo.png"></td> + <td rowspan=2 BGCOLOR="#ffffff"><IMG BORDER=0 ALT="freeside" SRC="<%$fsurl%>images/small-logo.png"></td> <td align=left rowspan=2 BGCOLOR="#ffffff"> <!-- valign="top" --> - <font size=6><%= $conf->config('company_name') || 'ExampleCo' %></font> + <font size=6><% $conf->config('company_name') || 'ExampleCo' %></font> </td> - <td align=right valign=top BGCOLOR="#ffffff"><FONT SIZE="-1">Logged in as <b><%= getotaker %> </b><br></FONT><FONT SIZE="-2"><a href="<%=$fsurl%>pref/XXXwritethis">Preferences</a> <BR></FONT> + <td align=right valign=top BGCOLOR="#ffffff"><FONT SIZE="-1">Logged in as <b><% getotaker %> </b><br></FONT><FONT SIZE="-2"><a href="<%$fsurl%>pref/XXXwritethis">Preferences</a> <BR></FONT> </td> </tr> <tr> @@ -59,20 +60,22 @@ <tr> <td align=right BGCOLOR="#ffffff"> <FONT SIZE="-2"> - <A HREF="http://www.sisd.com/freeside">Freeside</A> v<%= $FS::VERSION %><BR> - <A HREF="<%= $fsurl %>docs/">Documentation</A><BR> + <A HREF="http://www.sisd.com/freeside">Freeside</A> v<% $FS::VERSION %><BR> + <A HREF="<% $fsurl %>docs/">Documentation</A><BR> </FONT> </td> - <% if ( $conf->config('ticket_system') eq 'RT_Internal' ) { %> - <% eval "use RT;"; %> +% if ( $conf->config('ticket_system') eq 'RT_Internal' ) { +% eval "use RT;"; + <td bgcolor=#000000></td> <td align=left> <FONT SIZE="-2"> - <A HREF="http://www.bestpractical.com/rt">RT<A> v<%= $RT::VERSION %><BR> + <A HREF="http://www.bestpractical.com/rt">RT<A> v<% $RT::VERSION %><BR> <A HREF="http://wiki.bestpractical.com/">Documentation</A><BR> </FONT> </td> - <% } %> +% } + </tr> </table> @@ -115,50 +118,54 @@ input.fsblackbuttonselected { <TABLE WIDTH="100%" CELLSPACING=0 CELLPADDING=0> <TR> - <TD COLSPAN=5 WIDTH="100%" STYLE="padding:0"><IMG BORDER=0 ALT="" SRC="<%=$fsurl%>images/black-gradient.png" HEIGHT="13" WIDTH="100%"></TD> + <TD COLSPAN=5 WIDTH="100%" STYLE="padding:0"><IMG BORDER=0 ALT="" SRC="<%$fsurl%>images/black-gradient.png" HEIGHT="13" WIDTH="100%"></TD> </TR> <TR> <TD COLSPAN=1 BGCOLOR="#000000" ALIGN="right"> - <FORM ACTION="<%=$fsurl%>edit/cust_main.cgi" METHOD="GET" STYLE="margin:0"> + <FORM ACTION="<%$fsurl%>edit/cust_main.cgi" METHOD="GET" STYLE="margin:0"> <INPUT TYPE="submit" VALUE="New customer" CLASS="fsblackbutton" onMouseOver="this.className='fsblackbuttonselected'; return true;" onMouseOut="this.className='fsblackbutton'; return true;" STYLE="vertical-align:bottom"> </FORM> </TD> <TD COLSPAN=1 BGCOLOR="#000000" ALIGN="right"> - <FORM ACTION="<%=$fsurl%>search/cust_main.cgi" METHOD="GET" STYLE="margin:0"> + <FORM ACTION="<%$fsurl%>search/cust_main.cgi" METHOD="GET" STYLE="margin:0"> <INPUT NAME="search_cust" TYPE="text" VALUE="(cust #, name, company or phone)" SIZE="28" onFocus="clearhint_search_cust(this);" onClick="clearhint_search_cust(this);" STYLE="vertical-align:bottom;text-align:right"><BR> - <A HREF="<%=$fsurl%>search/cust_main.html" STYLE="color: #000000; font-size: 70%">Advanced</A> + <A HREF="<%$fsurl%>search/cust_main.html" STYLE="color: #000000; font-size: 70%">Advanced</A> <INPUT TYPE="submit" VALUE="Search customers" CLASS="fsblackbutton" onMouseOver="this.className='fsblackbuttonselected'; return true;" onMouseOut="this.className='fsblackbutton'; return true;" STYLE="font-size:70%"> </FORM> </TD> <TD COLSPAN=1 BGCOLOR="#000000" ALIGN="right"> - <% if ( $FS::CurrentUser::CurrentUser->access_right('View invoices') ) { %> - <FORM ACTION="<%=$fsurl%>search/cust_bill.html" METHOD="GET" STYLE="margin:0;display:inline"> +% if ( $FS::CurrentUser::CurrentUser->access_right('View invoices') ) { + + <FORM ACTION="<%$fsurl%>search/cust_bill.html" METHOD="GET" STYLE="margin:0;display:inline"> <INPUT NAME="invnum" TYPE="text" VALUE="(inv #)" SIZE="4" onFocus="clearhint_search_invoice(this);" onClick="clearhint_search_invoice(this);" STYLE="vertical-align:bottom;text-align:right;margin-bottom:1px"> - <% if ( $FS::CurrentUser::CurrentUser->access_right('List invoices') ) { %> - <A HREF="<%=$fsurl%>search/report_cust_bill.html" STYLE="color: #ffffff; font-size: 70%">Advanced</A> - <% } %> +% if ( $FS::CurrentUser::CurrentUser->access_right('List invoices') ) { + + <A HREF="<%$fsurl%>search/report_cust_bill.html" STYLE="color: #ffffff; font-size: 70%">Advanced</A> +% } + <BR> <INPUT TYPE="submit" VALUE="Search invoices" CLASS="fsblackbutton" onMouseOver="this.className='fsblackbuttonselected'; return true;" onMouseOut="this.className='fsblackbutton'; return true;" STYLE="font-size:70%"> </FORM> - <% } %> +% } + </TD> <TD COLSPAN=1 BGCOLOR="#000000" ALIGN="right"> - <FORM ACTION="<%=$fsurl%>search/svc_Smart.html" METHOD="GET" STYLE="margin:0"> + <FORM ACTION="<%$fsurl%>search/svc_Smart.html" METHOD="GET" STYLE="margin:0"> <INPUT NAME="search_svc" TYPE="text" VALUE="(user, user@domain or domain)" SIZE="26" onFocus="clearhint_search_svc(this);" onClick="clearhint_search_svc(this);" STYLE="vertical-align:bottom;text-align:right"><BR> - <A HREF="<%=$fsurl%>search/svc_Smarter.html" STYLE="color: #000000; font-size: 70%">Advanced</A> + <A HREF="<%$fsurl%>search/svc_Smarter.html" STYLE="color: #000000; font-size: 70%">Advanced</A> <INPUT TYPE="submit" VALUE="Search services"CLASS="fsblackbutton" onMouseOver="this.className='fsblackbuttonselected'; return true;" onMouseOut="this.className='fsblackbutton'; return true;" STYLE="font-size:70%"> </FORM> </TD> <TD COLSPAN=1 BGCOLOR="#000000" ALIGN="right" STYLE="padding-right:4px"> - <FORM ACTION="<%=$fsurl%>rt/index.html" METHOD="GET" STYLE="margin:0"> + <FORM ACTION="<%$fsurl%>rt/index.html" METHOD="GET" STYLE="margin:0"> <INPUT NAME="q" TYPE="text" VALUE="(ticket # or subject string)" onFocus="clearhint_search_ticket(this);" onClick="clearhint_search_ticket(this);" STYLE="vertical-align:bottom;text-align:right"><BR> - <A HREF="<%=$fsurl%>rt/Search/Build.html" STYLE="color: #ffffff; font-size: 70%">Advanced</A> + <A HREF="<%$fsurl%>rt/Search/Build.html" STYLE="color: #ffffff; font-size: 70%">Advanced</A> <INPUT TYPE="submit" VALUE="Search tickets" CLASS="fsblackbutton" onMouseOver="this.className='fsblackbuttonselected'; return true;" onMouseOut="this.className='fsblackbutton'; return true;" STYLE="font-size:70%;padding-left:2px;padding-right:2px"> </FORM> </TD> @@ -168,8 +175,8 @@ input.fsblackbuttonselected { <TABLE WIDTH="100%" HEIGHT="100%" CELLSPACING=0 CELLPADDING=4> <TR> <TD BGCOLOR="#000000" STYLE="padding:0" WIDTH="154"></TD> - <TD STYLE="padding:0" WIDTH="13"><IMG BORDER=0 ALT="" SRC="<%=$fsurl%>images/black-gray-corner.png"></TD> - <TD STYLE="padding:0"><IMG BORDER=0 ALT="" SRC="<%=$fsurl%>images/black-gray-top.png" HEIGHT="13" WIDTH="100%"></TD> + <TD STYLE="padding:0" WIDTH="13"><IMG BORDER=0 ALT="" SRC="<%$fsurl%>images/black-gray-corner.png"></TD> + <TD STYLE="padding:0"><IMG BORDER=0 ALT="" SRC="<%$fsurl%>images/black-gray-top.png" HEIGHT="13" WIDTH="100%"></TD> </TR> <TR HEIGHT="100%"> <TD BGCOLOR="#000000" ALIGN="left" HEIGHT="100%" WIDTH="154" VALIGN="top" ALIGN="right"> @@ -177,15 +184,15 @@ input.fsblackbuttonselected { document.write(myBar); </SCRIPT> <BR> - <IMG SRC="<%=$fsurl%>images/32clear.gif" HEIGHT="1" WIDTH="154"> + <IMG SRC="<%$fsurl%>images/32clear.gif" HEIGHT="1" WIDTH="154"> </TD> - <TD STYLE="padding:0" HEIGHT="100%" WIDTH=13 VALIGN="top"><IMG WIDTH="13" HEIGHT="100%" BORDER=0 ALT="" SRC="<%=$fsurl%>images/black-gray-side.png"></TD> + <TD STYLE="padding:0" HEIGHT="100%" WIDTH=13 VALIGN="top"><IMG WIDTH="13" HEIGHT="100%" BORDER=0 ALT="" SRC="<%$fsurl%>images/black-gray-side.png"></TD> <TD BGCOLOR="#e8e8e8" HEIGHT="100%"> <!-- WIDTH="100%"> --> <FONT SIZE=6> - <%= $title %> + <% $title %> </FONT> <BR><BR> - <%= $menubar !~ /^\s*$/ ? "$menubar<BR><BR>" : '' %> + <% $menubar !~ /^\s*$/ ? "$menubar<BR><BR>" : '' %> diff --git a/httemplate/elements/jsrsServer.html b/httemplate/elements/jsrsServer.html index fd6dc5465..f37b0aaee 100644 --- a/httemplate/elements/jsrsServer.html +++ b/httemplate/elements/jsrsServer.html @@ -1,3 +1,4 @@ -<% - my $server = new FS::UI::Web::JSRPC '', $cgi; -%><%= $server->process %> +% +% my $server = new FS::UI::Web::JSRPC '', $cgi; +% +<% $server->process %> diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index a5b41aefd..f05866046 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -1,329 +1,330 @@ -<% - my( %opt ) = @_; - my $conf = new FS::Conf; - my $fsurl = $opt{'freeside_baseurl'}; - - my $curuser = $FS::CurrentUser::CurrentUser; - - #Active tickets not assigned to a customer - - 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', '' ], - 'by company name' => [ $fsurl. 'search/cust_main.cgi?browse=company', '' ], - 'by active trouble tickets' => [ $fsurl. 'search/cust_main.cgi?browse=tickets', '' ], - ; - - tie my %report_customers_search, 'Tie::IxHash', - 'by ordering employee' => [ $fsurl. 'search/cust_main-otaker.cgi' ], - ; - - tie my %report_customers, 'Tie::IxHash', - 'List customers' => [ \%report_customers_lists, 'List customers' ], - 'Search customers' => [ \%report_customers_search, 'Search customers' ], - 'Zip code distribution' => [ $fsurl.'search/report_cust_main-zip.html', 'Zip codes by number of customers' ], - ; - - tie my %report_invoices_open, 'Tie::IxHash', - 'All open invoices' => [ $fsurl.'search/cust_bill.html?OPEN_date', 'All invoices with an unpaid balance' ], - '15 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN15_date', 'Invoices 15 days or older with an unpaid balance' ], - '30 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN30_date', 'Invoices 30 days or older with an unpaid balance' ], - '60 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN60_date', 'Invoices 60 days or older with an unpaid balance' ], - '90 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN90_date', 'Invoices 90 days or older with an unpaid balance' ], - '120 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN120_date', 'Invoices 120 days or older with an unpaid balance' ], - ; - - tie my %report_invoices, 'Tie::IxHash', - 'Open invoices' => [ \%report_invoices_open, 'Open invoices' ], - 'All invoices' => [ $fsurl. 'search/cust_bill.html?date', 'List all invoices' ], - 'Advanced invoice reports' => [ $fsurl.'search/report_cust_bill.html', 'by agent, date range, etc.' ], - ; - - tie my %report_services_acct, 'Tie::IxHash', - 'All accounts by username' => [ $fsurl.'search/svc_acct.cgi?username', '' ], - 'All accounts by UID' => [ $fsurl.'search/svc_acct.cgi?uid', '' ], - ; - $report_services_acct{'Unlinked accounts'} = [ $fsurl.'search/svc_acct.cgi?UN_uid', 'Pre-Freeside accounts without a customer record' ] - if $curuser->access_right('View/link unlinked services'); - - tie my %report_services_domain, 'Tie::IxHash', - 'All domains' => [ $fsurl.'search/svc_domain.cgi?domain', '' ], - ; - $report_services_domain{'Unlinked domains'} = [ $fsurl.'search/svc_domain.cgi?UN_domain', 'Pre-Freeside domains without a customer record' ] - if $curuser->access_right('View/link unlinked services'); - - tie my %report_services_forward, 'Tie::IxHash', - 'All mail forwards' => [ $fsurl.'search/svc_forward.cgi?svcnum', '' ], - ; - $report_services_forward{'Unlinked mail forwards'} = [ $fsurl.'search/svc_forward.cgi?UN_svcnum', 'Pre-Freeside mail forwards without a customer record' ] - if $curuser->access_right('View/link unlinked services'); - - tie my %report_services_www, 'Tie::IxHash', - 'All virtual hosts' => [ $fsurl.'search/svc_www.cgi?svcnum', '' ], - ; - $report_services_www{'Unlinked virtual hosts'} = [ $fsurl.'search/svc_www.cgi?UN_svcnum', 'Pre-Freeside virtual hosts without a customer record' ] - if $curuser->access_right('View/link unlinked services'); - - tie my %report_services_broadband, 'Tie::IxHash', - 'All broadband services' => [ $fsurl.'search/svc_broadband.cgi?svcnum', '' ], - #'Unlinked domain' => [ $fsurl.'search/svc_acct.cgi?UN_uid', 'Pre-Freeside domains without a customer record' ], - ; - - tie my %report_services_phone, 'Tie::IxHash', - 'All phone numbers' => [ $fsurl.'search/svc_phone.cgi?svcnum', '' ], - ; - - tie my %report_services_external, 'Tie::IxHash', - 'All external services' => [ $fsurl.'search/svc_external.cgi?id', '' ], - ; - $report_services_external{'Unlinked external services'} = [ $fsurl.'search/svc_external.cgi?UN_id', 'Pre-Freeside domains without a customer record' ] - if $curuser->access_right('View/link unlinked services'); - - tie my %report_services, 'Tie::IxHash'; - if ( $curuser->access_right('Configuration') ) { - $report_services{'Service definitions'} = [ $fsurl.'browse/part_svc.cgi?orderby=active', 'Service definitions by number of active packages' ]; - $report_services{'separator'} = ''; - } - $report_services{'Accounts'} = [ \%report_services_acct, 'Access accounts and mailboxes' ]; - $report_services{'Domains'} = [ \%report_services_domain, 'Domains', ]; - $report_services{'Mail forwards'} = [ \%report_services_forward, 'Mail forwards', ]; - $report_services{'Virtual hosts'} = [ \%report_services_www, 'Virtual hosting', ]; - $report_services{'Broadband services'} = [ \%report_services_broadband, 'Fixed (username-less) broadband services', ]; - $report_services{'Phone numbers'} = [ \%report_services_phone, 'Telephone numbers', ]; - $report_services{'External services'} = [ \%report_services_external, 'External services', ]; - - tie my %report_packages, 'Tie::IxHash'; - if ( $curuser->access_right('Configuration') ) { - $report_packages{'Package definitions'} = [ $fsurl.'browse/part_pkg.cgi?active=1', 'Package definitions by number of active packages' ]; - $report_packages{'separator'} = ''; - } - $report_packages{'All customer packages'} = [ $fsurl.'search/cust_pkg.cgi?pkgnum', 'List all customer packages', ]; - $report_packages{'Suspended customer packages'} = [ $fsurl.'search/cust_pkg.cgi?magic=suspended', 'List suspended packages' ]; - $report_packages{'Customer packages with unconfigured services'} = [ $fsurl.'search/cust_pkg.cgi?APKG_pkgnum', 'List packages which have provisionable services' ]; - $report_packages{'Advanced package reports'} = [ $fsurl.'search/report_cust_pkg.html', 'by agent, date range, status, package definition' ]; - - tie my %report_rating, 'Tie::IxHash', - 'Call Detail Records (CDRs)' => [ $fsurl.'search/report_cdr.html', '' ], - ; - - tie my %report_financial, 'Tie::IxHash', - 'Sales, Credits and Receipts' => [ $fsurl.'graph/report_money_time.html', 'Sales, credits and receipts summary graph' ], - 'Sales Report' => [ $fsurl.'graph/report_cust_bill_pkg.html', 'Sales report and graph (by agent, package class and/or date range)' ], - 'Credit Report' => [ $fsurl.'search/report_cust_credit.html', 'Credit report (by employee and/or date range)' ], - 'Payment Report' => [ $fsurl.'search/report_cust_pay.html', 'Credit report (by type and/or date range)' ], - 'A/R Aging' => [ $fsurl.'search/report_receivables.html', 'Accounts Receivable Aging report' ], - 'Prepaid Income' => [ $fsurl.'search/report_prepaid_income.html', 'Prepaid income (unearned revenue) report' ], - 'Sales Tax Liability' => [ $fsurl.'search/report_tax.html', 'Sales tax liability report' ], - ; - - tie my %report_menu, 'Tie::IxHash'; - $report_menu{'Customers'} = [ \%report_customers, 'Customer reports' ] - if $curuser->access_right('List customers'); - $report_menu{'Invoices'} = [ \%report_invoices, 'Invoice reports' ] - if $curuser->access_right('List invoices'); - $report_menu{'Packages'} = [ \%report_packages, 'Package reports' ] - if $curuser->access_right('List packages'); - $report_menu{'Services'} = [ \%report_services, 'Services reports' ] - if $curuser->access_right('List services'); - $report_menu{'Rating data'} = [ \%report_rating, 'Rating reports' ] - if $curuser->access_right('List rating data'); - $report_menu{'Financial'} = [ \%report_financial, 'Financial reports' ] - if $curuser->access_right('Financial reports'); - - tie my %tools_importing, 'Tie::IxHash', - 'Import customers from CSV file' => [ $fsurl.'misc/cust_main-import.cgi', '' ], - 'Import one-time charges from CSV file' => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ], - 'Import Call Detail Records (CDRs) from CSV file' => [ $fsurl.'misc/cdr-import.html', '' ], - ; - - tie my %tools_exporting, 'Tie::IxHash', - 'Download database dump' => [ $fsurl. 'misc/dump.cgi', '' ], - ; - - # <!-- <BR>View active NAS ports: - # <A HREF="browse/nas.cgi">session server</A> --> - # <!-- or <A HREF="browse/nas-sqlradius.cgi">RADIUS</A> - # <BR> --> - - tie my %tools_menu, 'Tie::IxHash', (); - $tools_menu{'Quick payment entry'} = [ $fsurl.'misc/batch-cust_pay.html', 'Enter multiple payments in a batch' ] - if $curuser->access_right('Post payment batch'); - $tools_menu{'Job Queue'} = [ $fsurl.'search/queue.html', 'View pending job queue' ] - if $curuser->access_right('Job queue'); - $tools_menu{'Importing'} = [ \%tools_importing, 'Import tools' ] - if $curuser->access_right('Import'); - $tools_menu{'Exporting'} = [ \%tools_exporting, 'Export tools' ] - if $curuser->access_right('Export'); - - tie my %config_employees, 'Tie::IxHash', - 'View/Edit employees' => [ $fsurl.'browse/access_user.html', 'Setup internal users' ], - 'View/Edit employee groups' => [ $fsurl.'browse/access_group.html', 'Employee groups allow you to control access to the backend' ], - ; - - tie my %config_export_svc_pkg, 'Tie::IxHash', - 'View/Edit exports' => [ $fsurl.'browse/part_export.cgi', 'Provisioning services to external machines, databases and APIs' ], - 'View/Edit service definitions' => [ $fsurl.'browse/part_svc.cgi', 'Services are items you offer to your customers' ], - 'View/Edit package definitions' => [ $fsurl.'browse/part_pkg.cgi', 'One or more services are grouped together into a package and given pricing information. Customers purchase packages, not services' ], - 'View/Edit package classes' => [ $fsurl.'browse/pkg_class.html', 'Package classes define groups of packages, for reporting and convenience purposes.' ], - ; - - tie my %config_agent, 'Tie::IxHash', - 'View/Edit agent types' => [ $fsurl.'browse/agent_type.cgi', 'Agent types define groups of package definitions that you can then assign to particular agents' ], - 'View/Edit agents' => [ $fsurl.'browse/agent.cgi', 'Agents are resellers of your service. Agents may be limited to a subset of your full offerings (via their type)' ], - ; - - tie my %config_billing, 'Tie::IxHash', - 'View/Edit payment gateways' => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors' ], - 'View/Edit invoice events' => [ $fsurl.'browse/part_bill_event.cgi', 'Actions for overdue invoices' ], - 'View/Edit prepaid cards' => [ $fsurl.'search/prepay_credit.html', 'View outstanding cards, generate new cards' ], - 'View/Edit call rates and regions' => [ $fsurl.'browse/rate.cgi', 'Manage rate plans, regions and prefixes for VoIP and call billing' ], - 'View/Edit locales and tax rates' => [ $fsurl.'browse/cust_main_county.cgi', 'Change tax rates, or break down a country into states, or a state into counties and assign different tax rates to each' ], - ; - - tie my %config_dialup, 'Tie::IxHash', - 'View/Edit access numbers' => [ $fsurl.'browse/svc_acct_pop.cgi', 'Points of Presence' ], - ; - - tie my %config_broadband, 'Tie::IxHash', - 'View/Edit routers' => [ $fsurl.'browse/router.cgi', 'Broadband access routers' ], - 'View/Edit address blocks' => [ $fsurl.'browse/addr_block.cgi', 'Manage address blocks and block assignments to broadband routers' ], - ; - - tie my %config_misc, 'Tie::IxHash'; - $config_misc{'View/Edit advertising sources'} = [ $fsurl.'browse/part_referral.html', 'Where a customer heard about your service. Tracked for informational purposes' ] - if $curuser->access_right('Configuration') - || $curuser->access_right('Edit advertising sources') - || $curuser->access_right('Edit global advertising sources'); - if ( $curuser->access_right('Configuration') ) { - $config_misc{'View/Edit virtual fields'} = [ $fsurl.'browse/part_virtual_field.cgi', 'Locally defined fields', ]; - $config_misc{'View/Edit message catalog'} = [ $fsurl.'browse/msgcat.cgi', 'Change error messages and other customizable labels' ]; - $config_misc{'View/Edit inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ]; - } - - tie my %config_menu, 'Tie::IxHash'; - if ( $curuser->access_right('Configuration' ) ) { - %config_menu = ( - 'Settings' => [ $fsurl.'config/config-view.cgi', '' ], - 'separator' => '', #its a separator! - 'Employees' => [ \%config_employees, '' ], - 'Provisioning, services and packages' - => [ \%config_export_svc_pkg, '' ], - 'Resellers' => [ \%config_agent, '' ], - 'Billing' => [ \%config_billing, '' ], - 'Dialup' => [ \%config_dialup, '' ], - 'Fixed (username-less) broadband' - => [ \%config_broadband, '' ], - ); - } - $config_menu{'Miscellaneous'} = [ \%config_misc, '' ] - if $curuser->access_right('Configuration') - || $curuser->access_right('Edit advertising sources') - || $curuser->access_right('Edit global advertising sources'); - - tie my %menu, 'Tie::IxHash', - 'Billing Main' => [ $fsurl, 'Billing start page', ], - 'Ticketing Main' => [ - ( $conf->config('ticket_system') eq 'RT_External' - ? FS::TicketSystem->baseurl() - : $fsurl.'rt/' - ), - 'Ticketing start page', - ], - ; - $menu{'Reports'} = [ \%report_menu, 'Lists, reporting and graphing' ] - if keys %report_menu; - $menu{'Tools'} = [ \%tools_menu, 'Tools' ] - if keys %tools_menu; - $menu{'Configuration'} = [ \%config_menu, 'Configuraiton and setup' ] - if $curuser->access_right('Configuration') - || $curuser->access_right('Edit advertising sources') - || $curuser->access_right('Edit global advertising sources'); - - use vars qw($gmenunum); - $gmenunum = 0; - - sub submenu { - my($submenu, $title) = @_; - my $menunum = $gmenunum++; - - #return two args: html, menuname - - "var myMenu$menunum = new WebFXMenu;\n". - #"myMenu$menunum.useAutoPosition = true;\n". - "myMenu$menunum.emptyText = '$title';\n". - - ( - join("\n", map { - - if ( !ref( $submenu->{$_} ) ) { - - "myMenu$menunum.add(new WebFXMenuSeparator());"; - - } else { - - my($url_or_submenu, $tooltip ) = @{ $submenu->{$_} }; - if ( ref($url_or_submenu) ) { - - my($subhtml, $submenuname ) = submenu($url_or_submenu, $_); #mmm, recursion - - "$subhtml\n". - "myMenu$menunum.add(new WebFXMenuItem(\"$_\", null, \"$tooltip\", $submenuname ));"; - - } else { - - "myMenu$menunum.add(new WebFXMenuItem(\"$_\", \"$url_or_submenu\", \"$tooltip\" ));"; - - } - - } - - } keys %$submenu ) - ). "\n". - "myMenu$menunum.width = 224\n", - - "myMenu$menunum"; - - } - -%> - -<script type="text/javascript" src="<%=$fsurl%>elements/cssexpr.js"></script> -<script type="text/javascript" src="<%=$fsurl%>elements/xmenu.js"></script> -<link href="<%=$fsurl%>elements/xmenu.css" type="text/css" rel="stylesheet"> -<link href="<%=$fsurl%>elements/freeside.css" type="text/css" rel="stylesheet"> +% +% my( %opt ) = @_; +% my $conf = new FS::Conf; +% my $fsurl = $opt{'freeside_baseurl'}; +% +% my $curuser = $FS::CurrentUser::CurrentUser; +% +% #Active tickets not assigned to a customer +% +% 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', '' ], +% 'by company name' => [ $fsurl. 'search/cust_main.cgi?browse=company', '' ], +% 'by active trouble tickets' => [ $fsurl. 'search/cust_main.cgi?browse=tickets', '' ], +% ; +% +% tie my %report_customers_search, 'Tie::IxHash', +% 'by ordering employee' => [ $fsurl. 'search/cust_main-otaker.cgi' ], +% ; +% +% tie my %report_customers, 'Tie::IxHash', +% 'List customers' => [ \%report_customers_lists, 'List customers' ], +% 'Search customers' => [ \%report_customers_search, 'Search customers' ], +% 'Zip code distribution' => [ $fsurl.'search/report_cust_main-zip.html', 'Zip codes by number of customers' ], +% ; +% +% tie my %report_invoices_open, 'Tie::IxHash', +% 'All open invoices' => [ $fsurl.'search/cust_bill.html?OPEN_date', 'All invoices with an unpaid balance' ], +% '15 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN15_date', 'Invoices 15 days or older with an unpaid balance' ], +% '30 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN30_date', 'Invoices 30 days or older with an unpaid balance' ], +% '60 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN60_date', 'Invoices 60 days or older with an unpaid balance' ], +% '90 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN90_date', 'Invoices 90 days or older with an unpaid balance' ], +% '120 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN120_date', 'Invoices 120 days or older with an unpaid balance' ], +% ; +% +% tie my %report_invoices, 'Tie::IxHash', +% 'Open invoices' => [ \%report_invoices_open, 'Open invoices' ], +% 'All invoices' => [ $fsurl. 'search/cust_bill.html?date', 'List all invoices' ], +% 'Advanced invoice reports' => [ $fsurl.'search/report_cust_bill.html', 'by agent, date range, etc.' ], +% ; +% +% tie my %report_services_acct, 'Tie::IxHash', +% 'All accounts by username' => [ $fsurl.'search/svc_acct.cgi?username', '' ], +% 'All accounts by UID' => [ $fsurl.'search/svc_acct.cgi?uid', '' ], +% ; +% $report_services_acct{'Unlinked accounts'} = [ $fsurl.'search/svc_acct.cgi?UN_uid', 'Pre-Freeside accounts without a customer record' ] +% if $curuser->access_right('View/link unlinked services'); +% +% tie my %report_services_domain, 'Tie::IxHash', +% 'All domains' => [ $fsurl.'search/svc_domain.cgi?domain', '' ], +% ; +% $report_services_domain{'Unlinked domains'} = [ $fsurl.'search/svc_domain.cgi?UN_domain', 'Pre-Freeside domains without a customer record' ] +% if $curuser->access_right('View/link unlinked services'); +% +% tie my %report_services_forward, 'Tie::IxHash', +% 'All mail forwards' => [ $fsurl.'search/svc_forward.cgi?svcnum', '' ], +% ; +% $report_services_forward{'Unlinked mail forwards'} = [ $fsurl.'search/svc_forward.cgi?UN_svcnum', 'Pre-Freeside mail forwards without a customer record' ] +% if $curuser->access_right('View/link unlinked services'); +% +% tie my %report_services_www, 'Tie::IxHash', +% 'All virtual hosts' => [ $fsurl.'search/svc_www.cgi?svcnum', '' ], +% ; +% $report_services_www{'Unlinked virtual hosts'} = [ $fsurl.'search/svc_www.cgi?UN_svcnum', 'Pre-Freeside virtual hosts without a customer record' ] +% if $curuser->access_right('View/link unlinked services'); +% +% tie my %report_services_broadband, 'Tie::IxHash', +% 'All broadband services' => [ $fsurl.'search/svc_broadband.cgi?svcnum', '' ], +% #'Unlinked domain' => [ $fsurl.'search/svc_acct.cgi?UN_uid', 'Pre-Freeside domains without a customer record' ], +% ; +% +% tie my %report_services_phone, 'Tie::IxHash', +% 'All phone numbers' => [ $fsurl.'search/svc_phone.cgi?svcnum', '' ], +% ; +% +% tie my %report_services_external, 'Tie::IxHash', +% 'All external services' => [ $fsurl.'search/svc_external.cgi?id', '' ], +% ; +% $report_services_external{'Unlinked external services'} = [ $fsurl.'search/svc_external.cgi?UN_id', 'Pre-Freeside domains without a customer record' ] +% if $curuser->access_right('View/link unlinked services'); +% +% tie my %report_services, 'Tie::IxHash'; +% if ( $curuser->access_right('Configuration') ) { +% $report_services{'Service definitions'} = [ $fsurl.'browse/part_svc.cgi?orderby=active', 'Service definitions by number of active packages' ]; +% $report_services{'separator'} = ''; +% } +% $report_services{'Accounts'} = [ \%report_services_acct, 'Access accounts and mailboxes' ]; +% $report_services{'Domains'} = [ \%report_services_domain, 'Domains', ]; +% $report_services{'Mail forwards'} = [ \%report_services_forward, 'Mail forwards', ]; +% $report_services{'Virtual hosts'} = [ \%report_services_www, 'Virtual hosting', ]; +% $report_services{'Broadband services'} = [ \%report_services_broadband, 'Fixed (username-less) broadband services', ]; +% $report_services{'Phone numbers'} = [ \%report_services_phone, 'Telephone numbers', ]; +% $report_services{'External services'} = [ \%report_services_external, 'External services', ]; +% +% tie my %report_packages, 'Tie::IxHash'; +% if ( $curuser->access_right('Configuration') ) { +% $report_packages{'Package definitions'} = [ $fsurl.'browse/part_pkg.cgi?active=1', 'Package definitions by number of active packages' ]; +% $report_packages{'separator'} = ''; +% } +% $report_packages{'All customer packages'} = [ $fsurl.'search/cust_pkg.cgi?pkgnum', 'List all customer packages', ]; +% $report_packages{'Suspended customer packages'} = [ $fsurl.'search/cust_pkg.cgi?magic=suspended', 'List suspended packages' ]; +% $report_packages{'Customer packages with unconfigured services'} = [ $fsurl.'search/cust_pkg.cgi?APKG_pkgnum', 'List packages which have provisionable services' ]; +% $report_packages{'Advanced package reports'} = [ $fsurl.'search/report_cust_pkg.html', 'by agent, date range, status, package definition' ]; +% +% tie my %report_rating, 'Tie::IxHash', +% 'Call Detail Records (CDRs)' => [ $fsurl.'search/report_cdr.html', '' ], +% ; +% +% tie my %report_financial, 'Tie::IxHash', +% 'Sales, Credits and Receipts' => [ $fsurl.'graph/report_money_time.html', 'Sales, credits and receipts summary graph' ], +% 'Sales Report' => [ $fsurl.'graph/report_cust_bill_pkg.html', 'Sales report and graph (by agent, package class and/or date range)' ], +% 'Credit Report' => [ $fsurl.'search/report_cust_credit.html', 'Credit report (by employee and/or date range)' ], +% 'Payment Report' => [ $fsurl.'search/report_cust_pay.html', 'Credit report (by type and/or date range)' ], +% 'A/R Aging' => [ $fsurl.'search/report_receivables.html', 'Accounts Receivable Aging report' ], +% 'Prepaid Income' => [ $fsurl.'search/report_prepaid_income.html', 'Prepaid income (unearned revenue) report' ], +% 'Sales Tax Liability' => [ $fsurl.'search/report_tax.html', 'Sales tax liability report' ], +% ; +% +% tie my %report_menu, 'Tie::IxHash'; +% $report_menu{'Customers'} = [ \%report_customers, 'Customer reports' ] +% if $curuser->access_right('List customers'); +% $report_menu{'Invoices'} = [ \%report_invoices, 'Invoice reports' ] +% if $curuser->access_right('List invoices'); +% $report_menu{'Packages'} = [ \%report_packages, 'Package reports' ] +% if $curuser->access_right('List packages'); +% $report_menu{'Services'} = [ \%report_services, 'Services reports' ] +% if $curuser->access_right('List services'); +% $report_menu{'Rating data'} = [ \%report_rating, 'Rating reports' ] +% if $curuser->access_right('List rating data'); +% $report_menu{'Financial'} = [ \%report_financial, 'Financial reports' ] +% if $curuser->access_right('Financial reports'); +% +% tie my %tools_importing, 'Tie::IxHash', +% 'Import customers from CSV file' => [ $fsurl.'misc/cust_main-import.cgi', '' ], +% 'Import one-time charges from CSV file' => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ], +% 'Import Call Detail Records (CDRs) from CSV file' => [ $fsurl.'misc/cdr-import.html', '' ], +% ; +% +% tie my %tools_exporting, 'Tie::IxHash', +% 'Download database dump' => [ $fsurl. 'misc/dump.cgi', '' ], +% ; +% +% # <!-- <BR>View active NAS ports: +% # <A HREF="browse/nas.cgi">session server</A> --> +% # <!-- or <A HREF="browse/nas-sqlradius.cgi">RADIUS</A> +% # <BR> --> +% +% tie my %tools_menu, 'Tie::IxHash', (); +% $tools_menu{'Quick payment entry'} = [ $fsurl.'misc/batch-cust_pay.html', 'Enter multiple payments in a batch' ] +% if $curuser->access_right('Post payment batch'); +% $tools_menu{'Job Queue'} = [ $fsurl.'search/queue.html', 'View pending job queue' ] +% if $curuser->access_right('Job queue'); +% $tools_menu{'Importing'} = [ \%tools_importing, 'Import tools' ] +% if $curuser->access_right('Import'); +% $tools_menu{'Exporting'} = [ \%tools_exporting, 'Export tools' ] +% if $curuser->access_right('Export'); +% +% tie my %config_employees, 'Tie::IxHash', +% 'View/Edit employees' => [ $fsurl.'browse/access_user.html', 'Setup internal users' ], +% 'View/Edit employee groups' => [ $fsurl.'browse/access_group.html', 'Employee groups allow you to control access to the backend' ], +% ; +% +% tie my %config_export_svc_pkg, 'Tie::IxHash', +% 'View/Edit exports' => [ $fsurl.'browse/part_export.cgi', 'Provisioning services to external machines, databases and APIs' ], +% 'View/Edit service definitions' => [ $fsurl.'browse/part_svc.cgi', 'Services are items you offer to your customers' ], +% 'View/Edit package definitions' => [ $fsurl.'browse/part_pkg.cgi', 'One or more services are grouped together into a package and given pricing information. Customers purchase packages, not services' ], +% 'View/Edit package classes' => [ $fsurl.'browse/pkg_class.html', 'Package classes define groups of packages, for reporting and convenience purposes.' ], +% ; +% +% tie my %config_agent, 'Tie::IxHash', +% 'View/Edit agent types' => [ $fsurl.'browse/agent_type.cgi', 'Agent types define groups of package definitions that you can then assign to particular agents' ], +% 'View/Edit agents' => [ $fsurl.'browse/agent.cgi', 'Agents are resellers of your service. Agents may be limited to a subset of your full offerings (via their type)' ], +% ; +% +% tie my %config_billing, 'Tie::IxHash', +% 'View/Edit payment gateways' => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors' ], +% 'View/Edit invoice events' => [ $fsurl.'browse/part_bill_event.cgi', 'Actions for overdue invoices' ], +% 'View/Edit prepaid cards' => [ $fsurl.'search/prepay_credit.html', 'View outstanding cards, generate new cards' ], +% 'View/Edit call rates and regions' => [ $fsurl.'browse/rate.cgi', 'Manage rate plans, regions and prefixes for VoIP and call billing' ], +% 'View/Edit locales and tax rates' => [ $fsurl.'browse/cust_main_county.cgi', 'Change tax rates, or break down a country into states, or a state into counties and assign different tax rates to each' ], +% ; +% +% tie my %config_dialup, 'Tie::IxHash', +% 'View/Edit access numbers' => [ $fsurl.'browse/svc_acct_pop.cgi', 'Points of Presence' ], +% ; +% +% tie my %config_broadband, 'Tie::IxHash', +% 'View/Edit routers' => [ $fsurl.'browse/router.cgi', 'Broadband access routers' ], +% 'View/Edit address blocks' => [ $fsurl.'browse/addr_block.cgi', 'Manage address blocks and block assignments to broadband routers' ], +% ; +% +% tie my %config_misc, 'Tie::IxHash'; +% $config_misc{'View/Edit advertising sources'} = [ $fsurl.'browse/part_referral.html', 'Where a customer heard about your service. Tracked for informational purposes' ] +% if $curuser->access_right('Configuration') +% || $curuser->access_right('Edit advertising sources') +% || $curuser->access_right('Edit global advertising sources'); +% if ( $curuser->access_right('Configuration') ) { +% $config_misc{'View/Edit virtual fields'} = [ $fsurl.'browse/part_virtual_field.cgi', 'Locally defined fields', ]; +% $config_misc{'View/Edit message catalog'} = [ $fsurl.'browse/msgcat.cgi', 'Change error messages and other customizable labels' ]; +% $config_misc{'View/Edit inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ]; +% } +% +% tie my %config_menu, 'Tie::IxHash'; +% if ( $curuser->access_right('Configuration' ) ) { +% %config_menu = ( +% 'Settings' => [ $fsurl.'config/config-view.cgi', '' ], +% 'separator' => '', #its a separator! +% 'Employees' => [ \%config_employees, '' ], +% 'Provisioning, services and packages' +% => [ \%config_export_svc_pkg, '' ], +% 'Resellers' => [ \%config_agent, '' ], +% 'Billing' => [ \%config_billing, '' ], +% 'Dialup' => [ \%config_dialup, '' ], +% 'Fixed (username-less) broadband' +% => [ \%config_broadband, '' ], +% ); +% } +% $config_menu{'Miscellaneous'} = [ \%config_misc, '' ] +% if $curuser->access_right('Configuration') +% || $curuser->access_right('Edit advertising sources') +% || $curuser->access_right('Edit global advertising sources'); +% +% tie my %menu, 'Tie::IxHash', +% 'Billing Main' => [ $fsurl, 'Billing start page', ], +% 'Ticketing Main' => [ +% ( $conf->config('ticket_system') eq 'RT_External' +% ? FS::TicketSystem->baseurl() +% : $fsurl.'rt/' +% ), +% 'Ticketing start page', +% ], +% ; +% $menu{'Reports'} = [ \%report_menu, 'Lists, reporting and graphing' ] +% if keys %report_menu; +% $menu{'Tools'} = [ \%tools_menu, 'Tools' ] +% if keys %tools_menu; +% $menu{'Configuration'} = [ \%config_menu, 'Configuraiton and setup' ] +% if $curuser->access_right('Configuration') +% || $curuser->access_right('Edit advertising sources') +% || $curuser->access_right('Edit global advertising sources'); +% +% use vars qw($gmenunum); +% $gmenunum = 0; +% +% sub submenu { +% my($submenu, $title) = @_; +% my $menunum = $gmenunum++; +% +% #return two args: html, menuname +% +% "var myMenu$menunum = new WebFXMenu;\n". +% #"myMenu$menunum.useAutoPosition = true;\n". +% "myMenu$menunum.emptyText = '$title';\n". +% +% ( +% join("\n", map { +% +% if ( !ref( $submenu->{$_} ) ) { +% +% "myMenu$menunum.add(new WebFXMenuSeparator());"; +% +% } else { +% +% my($url_or_submenu, $tooltip ) = @{ $submenu->{$_} }; +% if ( ref($url_or_submenu) ) { +% +% my($subhtml, $submenuname ) = submenu($url_or_submenu, $_); #mmm, recursion +% +% "$subhtml\n". +% "myMenu$menunum.add(new WebFXMenuItem(\"$_\", null, \"$tooltip\", $submenuname ));"; +% +% } else { +% +% "myMenu$menunum.add(new WebFXMenuItem(\"$_\", \"$url_or_submenu\", \"$tooltip\" ));"; +% +% } +% +% } +% +% } keys %$submenu ) +% ). "\n". +% "myMenu$menunum.width = 224\n", +% +% "myMenu$menunum"; +% +% } +% +% + + +<script type="text/javascript" src="<%$fsurl%>elements/cssexpr.js"></script> +<script type="text/javascript" src="<%$fsurl%>elements/xmenu.js"></script> +<link href="<%$fsurl%>elements/xmenu.css" type="text/css" rel="stylesheet"> +<link href="<%$fsurl%>elements/freeside.css" type="text/css" rel="stylesheet"> <SCRIPT TYPE="text/javascript"> - webfxMenuImagePath = "<%=$fsurl%>images/"; + webfxMenuImagePath = "<%$fsurl%>images/"; webfxMenuUseHover = 1; webfxMenuShowTime = 300; webfxMenuHideTime = 300; var myBar = new WebFXMenuBar; +% foreach my $item ( keys %menu ) { +% +% my( $url_or_submenu, $tooltip ) = @{ $menu{$item} }; +% +% if ( ref($url_or_submenu) ) { +% +% #warn $item; +% +% my( $subhtml, $submenuname ) = submenu($url_or_submenu, $item); +% +% + + + <% $subhtml %> + myBar.add(new WebFXMenuButton("<% $item %>", null, "<% $tooltip %>", <% $submenuname %> )); +% } else { - <% foreach my $item ( keys %menu ) { - - my( $url_or_submenu, $tooltip ) = @{ $menu{$item} }; - - if ( ref($url_or_submenu) ) { - - #warn $item; - - my( $subhtml, $submenuname ) = submenu($url_or_submenu, $item); - - %> - - <%= $subhtml %> - myBar.add(new WebFXMenuButton("<%= $item %>", null, "<%= $tooltip %>", <%= $submenuname %> )); - - <% } else { %> - myBar.add(new WebFXMenuButton("<%= $item %>", "<%= $url_or_submenu %>", "<%= $tooltip %>" )); - - <% } + myBar.add(new WebFXMenuButton("<% $item %>", "<% $url_or_submenu %>", "<% $tooltip %>" )); +% } +% +% } +% - } - %> myBar.show( null, 'vertical' ); //myBar.show( null, 'horizontal' ); diff --git a/httemplate/elements/menubar.html b/httemplate/elements/menubar.html index 29facb6b6..ec6c13fea 100644 --- a/httemplate/elements/menubar.html +++ b/httemplate/elements/menubar.html @@ -1,9 +1,10 @@ -<% - my($item, $url, @html); - while (@_) { - ($item, $url) = splice(@_,0,2); - next if $item =~ /^\s*Main\s+Menu\s*$/i; - push @html, qq!<A HREF="$url">$item</A>!; - } -%> -<%= join(' | ', @html) %> +% +% my($item, $url, @html); +% while (@_) { +% ($item, $url) = splice(@_,0,2); +% next if $item =~ /^\s*Main\s+Menu\s*$/i; +% push @html, qq!<A HREF="$url">$item</A>!; +% } +% + +<% join(' | ', @html) %> diff --git a/httemplate/elements/pager.html b/httemplate/elements/pager.html index 0510d327d..2327594a8 100644 --- a/httemplate/elements/pager.html +++ b/httemplate/elements/pager.html @@ -1,42 +1,43 @@ -<% +% +% +% my %opt = @_; +% +% my $pager = ''; +% if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) { +% unless ( $opt{'offset'} == 0 ) { +% $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'}); +% + + + <A HREF="<% $cgi->self_url %>"><B><FONT SIZE="+1">Previous</FONT></B></A> +% +% } +% my $page = 0; +% for ( my $poff = 0; $poff < $opt{'total'}; $poff += $opt{'maxrecords'} ) { +% $page++; +% if ( $opt{'offset'} == $poff ) { +% + + + <FONT SIZE="+2"><% $page %></FONT> +% +% } else { +% $cgi->param('offset', $poff); +% + + + <A HREF="<% $cgi->self_url %>"><% $page %></A> +% +% } +% } +% unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) { +% $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'}); +% + + + <A HREF="<% $cgi->self_url %>"><B><FONT SIZE="+1">Next</FONT></B></A> +% +% } +% } +% - my %opt = @_; - - my $pager = ''; - if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) { - unless ( $opt{'offset'} == 0 ) { - $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'}); -%> - - <A HREF="<%= $cgi->self_url %>"><B><FONT SIZE="+1">Previous</FONT></B></A> - -<% - } - my $page = 0; - for ( my $poff = 0; $poff < $opt{'total'}; $poff += $opt{'maxrecords'} ) { - $page++; - if ( $opt{'offset'} == $poff ) { -%> - - <FONT SIZE="+2"><%= $page %></FONT> - -<% - } else { - $cgi->param('offset', $poff); -%> - - <A HREF="<%= $cgi->self_url %>"><%= $page %></A> - -<% - } - } - unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) { - $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'}); -%> - - <A HREF="<%= $cgi->self_url %>"><B><FONT SIZE="+1">Next</FONT></B></A> - -<% - } - } -%> diff --git a/httemplate/elements/phonenumber.html b/httemplate/elements/phonenumber.html index 6e16ec0ad..0e730ebcc 100644 --- a/httemplate/elements/phonenumber.html +++ b/httemplate/elements/phonenumber.html @@ -1,17 +1,22 @@ -<% - my( $number, %opt ) = @_; - my $conf = new FS::Conf; - ( my $snumber = $number ) =~ s/\D//g; -%> +% +% my( $number, %opt ) = @_; +% my $conf = new FS::Conf; +% ( my $snumber = $number ) =~ s/\D//g; +% + <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/iframecontentmws.js"></SCRIPT> -<% if ( length($number) ) { %> - <%= $number %> - <% if ( $opt{'callable'} && $conf->config('vonage-username') ) { %> - <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('https://secure.click2callu.com/tpcc/makecall?username=<%= $conf->config('vonage-username') %>&password=<%= $conf->config('vonage-password') %>&fromnumber=<%= $conf->config('vonage-fromnumber')%>&tonumber=1<%= $snumber %>', 240, 64, 'call_popup'), CAPTION, 'Initiating call', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE, WIDTH, 240, HEIGHT, 64 ); return false;" TITLE="Call this number"><IMG SRC="<%=$fsurl%>images/red_telephone_mimooh_01.png" BORDER=0 ALT="Call this number"></A> - <% } %> -<% } else { %> +% if ( length($number) ) { + + <% $number %> +% if ( $opt{'callable'} && $conf->config('vonage-username') ) { + + <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('https://secure.click2callu.com/tpcc/makecall?username=<% $conf->config('vonage-username') %>&password=<% $conf->config('vonage-password') %>&fromnumber=<% $conf->config('vonage-fromnumber')%>&tonumber=1<% $snumber %>', 240, 64, 'call_popup'), CAPTION, 'Initiating call', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE, WIDTH, 240, HEIGHT, 64 ); return false;" TITLE="Call this number"><IMG SRC="<%$fsurl%>images/red_telephone_mimooh_01.png" BORDER=0 ALT="Call this number"></A> +% } +% } else { + -<% } %> +% } + diff --git a/httemplate/elements/progress-init.html b/httemplate/elements/progress-init.html index ec485f438..3894feef9 100644 --- a/httemplate/elements/progress-init.html +++ b/httemplate/elements/progress-init.html @@ -1,17 +1,18 @@ -<% - my( $formname, $fields, $action, $url_or_message, $key ) = @_; - $key = '' unless defined $key; +% +% my( $formname, $fields, $action, $url_or_message, $key ) = @_; +% $key = '' unless defined $key; +% +% my $url_or_message_link; +% if ( ref($url_or_message) ) { #its a message or something +% $url_or_message_link = +% 'message='. uri_escape( $url_or_message->{'message'} ) +% } else { +% $url_or_message_link = "url=$url_or_message"; +% } +% - my $url_or_message_link; - if ( ref($url_or_message) ) { #its a message or something - $url_or_message_link = - 'message='. uri_escape( $url_or_message->{'message'} ) - } else { - $url_or_message_link = "url=$url_or_message"; - } -%> -<%= include('/elements/xmlhttp.html', +<% include('/elements/xmlhttp.html', 'method' => 'POST', 'url' => $action, 'subs' => [ 'start_job' ], @@ -27,12 +28,12 @@ function OLiframeContent(src, width, height, name) { +'<div>[iframe not supported]</div></iframe>'); } -function <%=$key%>process () { +function <%$key%>process () { - //alert('<%=$key%>process for form <%=$formname%>'); + //alert('<%$key%>process for form <%$formname%>'); - if ( document.<%=$formname%>.submit.disabled == false ) { - document.<%=$formname%>.submit.disabled=true; + if ( document.<%$formname%>.submit.disabled == false ) { + document.<%$formname%>.submit.disabled=true; } overlib( 'Submitting job to server...', WIDTH, 444, HEIGHT, 168, CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 ); @@ -40,9 +41,9 @@ function <%=$key%>process () { var Hash = new Array(); var x = 0; var fieldName; - for (var i = 0; i<document.<%=$formname%>.elements.length; i++) { - field = document.<%=$formname%>.elements[i]; - if ( <%= join(' || ', map { "(field.name.indexOf('$_') > -1)" } @$fields ) %> + for (var i = 0; i<document.<%$formname%>.elements.length; i++) { + field = document.<%$formname%>.elements[i]; + if ( <% join(' || ', map { "(field.name.indexOf('$_') > -1)" } @$fields ) %> ) { if ( field.type == 'select-multiple' ) { @@ -56,7 +57,7 @@ function <%=$key%>process () { } } else if ( ( field.type != 'radio' && field.type != 'checkbox' ) || ( ( field.type == 'radio' || field.type == 'checkbox' ) - && document.<%=$formname%>.elements[i].checked + && document.<%$formname%>.elements[i].checked ) ) { @@ -67,17 +68,17 @@ function <%=$key%>process () { } // jsrsPOST = true; - // jsrsExecute( '<%= $action %>', <%=$key%>myCallback, 'start_job', Hash ); + // jsrsExecute( '<% $action %>', <%$key%>myCallback, 'start_job', Hash ); - //alert('start_job( ' + Hash + ', <%=$key%>myCallback )' ); + //alert('start_job( ' + Hash + ', <%$key%>myCallback )' ); //alert('start_job()' ); - <%=$key%>start_job( Hash, <%=$key%>myCallback ); + <%$key%>start_job( Hash, <%$key%>myCallback ); } -function <%=$key%>myCallback( jobnum ) { +function <%$key%>myCallback( jobnum ) { - overlib( OLiframeContent('<%=$p%>elements/progress-popup.html?jobnum=' + jobnum + ';<%=$url_or_message_link%>;formname=<%=$formname%>' , 444, 168, 'progress_popup'), CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 ); + overlib( OLiframeContent('<%$p%>elements/progress-popup.html?jobnum=' + jobnum + ';<%$url_or_message_link%>;formname=<%$formname%>' , 444, 168, 'progress_popup'), CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 ); } diff --git a/httemplate/elements/progress-popup.html b/httemplate/elements/progress-popup.html index 544440138..8f2ff1982 100644 --- a/httemplate/elements/progress-popup.html +++ b/httemplate/elements/progress-popup.html @@ -1,16 +1,17 @@ -<% - my $jobnum = $cgi->param('jobnum'); - my $url = $cgi->param('url'); - my $message = $cgi->param('message'); - my $formname = scalar($cgi->param('formname')); -%> +% +% my $jobnum = $cgi->param('jobnum'); +% my $url = $cgi->param('url'); +% my $message = $cgi->param('message'); +% my $formname = scalar($cgi->param('formname')); +% + <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY BGCOLOR="#ccccff" onLoad="refreshStatus()"> -<%= include('/elements/xmlhttp.html', +<% include('/elements/xmlhttp.html', 'url' => $p.'elements/jsrsServer.html', 'subs' => [ 'job_status' ], ) @@ -20,9 +21,9 @@ <SCRIPT TYPE="text/javascript" src="../elements/qlib/progress.js"></SCRIPT> <SCRIPT TYPE="text/javascript"> function refreshStatus () { - //jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' ); + //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' ); - job_status( '<%= $jobnum %>', updateStatus ); + job_status( '<% $jobnum %>', updateStatus ); } function updateStatus( status_statustext ) { @@ -37,29 +38,33 @@ function updateStatus( status_statustext ) { document.getElementById("progress_percent").innerHTML = statustext + '%'; bar1.set(statustext); bar1.update; - //jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' ); - job_status( '<%= $jobnum %>', updateStatus ); + //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' ); + job_status( '<% $jobnum %>', updateStatus ); } else if ( status.indexOf('complete') > -1 ) { -<% if ( $message ) { %> - document.getElementById("progress_message").innerHTML = "<%= $message %>"; +% if ( $message ) { + + document.getElementById("progress_message").innerHTML = "<% $message %>"; document.getElementById("progress_bar").innerHTML = ''; document.getElementById("progress_percent").innerHTML = '<INPUT TYPE="button" VALUE="OK" onClick="parent.nd(1);">'; document.getElementById("progress_jobnum").innerHTML = ''; - if ( parent.document.<%=$formname%>.submit.disabled == true ) { - parent.document.<%=$formname%>.submit.disabled=false; + if ( parent.document.<%$formname%>.submit.disabled == true ) { + parent.document.<%$formname%>.submit.disabled=false; } -<% } elsif ( $url ) { %> - window.top.location.href = '<%= $url %>'; -<% } else { %> +% } elsif ( $url ) { + + window.top.location.href = '<% $url %>'; +% } else { + alert('job done but no url or message specified'); -<% } %> +% } + } else if ( status.indexOf('error') > -1 ) { document.getElementById("progress_message").innerHTML = '<FONT SIZE="+1" COLOR="#FF0000">Error: ' + statustext + '</FONT>'; document.getElementById("progress_bar").innerHTML = ''; document.getElementById("progress_percent").innerHTML = '<INPUT TYPE="button" VALUE="OK" onClick="parent.nd(1);">'; document.getElementById("progress_jobnum").innerHTML = ''; - if ( parent.document.<%=$formname%>.submit.disabled == true ) { - parent.document.<%=$formname%>.submit.disabled=false; + if ( parent.document.<%$formname%>.submit.disabled == true ) { + parent.document.<%$formname%>.submit.disabled=false; } } else { alert('XXX unknown status returned from server: ' + status); @@ -90,7 +95,7 @@ function updateStatus( status_statustext ) { </TD> </TR><TR> <TD ALIGN="center" ID="progress_jobnum"> - (progress of job #<%= $jobnum %>) + (progress of job #<% $jobnum %>) </TD> </TR> </TABLE> diff --git a/httemplate/elements/search-cust_main.html b/httemplate/elements/search-cust_main.html index ca91b4027..f2b17eacb 100644 --- a/httemplate/elements/search-cust_main.html +++ b/httemplate/elements/search-cust_main.html @@ -1,27 +1,28 @@ -<% - my( %opt ) = @_; - $opt{'field_name'} ||= 'custnum'; - - my $cust_main = ''; - if ( $opt{'value'} ) { - $cust_main = qsearchs( - 'table' => 'cust_main', - 'hashref' => { 'custnum' => $opt{'value'} }, - 'extra_sql' => " AND ". $FS::CurrentUser::CurrentUser->agentnums_sql, - ); - } -%> - -<INPUT TYPE="hidden" NAME="<%= $opt{'field_name'} %>" VALUE="<%= $opt{'value'} %>"> +% +% my( %opt ) = @_; +% $opt{'field_name'} ||= 'custnum'; +% +% my $cust_main = ''; +% if ( $opt{'value'} ) { +% $cust_main = qsearchs( +% 'table' => 'cust_main', +% 'hashref' => { 'custnum' => $opt{'value'} }, +% 'extra_sql' => " AND ". $FS::CurrentUser::CurrentUser->agentnums_sql, +% ); +% } +% + + +<INPUT TYPE="hidden" NAME="<% $opt{'field_name'} %>" VALUE="<% $opt{'value'} %>"> <!-- some false laziness w/ misc/batch-cust_pay.html, though not as bad as i'd thought at first... --> -<INPUT TYPE="text" NAME="<%= $opt{'field_name'} %>_search" ID="<%= $opt{'field_name'} %>_search" SIZE="32" VALUE="<%= $cust_main ? $cust_main->name : '(cust #, name or company)' %>" onFocus="clearhint_<%= $opt{'field_name'} %>_search(this);" onClick="clearhint_<%= $opt{'field_name'} %>_search(this);" onChange="smart_<%= $opt{'field_name'} %>_search(this);"> +<INPUT TYPE="text" NAME="<% $opt{'field_name'} %>_search" ID="<% $opt{'field_name'} %>_search" SIZE="32" VALUE="<% $cust_main ? $cust_main->name : '(cust #, name or company)' %>" onFocus="clearhint_<% $opt{'field_name'} %>_search(this);" onClick="clearhint_<% $opt{'field_name'} %>_search(this);" onChange="smart_<% $opt{'field_name'} %>_search(this);"> -<SELECT NAME="<%= $opt{'field_name'} %>_select" ID="<%= $opt{'field_name'} %>_select" STYLE="color:#ff0000; display:none" onChange="select_<%= $opt{'field_name'} %>(this);"> +<SELECT NAME="<% $opt{'field_name'} %>_select" ID="<% $opt{'field_name'} %>_select" STYLE="color:#ff0000; display:none" onChange="select_<% $opt{'field_name'} %>(this);"> </SELECT> -<%= include('/elements/xmlhttp.html', +<% include('/elements/xmlhttp.html', 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi', 'subs' => [ 'smart_search' ], ) @@ -29,7 +30,7 @@ <SCRIPT TYPE="text/javascript"> - function clearhint_<%= $opt{'field_name'} %>_search (what) { + function clearhint_<% $opt{'field_name'} %>_search (what) { what.style.color = '#000000'; @@ -41,7 +42,7 @@ } - function smart_<%= $opt{'field_name'} %>_search(what) { + function smart_<% $opt{'field_name'} %>_search(what) { var customer = what.value; @@ -59,11 +60,11 @@ what.style.color= '#000000'; what.style.backgroundColor = '#dddddd'; - var customer_select = document.getElementById('<%= $opt{'field_name'} %>_select'); + var customer_select = document.getElementById('<% $opt{'field_name'} %>_select'); //alert("search for customer " + customer); - function <%= $opt{'field_name'} %>_search_update(customers) { + function <% $opt{'field_name'} %>_search_update(customers) { //alert('customers returned: ' + customers); @@ -74,7 +75,7 @@ if ( customerArray.length == 0 ) { - what.form.<%= $opt{'field_name'} %>.value = ''; + what.form.<% $opt{'field_name'} %>.value = ''; what.value = 'Customer not found: ' + what.value; what.style.color = '#ff0000'; @@ -86,7 +87,7 @@ //alert('one customer found: ' + customerArray[0]); - what.form.<%= $opt{'field_name'} %>.value = customerArray[0][0]; + what.form.<% $opt{'field_name'} %>.value = customerArray[0][0]; what.value = customerArray[0][1]; what.style.display = ''; @@ -115,17 +116,17 @@ } - smart_search( customer, <%= $opt{'field_name'} %>_search_update ); + smart_search( customer, <% $opt{'field_name'} %>_search_update ); } - function select_<%= $opt{'field_name'} %> (what) { + function select_<% $opt{'field_name'} %> (what) { var custnum = what.options[what.selectedIndex].value; var customer = what.options[what.selectedIndex].text; - var customer_obj = document.getElementById('<%= $opt{'field_name'} %>_search'); + var customer_obj = document.getElementById('<% $opt{'field_name'} %>_search'); if ( custnum == '' ) { //what.style.color = '#ff0000'; @@ -140,7 +141,7 @@ } else { - what.form.<%= $opt{'field_name'} %>.value = custnum; + what.form.<% $opt{'field_name'} %>.value = custnum; customer_obj.value = customer; customer_obj.style.color = '#000000'; diff --git a/httemplate/elements/select-access_group.html b/httemplate/elements/select-access_group.html index b05f565ea..299a66a45 100644 --- a/httemplate/elements/select-access_group.html +++ b/httemplate/elements/select-access_group.html @@ -1,10 +1,11 @@ -<% - my( $groupnum, %opt ) = @_; - - %opt{'records'} = delete $opt{'access_group'} - if $opt{'access_group'}; - -%><%= include( '/elements/select-table.html', +% +% my( $groupnum, %opt ) = @_; +% +% %opt{'records'} = delete $opt{'access_group'} +% if $opt{'access_group'}; +% +% +<% include( '/elements/select-table.html', 'table' => 'access_group', 'name_col' => 'groupname', 'value' => $groupnum, diff --git a/httemplate/elements/select-agent.html b/httemplate/elements/select-agent.html index 009cc6e06..e85ede5b8 100644 --- a/httemplate/elements/select-agent.html +++ b/httemplate/elements/select-agent.html @@ -1,10 +1,11 @@ -<% - my( $agentnum, %opt ) = @_; - - $opt{'records'} = delete $opt{'agents'} - if $opt{'agents'}; - -%><%= include( '/elements/select-table.html', +% +% my( $agentnum, %opt ) = @_; +% +% $opt{'records'} = delete $opt{'agents'} +% if $opt{'agents'}; +% +% +<% include( '/elements/select-table.html', 'table' => 'agent', 'name_col' => 'agent', 'value' => $agentnum, diff --git a/httemplate/elements/select-cust-fields.html b/httemplate/elements/select-cust-fields.html index 4d47fbe40..98feaf85c 100644 --- a/httemplate/elements/select-cust-fields.html +++ b/httemplate/elements/select-cust-fields.html @@ -1,23 +1,24 @@ -<% - my( $cust_fields, %opt ) = @_; +% +% my( $cust_fields, %opt ) = @_; +% +% use FS::ConfDefaults; +% $opt{'avail_fields'} ||= [ FS::ConfDefaults->cust_fields_avail() ]; +% +% tie my %hash, 'Tie::IxHash', @{ $opt{'avail_fields'} }; +% +% - use FS::ConfDefaults; - $opt{'avail_fields'} ||= [ FS::ConfDefaults->cust_fields_avail() ]; - - tie my %hash, 'Tie::IxHash', @{ $opt{'avail_fields'} }; - -%> <SELECT NAME="cust_fields"> <OPTION VALUE="">(configured default) +% +% foreach my $value ( keys %hash ) { - <% - foreach my $value ( keys %hash ) { %> - <OPTION VALUE="<%= $value %>"><%= $hash{$value} %> + <OPTION VALUE="<% $value %>"><% $hash{$value} %> +% } - <% } %> </SELECT> diff --git a/httemplate/elements/select-cust_pkg-status.html b/httemplate/elements/select-cust_pkg-status.html index 5da93fe79..58f270342 100644 --- a/httemplate/elements/select-cust_pkg-status.html +++ b/httemplate/elements/select-cust_pkg-status.html @@ -1,19 +1,20 @@ -<% - my( $status, %opt ) = @_; +% +% my( $status, %opt ) = @_; +% +% $opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } ) +% +% - $opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } ) - -%> <SELECT NAME="status"> <OPTION VALUE="">all +% foreach my $status ( @{ $opt{'statuses'} } ) { - <% foreach my $status ( @{ $opt{'statuses'} } ) { %> - <OPTION VALUE="<%= $status %>"><%= $status %> + <OPTION VALUE="<% $status %>"><% $status %> +% } - <% } %> </SELECT> diff --git a/httemplate/elements/select-month_year.html b/httemplate/elements/select-month_year.html index 2866960bd..34476bc94 100644 --- a/httemplate/elements/select-month_year.html +++ b/httemplate/elements/select-month_year.html @@ -1,59 +1,62 @@ -<% - - my %opt = @_; - - my $prefix = $opt{'prefix'} || ''; - my $disabled = $opt{'disabled'} || ''; - my $empty = $opt{'empty_option'} || ''; - my $start_year = $opt{'start_year'}; - my $end_year = $opt{'end_year'} || '2037'; - - my @mon; - if ( $opt{'show_month_abbr'} ) { - @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); - } else { - @mon = ( 1 .. 12 ); - } - - my $date = $opt{'selected_date'} || ''; - $date = '' if $date eq '-'; - #$date ||= '01-2000' unless $empty; - - my $mon = $opt{'selected_mon'} || 0; - my $year = $opt{'selected_year'} || 0; - if ( $date ) { - if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); - } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); - } else { - die "unrecognized expiration date format: $date"; - } - } - - unless ( $start_year ) { - my @t = localtime; - $start_year = $t[5] + 1900; - } - $start_year = $year if $start_year > $year && $year > 0; - -%> - -<SELECT NAME="<%= $prefix %>_month" SIZE="1" <%= $disabled%>> - -<%= $empty ? '<OPTION VALUE="">' : '' %> - -<% foreach ( 1 .. 12 ) { %> - <OPTION<%= $_ == $mon ? ' SELECTED' : '' %> VALUE="<%= $_ %>"><%= $mon[$_-1] %> -<% } %> - -</SELECT>/<SELECT NAME="<%= $prefix %>_year" SIZE="1" <%= $disabled%>> - -<%= $empty ? '<OPTION VALUE="">' : '' %> - -<% for ( $start_year .. $end_year ) { %> - <OPTION<%= $_ == $year ? ' SELECTED' : '' %> VALUE="<%= $_ %>"><%= $_ %> -<% } %> +% +% +% my %opt = @_; +% +% my $prefix = $opt{'prefix'} || ''; +% my $disabled = $opt{'disabled'} || ''; +% my $empty = $opt{'empty_option'} || ''; +% my $start_year = $opt{'start_year'}; +% my $end_year = $opt{'end_year'} || '2037'; +% +% my @mon; +% if ( $opt{'show_month_abbr'} ) { +% @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); +% } else { +% @mon = ( 1 .. 12 ); +% } +% +% my $date = $opt{'selected_date'} || ''; +% $date = '' if $date eq '-'; +% #$date ||= '01-2000' unless $empty; +% +% my $mon = $opt{'selected_mon'} || 0; +% my $year = $opt{'selected_year'} || 0; +% if ( $date ) { +% if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format +% ( $mon, $year ) = ( $2, $1 ); +% } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { +% ( $mon, $year ) = ( $1, $3 ); +% } else { +% die "unrecognized expiration date format: $date"; +% } +% } +% +% unless ( $start_year ) { +% my @t = localtime; +% $start_year = $t[5] + 1900; +% } +% $start_year = $year if $start_year > $year && $year > 0; +% +% + + +<SELECT NAME="<% $prefix %>_month" SIZE="1" <% $disabled%>> + +<% $empty ? '<OPTION VALUE="">' : '' %> +% foreach ( 1 .. 12 ) { + + <OPTION<% $_ == $mon ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $mon[$_-1] %> +% } + + +</SELECT>/<SELECT NAME="<% $prefix %>_year" SIZE="1" <% $disabled%>> + +<% $empty ? '<OPTION VALUE="">' : '' %> +% for ( $start_year .. $end_year ) { + + <OPTION<% $_ == $year ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $_ %> +% } + </SELECT> diff --git a/httemplate/elements/select-part_referral.html b/httemplate/elements/select-part_referral.html index deb87bd3b..efcc477af 100644 --- a/httemplate/elements/select-part_referral.html +++ b/httemplate/elements/select-part_referral.html @@ -1,10 +1,11 @@ -<% - my( $refnum, %opt ) = @_; - - $opt{'records'} = delete $opt{'part_referrals'} - if $opt{'part_referrals'}; - -%><%= include( '/elements/select-table.html', +% +% my( $refnum, %opt ) = @_; +% +% $opt{'records'} = delete $opt{'part_referrals'} +% if $opt{'part_referrals'}; +% +% +<% include( '/elements/select-table.html', 'table' => 'part_referral', 'name_col' => 'referral', 'value' => $refnum, diff --git a/httemplate/elements/select-pkg_class.html b/httemplate/elements/select-pkg_class.html index 032c7abda..0d8e6ac84 100644 --- a/httemplate/elements/select-pkg_class.html +++ b/httemplate/elements/select-pkg_class.html @@ -1,12 +1,13 @@ -<% - my( $classnum, %opt ) = @_; - - $opt{'records'} = delete $opt{'pkg_class'} - if $opt{'pkg_class'}; - - #warn "***** select-pkg-class: \n". Dumper(%opt); - -%><%= include( '/elements/select-table.html', +% +% my( $classnum, %opt ) = @_; +% +% $opt{'records'} = delete $opt{'pkg_class'} +% if $opt{'pkg_class'}; +% +% #warn "***** select-pkg-class: \n". Dumper(%opt); +% +% +<% include( '/elements/select-table.html', 'table' => 'pkg_class', 'name_col' => 'classname', 'value' => $classnum, diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 36eb4e211..83445f41a 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -1,63 +1,65 @@ -<% - - ##required - # 'table' => 'table_name', - # 'name_col' => 'name_column', - # - ##strongly recommended (you want your forms to be "sticky" on errors, right?) - # 'value' => 'current_value', - # - ##opt - # 'empty_label' => '', #better specify it though, the default might change - # 'hashref' => {}, - # 'extra_sql' => '', - # 'records' => \@records, #instead of hashref - # 'pre_options' => [ 'value' => 'option' ], #before normal options - # 'element_name' => '', #HTML element name, defaults to the name of - # # the primary key column - # 'element_etc' => '', #additional attributes (i.e. "DISABLED") for the - # #<SELECT> element - - my( %opt ) = @_; - - #warn "***** select-table: \n". Dumper(%opt); - - my $key = dbdef->table($opt{'table'})->primary_key; #? $opt{'primary_key'} || - - my $name_col = $opt{'name_col'}; - - my @records = (); - if ( $opt{'records'} ) { - @records = @{ $opt{'records'} }; - } else { - @records = qsearch( { - 'table' => $opt{'table'}, - 'hashref' => ( $opt{'hashref'} || {} ), - 'extra_sql' => ( $opt{'extra_sql'} || '' ), - }); - } - - my @pre_options = $opt{'pre_options'} ? @{ $opt{'pre_options'} } : (); - -%> - -<SELECT NAME="<%= $opt{'element_name'} || $key %>" <%= $opt{'element_etc'} %>> - - <% while ( @pre_options ) { %> - <OPTION VALUE="<%= shift(@pre_options) %>"><%= shift(@pre_options) %> - <% } %> - - <OPTION VALUE=""><%= $opt{'empty_label'} || 'all' %> - - <% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } - @records - ) - { - %> - - <OPTION VALUE="<%= $record->$key() %>"<%= $opt{'value'} == $record->$key() ? ' SELECTED' : '' %>><%= $record->$name_col() %> - - <% } %> +% +% +% ##required +% # 'table' => 'table_name', +% # 'name_col' => 'name_column', +% # +% ##strongly recommended (you want your forms to be "sticky" on errors, right?) +% # 'value' => 'current_value', +% # +% ##opt +% # 'empty_label' => '', #better specify it though, the default might change +% # 'hashref' => {}, +% # 'extra_sql' => '', +% # 'records' => \@records, #instead of hashref +% # 'pre_options' => [ 'value' => 'option' ], #before normal options +% # 'element_name' => '', #HTML element name, defaults to the name of +% # # the primary key column +% # 'element_etc' => '', #additional attributes (i.e. "DISABLED") for the +% # #<SELECT> element +% +% my( %opt ) = @_; +% +% #warn "***** select-table: \n". Dumper(%opt); +% +% my $key = dbdef->table($opt{'table'})->primary_key; #? $opt{'primary_key'} || +% +% my $name_col = $opt{'name_col'}; +% +% my @records = (); +% if ( $opt{'records'} ) { +% @records = @{ $opt{'records'} }; +% } else { +% @records = qsearch( { +% 'table' => $opt{'table'}, +% 'hashref' => ( $opt{'hashref'} || {} ), +% 'extra_sql' => ( $opt{'extra_sql'} || '' ), +% }); +% } +% +% my @pre_options = $opt{'pre_options'} ? @{ $opt{'pre_options'} } : (); +% +% + + +<SELECT NAME="<% $opt{'element_name'} || $key %>" <% $opt{'element_etc'} %>> +% while ( @pre_options ) { + + <OPTION VALUE="<% shift(@pre_options) %>"><% shift(@pre_options) %> +% } + + + <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %> +% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } +% @records +% ) +% { +% + + + <OPTION VALUE="<% $record->$key() %>"<% $opt{'value'} == $record->$key() ? ' SELECTED' : '' %>><% $record->$name_col() %> +% } + </SELECT> diff --git a/httemplate/elements/select-taxclass.html b/httemplate/elements/select-taxclass.html index e5a1abba1..495572323 100644 --- a/httemplate/elements/select-taxclass.html +++ b/httemplate/elements/select-taxclass.html @@ -1,42 +1,40 @@ -<% - my $conf = new FS::Conf; - my $selected_taxclass = scalar(@_) ? shift : ''; -%> +% +% my $conf = new FS::Conf; +% my $selected_taxclass = scalar(@_) ? shift : ''; +% +% if ( $conf->exists('enable_taxclasses') ) { -<% if ( $conf->exists('enable_taxclasses') ) { %> <SELECT NAME="taxclass"> +% if ( $conf->exists('require_taxclasses') ) { - <% if ( $conf->exists('require_taxclasses') ) { %> <OPTION VALUE="(select)">Select tax class +% } else { - <% } else { %> <OPTION VALUE=""> +% } +% +% my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county') +% or die dbh->errstr; +% $sth->execute or die $sth->errstr; +% my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref}; +% my @taxclasses = grep $_, keys %taxclasses; +% +% foreach my $taxclass ( @taxclasses ) { - <% } %> - - <% - my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county') - or die dbh->errstr; - $sth->execute or die $sth->errstr; - my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref}; - my @taxclasses = grep $_, keys %taxclasses; - %> - - <% foreach my $taxclass ( @taxclasses ) { %> - - <OPTION VALUE="<%= $taxclass %>"<%= $taxclass eq $selected_taxclass ? ' SELECTED' : '' %>><%= $taxclass %> - <% } %> + <OPTION VALUE="<% $taxclass %>"<% $taxclass eq $selected_taxclass ? ' SELECTED' : '' %>><% $taxclass %> +% } + </SELECT> +% } else { -<% } else { %> - <INPUT TYPE="hidden" NAME="taxclass" VALUE="<%= $selected_taxclass %>"> - -<% } %> + <INPUT TYPE="hidden" NAME="taxclass" VALUE="<% $selected_taxclass %>"> +% } + diff --git a/httemplate/elements/small_custview.html b/httemplate/elements/small_custview.html index e0c22e0c4..9060d897d 100644 --- a/httemplate/elements/small_custview.html +++ b/httemplate/elements/small_custview.html @@ -1,2 +1,3 @@ -<% my $conf = new FS::Conf; %> -<%= small_custview( shift, shift || scalar($conf->config('countrydefault')), @_ ) %> +% my $conf = new FS::Conf; + +<% small_custview( shift, shift || scalar($conf->config('countrydefault')), @_ ) %> diff --git a/httemplate/elements/table-grid.html b/httemplate/elements/table-grid.html index fd1cb9113..0f532e86b 100644 --- a/httemplate/elements/table-grid.html +++ b/httemplate/elements/table-grid.html @@ -1,9 +1,10 @@ -<% - my %opt = @_; - $opt{cellspacing} ||= 0; - $opt{cellpadding} ||= 0; +% +% my %opt = @_; +% $opt{cellspacing} ||= 0; +% $opt{cellpadding} ||= 0; +% +% -%> <STYLE TYPE="text/css"> .grid table { border: solid; empty-cells: show } @@ -16,5 +17,5 @@ </STYLE> -<TABLE CLASS="grid" CELLSPACING=<%= $opt{cellspacing} %> CELLPADDING=<%= $opt{cellpadding} %> BORDER=1 BORDERCOLOR="#000000" STYLE="border: solid 1px black; empty-cells: show"> +<TABLE CLASS="grid" CELLSPACING=<% $opt{cellspacing} %> CELLPADDING=<% $opt{cellpadding} %> BORDER=1 BORDERCOLOR="#000000" STYLE="border: solid 1px black; empty-cells: show"> diff --git a/httemplate/elements/table.html b/httemplate/elements/table.html index 3b6108719..8152b65d8 100644 --- a/httemplate/elements/table.html +++ b/httemplate/elements/table.html @@ -1,8 +1,11 @@ -<% - my $color = shift; - if ( $color ) { -%> - <TABLE BGCOLOR="<%= $color %>" BORDER=1 WIDTH="100%" CELLSPACING=0 CELLPADDING=2 BORDERCOLOR="#999999"> -<% } else { %> +% +% my $color = shift; +% if ( $color ) { +% + + <TABLE BGCOLOR="<% $color %>" BORDER=1 WIDTH="100%" CELLSPACING=0 CELLPADDING=2 BORDERCOLOR="#999999"> +% } else { + <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2 BORDERCOLOR="#999999"> -<% } %> +% } + diff --git a/httemplate/elements/tr-select-access_group.html b/httemplate/elements/tr-select-access_group.html index 0beec0842..e443ad26a 100644 --- a/httemplate/elements/tr-select-access_group.html +++ b/httemplate/elements/tr-select-access_group.html @@ -1,22 +1,22 @@ -<% - my( $groupnum, %opt ) = @_; +% +% my( $groupnum, %opt ) = @_; +% +% $opt{'access_group'} ||= [ qsearch( 'access_group', {} ) ]; # { disabled=>'' } ) +% +% #warn "***** tr-select-access_group: \n". Dumper(%opt); +% +% if ( scalar(@{ $opt{'access_group'} }) == 0 ) { - $opt{'access_group'} ||= [ qsearch( 'access_group', {} ) ]; # { disabled=>'' } ) - - #warn "***** tr-select-access_group: \n". Dumper(%opt); -%> - -<% if ( scalar(@{ $opt{'access_group'} }) == 0 ) { %> <INPUT TYPE="hidden" NAME="groupnum" VALUE=""> +% } else { -<% } else { %> <TR> - <TD ALIGN="right"><%= $opt{'label'} || 'Access group' %></TD> + <TD ALIGN="right"><% $opt{'label'} || 'Access group' %></TD> <TD> - <%= include( '/elements/select-access_group.html', $groupnum, %opt ) %> + <% include( '/elements/select-access_group.html', $groupnum, %opt ) %> </TD> </TR> +% } -<% } %> diff --git a/httemplate/elements/tr-select-agent.html b/httemplate/elements/tr-select-agent.html index 6158f6f47..37b1c1e88 100644 --- a/httemplate/elements/tr-select-agent.html +++ b/httemplate/elements/tr-select-agent.html @@ -1,34 +1,34 @@ -<% - my( $agentnum, %opt ) = @_; +% +% my( $agentnum, %opt ) = @_; +% +% my @agents; +% if ( $opt{'agents'} ) { +% #@agents = @{ $opt{'agents'} }; +% #here is the agent virtualization +% my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href; +% @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} }; +% delete $opt{'agents'}; +% } else { +% @agents = $FS::CurrentUser::CurrentUser->agents; +% } +% +% +% if ( scalar(@agents) == 1 ) { - my @agents; - if ( $opt{'agents'} ) { - #@agents = @{ $opt{'agents'} }; - #here is the agent virtualization - my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href; - @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} }; - delete $opt{'agents'}; - } else { - @agents = $FS::CurrentUser::CurrentUser->agents; - } -%> + <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agents[0]->agentnum %>"> +% } else { -<% if ( scalar(@agents) == 1 ) { %> - - <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agents[0]->agentnum %>"> - -<% } else { %> <TR> - <TD ALIGN="right"><%= $opt{'label'} || 'Agent' %></TD> + <TD ALIGN="right"><% $opt{'label'} || 'Agent' %></TD> <TD> - <%= include( '/elements/select-agent.html', $agentnum, + <% include( '/elements/select-agent.html', $agentnum, 'agents' => \@agents, %opt, ) %> </TD> </TR> +% } -<% } %> diff --git a/httemplate/elements/tr-select-cust-fields.html b/httemplate/elements/tr-select-cust-fields.html index ca37e4276..80562fe3d 100644 --- a/httemplate/elements/tr-select-cust-fields.html +++ b/httemplate/elements/tr-select-cust-fields.html @@ -1,14 +1,15 @@ -<% - my( $cust_fields, %opt ) = @_; +% +% my( $cust_fields, %opt ) = @_; +% +% use FS::ConfDefaults; +% $opt{'avail_fields'} ||= [ FS::ConfDefaults->cust_fields_avail() ]; +% +% - use FS::ConfDefaults; - $opt{'avail_fields'} ||= [ FS::ConfDefaults->cust_fields_avail() ]; - -%> <TR> - <TD ALIGN="right"><%= $opt{'label'} || 'Customer fields' %></TD> + <TD ALIGN="right"><% $opt{'label'} || 'Customer fields' %></TD> <TD> - <%= include( '/elements/select-cust-fields.html', $cust_fields, %opt ) %> + <% include( '/elements/select-cust-fields.html', $cust_fields, %opt ) %> </TD> </TR> diff --git a/httemplate/elements/tr-select-cust_pkg-status.html b/httemplate/elements/tr-select-cust_pkg-status.html index 17768517d..22ee146cd 100644 --- a/httemplate/elements/tr-select-cust_pkg-status.html +++ b/httemplate/elements/tr-select-cust_pkg-status.html @@ -1,13 +1,14 @@ -<% - my( $status, %opt ) = @_; +% +% my( $status, %opt ) = @_; +% +% $opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } ) +% +% - $opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } ) - -%> <TR> - <TD ALIGN="right"><%= $opt{'label'} || 'Status' %></TD> + <TD ALIGN="right"><% $opt{'label'} || 'Status' %></TD> <TD> - <%= include( '/elements/select-cust_pkg-status.html', $status, %opt ) %> + <% include( '/elements/select-cust_pkg-status.html', $status, %opt ) %> </TD> </TR> diff --git a/httemplate/elements/tr-select-from_to.html b/httemplate/elements/tr-select-from_to.html index d7e5a8337..083243d40 100644 --- a/httemplate/elements/tr-select-from_to.html +++ b/httemplate/elements/tr-select-from_to.html @@ -1,33 +1,34 @@ -<% +% +% +% #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +% my ($curmon,$curyear) = (localtime(time))[4,5]; +% +% #find first month +% my $syear = 1899+$curyear; +% my $smonth = $curmon+1; +% +% #want 12 month by default, not 13 +% $smonth++; +% if ( $smonth > 12 ) { $smonth-=12; $syear++ } +% +% #find last month +% my $eyear = 1900+$curyear; +% my $emonth = $curmon+1; +% +% my %hash = ( +% 'show_month_abbr' => 1, +% 'start_year' => '1999', +% 'end_year' => '2012', #haha, well... +% @_, +% ); +% +% - #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); - my ($curmon,$curyear) = (localtime(time))[4,5]; - - #find first month - my $syear = 1899+$curyear; - my $smonth = $curmon+1; - - #want 12 month by default, not 13 - $smonth++; - if ( $smonth > 12 ) { $smonth-=12; $syear++ } - - #find last month - my $eyear = 1900+$curyear; - my $emonth = $curmon+1; - - my %hash = ( - 'show_month_abbr' => 1, - 'start_year' => '1999', - 'end_year' => '2012', #haha, well... - @_, - ); - -%> <TR> <TD ALIGN="right">From: </TD> <TD> - <%= include('/elements/select-month_year.html', + <% include('/elements/select-month_year.html', 'prefix' => 'start', 'selected_mon' => $smonth, 'selected_year' => $syear, @@ -40,7 +41,7 @@ <TR> <TD ALIGN="right">To: </TD> <TD> - <%= include('/elements/select-month_year.html', + <% include('/elements/select-month_year.html', 'prefix' => 'end', 'selected_mon' => $emonth, 'selected_year' => $eyear, diff --git a/httemplate/elements/tr-select-part_referral.html b/httemplate/elements/tr-select-part_referral.html index 0108388bc..35c5b8047 100644 --- a/httemplate/elements/tr-select-part_referral.html +++ b/httemplate/elements/tr-select-part_referral.html @@ -1,30 +1,30 @@ -<% - my( $refnum, %opt ) = @_; +% +% my( $refnum, %opt ) = @_; +% +% $opt{'part_referrals'} ||= +% [ FS::part_referral->all_part_referral( 1 ) ]; #1: include global +% +% my $r = qq!<font color="#ff0000">*</font> !; +% +% +% if ( scalar( @{$opt{'part_referrals'}} ) == 0 ) { +% eidiot "You have not created any advertising sources. You must create at least one advertising source before adding a customer. Go to ". popurl(2). "browse/part_referral.html and create one or more advertising sources."; +% } elsif ( scalar( @{$opt{'part_referrals'}} ) == 1 ) { +% - $opt{'part_referrals'} ||= - [ FS::part_referral->all_part_referral( 1 ) ]; #1: include global - my $r = qq!<font color="#ff0000">*</font> !; + <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $opt{'part_referrals'}->[0]->refnum %>"> +% } else { -%> - -<% if ( scalar( @{$opt{'part_referrals'}} ) == 0 ) { - eidiot "You have not created any advertising sources. You must create at least one advertising source before adding a customer. Go to ". popurl(2). "browse/part_referral.html and create one or more advertising sources."; - } elsif ( scalar( @{$opt{'part_referrals'}} ) == 1 ) { -%> - - <INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $opt{'part_referrals'}->[0]->refnum %>"> - -<% } else { %> <TR> - <TH ALIGN="right"><%=$r%>Advertising source</TH> + <TH ALIGN="right"><%$r%>Advertising source</TH> <TD> - <%= include( '/elements/select-part_referral.html', $refnum, + <% include( '/elements/select-part_referral.html', $refnum, 'part_referrals' => $opt{'part_referrals'}, ) %> </TD> </TR> +% } -<% } %> diff --git a/httemplate/elements/tr-select-pkg_class.html b/httemplate/elements/tr-select-pkg_class.html index fbab0db14..7f37e816e 100644 --- a/httemplate/elements/tr-select-pkg_class.html +++ b/httemplate/elements/tr-select-pkg_class.html @@ -1,22 +1,22 @@ -<% - my( $classnum, %opt ) = @_; +% +% my( $classnum, %opt ) = @_; +% +% $opt{'pkg_class'} ||= [ qsearch( 'pkg_class', {} ) ]; # { disabled=>'' } ) +% +% #warn "***** tr-select-pkg-class: \n". Dumper(%opt); +% +% if ( scalar(@{ $opt{'pkg_class'} }) == 0 ) { - $opt{'pkg_class'} ||= [ qsearch( 'pkg_class', {} ) ]; # { disabled=>'' } ) - - #warn "***** tr-select-pkg-class: \n". Dumper(%opt); -%> - -<% if ( scalar(@{ $opt{'pkg_class'} }) == 0 ) { %> <INPUT TYPE="hidden" NAME="classnum" VALUE=""> +% } else { -<% } else { %> <TR> - <TD ALIGN="right"><%= $opt{'label'} || 'Package class' %></TD> + <TD ALIGN="right"><% $opt{'label'} || 'Package class' %></TD> <TD> - <%= include( '/elements/select-pkg_class.html', $classnum, %opt ) %> + <% include( '/elements/select-pkg_class.html', $classnum, %opt ) %> </TD> </TR> +% } -<% } %> diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index e03438822..6efc395f7 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -1,15 +1,16 @@ -<% - my ( %opt ) = @_; +% +% my ( %opt ) = @_; +% +% my $url = $opt{'url'}; +% my $method = exists($opt{'method'}) ? $opt{'method'} : 'GET'; +% #my @subs = @{ $opt{'subs'}; +% my $key = exists($opt{'key'}) ? $opt{'key'} : ''; +% +% $url .= ( ($url =~ /\?/) ? '&' : '?' ) +% if $method eq 'GET'; +% +% - my $url = $opt{'url'}; - my $method = exists($opt{'method'}) ? $opt{'method'} : 'GET'; - #my @subs = @{ $opt{'subs'}; - my $key = exists($opt{'key'}) ? $opt{'key'} : ''; - - $url .= ( ($url =~ /\?/) ? '&' : '?' ) - if $method eq 'GET'; - -%> <SCRIPT TYPE="text/javascript"> @@ -31,22 +32,22 @@ return A; } +% foreach my $func ( @{$opt{'subs'}} ) { +% +% my $furl = $url; +% $furl =~ s/\"/\\\\\"/; #javascript escape +% +% - <% foreach my $func ( @{$opt{'subs'}} ) { - - my $furl = $url; - $furl =~ s/\"/\\\\\"/; #javascript escape - - %> - function <%=$key%><%=$func%>() { + function <%$key%><%$func%>() { // count args; build URL - var url = "<%=$furl%>"; - var a = <%=$key%><%=$func%>.arguments; + var url = "<%$furl%>"; + var a = <%$key%><%$func%>.arguments; var args; var len; - var content = 'sub=<%= uri_escape($func) %>'; + var content = 'sub=<% uri_escape($func) %>'; if ( a && typeof a == 'object' && a[0].constructor == Array ) { args = a[0]; len = args.length @@ -58,14 +59,14 @@ content = content + "&arg=" + escape(args[i]); content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs - if ( '<%=$method%>' == 'GET' ) { + if ( '<%$method%>' == 'GET' ) { url = url + content; } - //alert('<%=$method%> ' + url); + //alert('<%$method%> ' + url); var xmlhttp = rs_init_object(); - xmlhttp.open("<%=$method%>", url, true); + xmlhttp.open("<%$method%>", url, true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState != 4) @@ -89,7 +90,7 @@ } } - if ( '<%=$method%>' == 'POST' ) { + if ( '<%$method%>' == 'POST' ) { xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp.send(content); @@ -104,7 +105,7 @@ //rs_debug("x_$func_name url = " + url); //rs_debug("x_$func_name waiting.."); } +% } - <% } %> </SCRIPT> diff --git a/httemplate/graph/cust_bill_pkg.cgi b/httemplate/graph/cust_bill_pkg.cgi index acd39b025..ea5ae0b2b 100644 --- a/httemplate/graph/cust_bill_pkg.cgi +++ b/httemplate/graph/cust_bill_pkg.cgi @@ -1,103 +1,104 @@ -<% - - -#find first month -my $syear = $cgi->param('start_year'); # || 1899+$curyear; -my $smonth = $cgi->param('start_month'); # || $curmon+1; - -#find last month -my $eyear = $cgi->param('end_year'); # || 1900+$curyear; -my $emonth = $cgi->param('end_month'); # || $curmon+1; - -#XXX or virtual -my( $agentnum, $sel_agent ) = ('', ''); -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $agentnum = $1; - $sel_agent = qsearchs('agent', { 'agentnum' => $agentnum } ); - die "agentnum $agentnum not found!" unless $sel_agent; -} -my $title = $sel_agent ? $sel_agent->agent.' ' : ''; - -#false lazinessish w/search/cust_pkg.cgi -my $classnum = 0; -my @pkg_class = (); -if ( $cgi->param('classnum') =~ /^(\d*)$/ ) { - $classnum = $1; - if ( $classnum ) { - @pkg_class = ( qsearchs('pkg_class', { 'classnum' => $classnum } ) ); - die "classnum $classnum not found!" unless $pkg_class[0]; - $title .= $pkg_class[0]->classname.' '; - } elsif ( $classnum eq '' ) { - $title .= 'Empty class '; - @pkg_class = ( '(empty class)' ); - } elsif ( $classnum eq '0' ) { - @pkg_class = qsearch('pkg_class', {} ); # { 'disabled' => '' } ); - push @pkg_class, '(empty class)'; - } -} -#eslaf - -my $hue = 0; -#my $hue_increment = 170; -#my $hue_increment = 145; -my $hue_increment = 125; - -my @items = (); -my @params = (); -my @labels = (); -my @colors = (); -my @links = (); - -my $link = "${p}search/cust_bill_pkg.cgi?nottax=1;include_comp_cust=1"; - -foreach my $agent ( $sel_agent || qsearch('agent', { 'disabled' => '' } ) ) { - - my $col_scheme = Color::Scheme->new - ->from_hue($hue) #->from_hex($agent->color) - ->scheme('analogic') - ; - my @recur_colors = (); - my @onetime_colors = (); - - ### fixup the color handling for package classes... - my $n = 0; - - foreach my $pkg_class ( @pkg_class ) { - - push @items, 'cust_bill_pkg'; - - - push @labels, - ( $sel_agent ? '' : $agent->agent.' ' ). - ( $classnum eq '0' - ? ( ref($pkg_class) ? $pkg_class->classname : $pkg_class ) - : '' - ); - - my $row_classnum = ref($pkg_class) ? $pkg_class->classnum : 0; - my $row_agentnum = $agent->agentnum; - push @params, [ 'classnum' => $row_classnum, - 'agentnum' => $row_agentnum, - ]; - - push @links, "$link;agentnum=$row_agentnum;classnum=$row_classnum;"; - - @recur_colors = ($col_scheme->colors)[0,4,8,1,5,9] - unless @recur_colors; - @onetime_colors = ($col_scheme->colors)[2,6,10,3,7,11] - unless @onetime_colors; - push @colors, shift @recur_colors; - - } - - $hue += $hue_increment; - -} - -#use Data::Dumper; -#warn Dumper(\@items); - -%><%= include('elements/monthly.html', +% +% +% +%#find first month +%my $syear = $cgi->param('start_year'); # || 1899+$curyear; +%my $smonth = $cgi->param('start_month'); # || $curmon+1; +% +%#find last month +%my $eyear = $cgi->param('end_year'); # || 1900+$curyear; +%my $emonth = $cgi->param('end_month'); # || $curmon+1; +% +%#XXX or virtual +%my( $agentnum, $sel_agent ) = ('', ''); +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $agentnum = $1; +% $sel_agent = qsearchs('agent', { 'agentnum' => $agentnum } ); +% die "agentnum $agentnum not found!" unless $sel_agent; +%} +%my $title = $sel_agent ? $sel_agent->agent.' ' : ''; +% +%#false lazinessish w/search/cust_pkg.cgi +%my $classnum = 0; +%my @pkg_class = (); +%if ( $cgi->param('classnum') =~ /^(\d*)$/ ) { +% $classnum = $1; +% if ( $classnum ) { +% @pkg_class = ( qsearchs('pkg_class', { 'classnum' => $classnum } ) ); +% die "classnum $classnum not found!" unless $pkg_class[0]; +% $title .= $pkg_class[0]->classname.' '; +% } elsif ( $classnum eq '' ) { +% $title .= 'Empty class '; +% @pkg_class = ( '(empty class)' ); +% } elsif ( $classnum eq '0' ) { +% @pkg_class = qsearch('pkg_class', {} ); # { 'disabled' => '' } ); +% push @pkg_class, '(empty class)'; +% } +%} +%#eslaf +% +%my $hue = 0; +%#my $hue_increment = 170; +%#my $hue_increment = 145; +%my $hue_increment = 125; +% +%my @items = (); +%my @params = (); +%my @labels = (); +%my @colors = (); +%my @links = (); +% +%my $link = "${p}search/cust_bill_pkg.cgi?nottax=1;include_comp_cust=1"; +% +%foreach my $agent ( $sel_agent || qsearch('agent', { 'disabled' => '' } ) ) { +% +% my $col_scheme = Color::Scheme->new +% ->from_hue($hue) #->from_hex($agent->color) +% ->scheme('analogic') +% ; +% my @recur_colors = (); +% my @onetime_colors = (); +% +% ### fixup the color handling for package classes... +% my $n = 0; +% +% foreach my $pkg_class ( @pkg_class ) { +% +% push @items, 'cust_bill_pkg'; +% +% +% push @labels, +% ( $sel_agent ? '' : $agent->agent.' ' ). +% ( $classnum eq '0' +% ? ( ref($pkg_class) ? $pkg_class->classname : $pkg_class ) +% : '' +% ); +% +% my $row_classnum = ref($pkg_class) ? $pkg_class->classnum : 0; +% my $row_agentnum = $agent->agentnum; +% push @params, [ 'classnum' => $row_classnum, +% 'agentnum' => $row_agentnum, +% ]; +% +% push @links, "$link;agentnum=$row_agentnum;classnum=$row_classnum;"; +% +% @recur_colors = ($col_scheme->colors)[0,4,8,1,5,9] +% unless @recur_colors; +% @onetime_colors = ($col_scheme->colors)[2,6,10,3,7,11] +% unless @onetime_colors; +% push @colors, shift @recur_colors; +% +% } +% +% $hue += $hue_increment; +% +%} +% +%#use Data::Dumper; +%#warn Dumper(\@items); +% +% +<% include('elements/monthly.html', 'title' => $title. 'Sales Report (Gross)', 'graph_type' => 'Mountain', 'items' => \@items, diff --git a/httemplate/graph/elements/monthly.html b/httemplate/graph/elements/monthly.html index 3b9f73aa1..f5789a2a2 100644 --- a/httemplate/graph/elements/monthly.html +++ b/httemplate/graph/elements/monthly.html @@ -1,206 +1,207 @@ -<% - - # options example... - # - # 'title' => 'Page title', - # 'items' => \@items, - # 'params' => \@params, # opt, - # 'labels' => \@labels, # or \%labels (keys are items) - # 'graph_labels' => \@graph_labels, # or \%graph_labels, - # 'colors' => \@colors, # or \%colors, - # 'links => \@links, # or \%link, #opt - # 'start_month' => $smonth, - # 'start_year' => $syear, - # 'end_month' => $emonth, - # 'end_year' => $eyear, - # 'agentnum' => $agentnum, #opt - # 'nototal' => 1, #opt, - # 'graph_type' => 'LinesPoints', #opt - # 'remove_empty' => 1, #opt, - # 'bottom_total' => 1, #opt, - - my(%opt) = @_; - my @items = @{ $opt{'items'} }; - - foreach my $other (qw( labels graph_labels colors links )) { - #foreach my $other (qw( labels graph_labels colors )) { - if ( ref($opt{$other}) eq 'HASH' ) { - $opt{$other} = [ map $opt{$other}{$_}, @items ]; - } - } - - my $report = new FS::Report::Table::Monthly ( - - #'items' => $opt{'items'}, - 'items' => \@items, - 'params' => $opt{'params'}, - 'item_labels' => ( $cgi->param('_type') =~ /^(png)$/ - ? $opt{'graph_labels'} - : $opt{'labels'} - ), - 'colors' => $opt{'colors'}, - 'links' => $opt{'links'}, - - 'start_month' => $opt{'start_month'}, - 'start_year' => $opt{'start_year'}, - 'end_month' => $opt{'end_month'}, - 'end_year' => $opt{'end_year'}, - - 'agentnum' => $opt{'agentnum'}, - 'remove_empty' => $opt{'remove_empty'}, - ); - my $data = $report->data; - - if ( $cgi->param('_type') =~ /^(png)$/ ) { - - #my $chart = Chart::LinesPoints->new(1024,480); - #my $chart = Chart::LinesPoints->new(768,480); - - my $graph_type = 'LinesPoints'; - if ( $opt{'graph_type'} =~ /^(LinesPoints|Mountain)$/ ) { - $graph_type = $1; - } - my $class = "Chart::$graph_type"; - - my $chart = $class->new(976,384); - - my $d = 0; - $chart->set( - #'min_val' => 0, - 'legend' => 'bottom', - 'colors' => { ( - map { my $color = $_; - 'dataset'.$d++ => - [ map hex($_), unpack 'a2a2a2', $color ] - } - #@{ $opt{'colors'} } - @{ $data->{'colors'} } - ), - #'grey_background' => [ 211, 211, 211 ], - 'grey_background' => 'white', - 'background' => [ 0xe8, 0xe8, 0xe8 ], #grey - }, - #'grey_background' => 'false', - 'legend_labels' => $data->{'item_labels'}, - 'brush_size' => 4, - #'pt_size' => 12, - ); - - #my @data = map { $data->{$_} } ( 'label', @items ); - my @data = @{ $data->{data} }; - unshift @data, $data->{'label'}; - - http_header('Content-Type' => 'image/png' ); - - $chart->_set_colors(); - - %><%= $chart->scalar_png(\@data) %><% - - } else { - - my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); - -%><%= include('/elements/header.html', $opt{'title'} ) %> - -<% $cgi->param('_type', 'png'); %> -<IMG SRC="<%= $cgi->self_url %>" WIDTH="976" HEIGHT="384"> +% +% +% # options example... +% # +% # 'title' => 'Page title', +% # 'items' => \@items, +% # 'params' => \@params, # opt, +% # 'labels' => \@labels, # or \%labels (keys are items) +% # 'graph_labels' => \@graph_labels, # or \%graph_labels, +% # 'colors' => \@colors, # or \%colors, +% # 'links => \@links, # or \%link, #opt +% # 'start_month' => $smonth, +% # 'start_year' => $syear, +% # 'end_month' => $emonth, +% # 'end_year' => $eyear, +% # 'agentnum' => $agentnum, #opt +% # 'nototal' => 1, #opt, +% # 'graph_type' => 'LinesPoints', #opt +% # 'remove_empty' => 1, #opt, +% # 'bottom_total' => 1, #opt, +% +% my(%opt) = @_; +% my @items = @{ $opt{'items'} }; +% +% foreach my $other (qw( labels graph_labels colors links )) { +% #foreach my $other (qw( labels graph_labels colors )) { +% if ( ref($opt{$other}) eq 'HASH' ) { +% $opt{$other} = [ map $opt{$other}{$_}, @items ]; +% } +% } +% +% my $report = new FS::Report::Table::Monthly ( +% +% #'items' => $opt{'items'}, +% 'items' => \@items, +% 'params' => $opt{'params'}, +% 'item_labels' => ( $cgi->param('_type') =~ /^(png)$/ +% ? $opt{'graph_labels'} +% : $opt{'labels'} +% ), +% 'colors' => $opt{'colors'}, +% 'links' => $opt{'links'}, +% +% 'start_month' => $opt{'start_month'}, +% 'start_year' => $opt{'start_year'}, +% 'end_month' => $opt{'end_month'}, +% 'end_year' => $opt{'end_year'}, +% +% 'agentnum' => $opt{'agentnum'}, +% 'remove_empty' => $opt{'remove_empty'}, +% ); +% my $data = $report->data; +% +% if ( $cgi->param('_type') =~ /^(png)$/ ) { +% +% #my $chart = Chart::LinesPoints->new(1024,480); +% #my $chart = Chart::LinesPoints->new(768,480); +% +% my $graph_type = 'LinesPoints'; +% if ( $opt{'graph_type'} =~ /^(LinesPoints|Mountain)$/ ) { +% $graph_type = $1; +% } +% my $class = "Chart::$graph_type"; +% +% my $chart = $class->new(976,384); +% +% my $d = 0; +% $chart->set( +% #'min_val' => 0, +% 'legend' => 'bottom', +% 'colors' => { ( +% map { my $color = $_; +% 'dataset'.$d++ => +% [ map hex($_), unpack 'a2a2a2', $color ] +% } +% #@{ $opt{'colors'} } +% @{ $data->{'colors'} } +% ), +% #'grey_background' => [ 211, 211, 211 ], +% 'grey_background' => 'white', +% 'background' => [ 0xe8, 0xe8, 0xe8 ], #grey +% }, +% #'grey_background' => 'false', +% 'legend_labels' => $data->{'item_labels'}, +% 'brush_size' => 4, +% #'pt_size' => 12, +% ); +% +% #my @data = map { $data->{$_} } ( 'label', @items ); +% my @data = @{ $data->{data} }; +% unshift @data, $data->{'label'}; +% +% http_header('Content-Type' => 'image/png' ); +% +% $chart->_set_colors(); +% +% +<% $chart->scalar_png(\@data) %> +% +% +% } else { +% +% my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); +% +% +<% include('/elements/header.html', $opt{'title'} ) %> +% $cgi->param('_type', 'png'); + +<IMG SRC="<% $cgi->self_url %>" WIDTH="976" HEIGHT="384"> <BR> -<%= table('e8e8e8') %> +<% table('e8e8e8') %> <TR> <TD></TD> +% foreach my $column ( @{$data->{label}} ) { +% #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e; +% $column =~ s/^(\d+)\//$mon[$1-1]<BR>/; +% - <% foreach my $column ( @{$data->{label}} ) { - #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e; - $column =~ s/^(\d+)\//$mon[$1-1]<BR>/; - %> - <TH><%= $column %></TH> - <% } %> + <TH><% $column %></TH> +% } +% unless ( $opt{'nototal'} ) { - <% unless ( $opt{'nototal'} ) { %> <TH>Total</TH> - <% } %> +% } -</TR> -<% my @bottom_total = (); - foreach my $row ( @{ $data->{'items'} } ) { +</TR> +% my @bottom_total = (); +% foreach my $row ( @{ $data->{'items'} } ) { +% +% #my $color = shift( @{ $opt{'colors'} } ); +% my $color = shift( @{ $data->{'colors'} } ); +% my $link = shift( @{ $data->{'links'} } ); +% $link = $link ? qq(<A HREF="$link) : ''; +% - #my $color = shift( @{ $opt{'colors'} } ); - my $color = shift( @{ $data->{'colors'} } ); - my $link = shift( @{ $data->{'links'} } ); - $link = $link ? qq(<A HREF="$link) : ''; -%> <TR> - <TH><FONT COLOR="#<%= $color %>"><%= shift( @{ $data->{'item_labels'} } ) %></FONT></TH> + <TH><FONT COLOR="#<% $color %>"><% shift( @{ $data->{'item_labels'} } ) %></FONT></TH> +% #my $link = exists($opt{'links'}{$row}) +% # ? qq(<A HREF="$opt{'links'}{$row}) +% # : ''; +% my @speriod = @{$data->{speriod}}; +% my @eperiod = @{$data->{eperiod}}; +% my $total = 0; +% +% my $col = 0; +% foreach my $column ( @{ shift( @{$data->{data}} ) } ) { # ( @{$data->{$row}} ) { +% - <% #my $link = exists($opt{'links'}{$row}) - # ? qq(<A HREF="$opt{'links'}{$row}) - # : ''; - my @speriod = @{$data->{speriod}}; - my @eperiod = @{$data->{eperiod}}; - my $total = 0; - %> - <% my $col = 0; - foreach my $column ( @{ shift( @{$data->{data}} ) } ) { # ( @{$data->{$row}} ) { - %> <TD ALIGN="right" BGCOLOR="#ffffff"> - <%= $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<%= $color %>">$<%= sprintf("%.2f", $column) %></FONT><%= $link ? '</A>' : '' %> + <% $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<% $color %>">$<% sprintf("%.2f", $column) %></FONT><% $link ? '</A>' : '' %> </TD> - <% - $total += $column; - $bottom_total[$col++] += $column; - %> - - <% } %> +% +% $total += $column; +% $bottom_total[$col++] += $column; +% +% } +% unless ( $opt{'nototal'} ) { - <% unless ( $opt{'nototal'} ) { %> <TD ALIGN="right" BGCOLOR="#f5f6be"> - <%= $link ? $link. 'begin='. ${$data->{speriod}}[0]. ';end='. ${$data->{eperiod}}[-1]. '">' : '' %><FONT COLOR="#<%= $color %>">$<%= sprintf("%.2f", $total) %></FONT><%= $link ? '</A>' : '' %> + <% $link ? $link. 'begin='. ${$data->{speriod}}[0]. ';end='. ${$data->{eperiod}}[-1]. '">' : '' %><FONT COLOR="#<% $color %>">$<% sprintf("%.2f", $total) %></FONT><% $link ? '</A>' : '' %> </TD> +% $bottom_total[$col++] += $total; +% } - <% $bottom_total[$col++] += $total; %> - - <% } %> </TR> +% } +% if ( $opt{'bottom_total'} ) { +% my @speriod = ( @{$data->{speriod}}, ${$data->{speriod}}[0] ); +% my @eperiod = ( @{$data->{eperiod}}, ${$data->{eperiod}}[-1] ); +% -<% } %> - -<% if ( $opt{'bottom_total'} ) { - my @speriod = ( @{$data->{speriod}}, ${$data->{speriod}}[0] ); - my @eperiod = ( @{$data->{eperiod}}, ${$data->{eperiod}}[-1] ); -%> <TR> <TH>Total</TH> +% foreach my $total ( @bottom_total ) { - <% foreach my $total ( @bottom_total ) { %> <TD ALIGN="right" BGCOLOR="#f5f6be"> - <%= $opt{'bottom_link'} + <% $opt{'bottom_link'} ? '<A HREF="'. $opt{'bottom_link'}. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' - %>$<%= sprintf("%.2f", $total) %><%= $opt{'bottom_link'} ? '</A>' : '' %> + %>$<% sprintf("%.2f", $total) %><% $opt{'bottom_link'} ? '</A>' : '' %> </TD> +% } - <% } %> </TR> +% } -<% } %> </TABLE> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> +% } -<% } %> diff --git a/httemplate/graph/money_time.cgi b/httemplate/graph/money_time.cgi index f085c2264..829b1e66f 100644 --- a/httemplate/graph/money_time.cgi +++ b/httemplate/graph/money_time.cgi @@ -1,68 +1,69 @@ -<% - -#find first month -my $syear = $cgi->param('start_year'); # || 1899+$curyear; -my $smonth = $cgi->param('start_month'); # || $curmon+1; - -#find last month -my $eyear = $cgi->param('end_year'); # || 1900+$curyear; -my $emonth = $cgi->param('end_month'); # || $curmon+1; - -#XXX or virtual -my( $agentnum, $agent ) = ('', ''); -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $agentnum = $1; - $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); - die "agentnum $agentnum not found!" unless $agent; -} -my $agentname = $agent ? $agent->agent.' ' : ''; - -my @items = qw( invoiced netsales credits payments receipts ); -if ( $cgi->param('12mo') == 1 ) { - @items = map $_.'_12mo', @items; -} - -my %label = ( - 'invoiced' => 'Gross Sales', - 'netsales' => 'Net Sales', - 'credits' => 'Credits', - 'payments' => 'Gross Receipts', - 'receipts' => 'Net Receipts', -); - -my %graph_suffix = ( - 'invoiced' => ' (invoiced)', - 'netsales' => ' (invoiced - applied credits)', - 'credits' => '', - 'payments' => ' (payments)', - 'receipts' => '/Cashflow (payments - refunds)', -); -my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label; - -$label{$_.'_12mo'} = $label{$_}. " (previous 12 months)" - foreach keys %label; - -$graph_label{$_.'_12mo'} = $graph_label{$_}. " (previous 12 months)" - foreach keys %graph_label; - -my %color = ( - 'invoiced' => '9999ff', #light blue - 'netsales' => '0000cc', #blue - 'credits' => 'cc0000', #red - 'payments' => '99cc99', #light green - 'receipts' => '00cc00', #green -); -$color{$_.'_12mo'} = $color{$_} - foreach keys %color; - -my %link = ( - 'invoiced' => "${p}search/cust_bill.html?agentnum=$agentnum;", - 'credits' => "${p}search/cust_credit.html?agentnum=$agentnum;", - 'payments' => "${p}search/cust_pay.cgi?magic=_date;agentnum=$agentnum;", -); -# XXX link 12mo? - -%><%= include('elements/monthly.html', +% +% +%#find first month +%my $syear = $cgi->param('start_year'); # || 1899+$curyear; +%my $smonth = $cgi->param('start_month'); # || $curmon+1; +% +%#find last month +%my $eyear = $cgi->param('end_year'); # || 1900+$curyear; +%my $emonth = $cgi->param('end_month'); # || $curmon+1; +% +%#XXX or virtual +%my( $agentnum, $agent ) = ('', ''); +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $agentnum = $1; +% $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); +% die "agentnum $agentnum not found!" unless $agent; +%} +%my $agentname = $agent ? $agent->agent.' ' : ''; +% +%my @items = qw( invoiced netsales credits payments receipts ); +%if ( $cgi->param('12mo') == 1 ) { +% @items = map $_.'_12mo', @items; +%} +% +%my %label = ( +% 'invoiced' => 'Gross Sales', +% 'netsales' => 'Net Sales', +% 'credits' => 'Credits', +% 'payments' => 'Gross Receipts', +% 'receipts' => 'Net Receipts', +%); +% +%my %graph_suffix = ( +% 'invoiced' => ' (invoiced)', +% 'netsales' => ' (invoiced - applied credits)', +% 'credits' => '', +% 'payments' => ' (payments)', +% 'receipts' => '/Cashflow (payments - refunds)', +%); +%my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label; +% +%$label{$_.'_12mo'} = $label{$_}. " (previous 12 months)" +% foreach keys %label; +% +%$graph_label{$_.'_12mo'} = $graph_label{$_}. " (previous 12 months)" +% foreach keys %graph_label; +% +%my %color = ( +% 'invoiced' => '9999ff', #light blue +% 'netsales' => '0000cc', #blue +% 'credits' => 'cc0000', #red +% 'payments' => '99cc99', #light green +% 'receipts' => '00cc00', #green +%); +%$color{$_.'_12mo'} = $color{$_} +% foreach keys %color; +% +%my %link = ( +% 'invoiced' => "${p}search/cust_bill.html?agentnum=$agentnum;", +% 'credits' => "${p}search/cust_credit.html?agentnum=$agentnum;", +% 'payments' => "${p}search/cust_pay.cgi?magic=_date;agentnum=$agentnum;", +%); +%# XXX link 12mo? +% +% +<% include('elements/monthly.html', 'title' => $agentname. 'Sales, Credits and Receipts Summary', 'items' => \@items, diff --git a/httemplate/graph/report_cust_bill_pkg.html b/httemplate/graph/report_cust_bill_pkg.html index 4f29b761f..664aab74e 100644 --- a/httemplate/graph/report_cust_bill_pkg.html +++ b/httemplate/graph/report_cust_bill_pkg.html @@ -1,14 +1,14 @@ -<%= include('/elements/header.html', 'Sales Report' ) %> +<% include('/elements/header.html', 'Sales Report' ) %> <FORM ACTION="cust_bill_pkg.cgi" METHOD="GET"> <TABLE> -<%= include('/elements/tr-select-from_to.html' ) %> +<% include('/elements/tr-select-from_to.html' ) %> -<%= include('/elements/tr-select-agent.html', 'label' => 'For agent: ' ) %> +<% include('/elements/tr-select-agent.html', 'label' => 'For agent: ' ) %> -<%= include('/elements/tr-select-pkg_class.html', '', +<% include('/elements/tr-select-pkg_class.html', '', 'pre_options' => [ '0' => 'all' ], 'empty_label' => '(empty class)', ) @@ -26,4 +26,4 @@ <BR><INPUT TYPE="submit" VALUE="Display"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/graph/report_money_time.html b/httemplate/graph/report_money_time.html index 564749686..b80696b65 100644 --- a/httemplate/graph/report_money_time.html +++ b/httemplate/graph/report_money_time.html @@ -1,4 +1,4 @@ -<%= include('/elements/header.html', 'Sales, Credits and Receipts Summary' ) %> +<% include('/elements/header.html', 'Sales, Credits and Receipts Summary' ) %> <FORM ACTION="money_time.cgi" METHOD="GET"> @@ -16,9 +16,9 @@ <TABLE> -<%= include('/elements/tr-select-from_to.html' ) %> +<% include('/elements/tr-select-from_to.html' ) %> -<%= include('/elements/tr-select-agent.html', '', 'label' => 'For agent: ' ) %> +<% include('/elements/tr-select-agent.html', '', 'label' => 'For agent: ' ) %> <TR> <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="12mo" VALUE="1"></TD> @@ -30,4 +30,4 @@ <BR><INPUT TYPE="submit" VALUE="Display"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/index.html b/httemplate/index.html index 1a92b45f6..57d85a9fb 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -1,59 +1,59 @@ -<% my $conf = new FS::Conf; %> -<%= include('/elements/header.html', 'Billing Main' ) %> +% my $conf = new FS::Conf; + +<% include('/elements/header.html', 'Billing Main' ) %> +% +% +% my $sth = dbh->prepare( +% #"SELECT DISTINCT custnum FROM h_cust_main JOIN cust_main USING ( custnum ) +% "SELECT custnum FROM h_cust_main JOIN cust_main USING ( custnum ) +% WHERE ( history_action = 'insert' OR history_action = 'replace_new' ) +% AND history_user = ? +% ORDER BY history_date desc" # LIMIT 10 +% ) or die dbh->errstr; +% +% $sth->execute( getotaker() ) or die $sth->errstr; +% +% my %saw = (); +% my @custnums = grep { !$saw{$_}++ } map $_->[0], @{ $sth->fetchall_arrayref }; +% +% @custnums = splice(@custnums, 0, 10); +% +% if ( @custnums ) { +% +% + + + <% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor; +% -<% - - my $sth = dbh->prepare( - #"SELECT DISTINCT custnum FROM h_cust_main JOIN cust_main USING ( custnum ) - "SELECT custnum FROM h_cust_main JOIN cust_main USING ( custnum ) - WHERE ( history_action = 'insert' OR history_action = 'replace_new' ) - AND history_user = ? - ORDER BY history_date desc" # LIMIT 10 - ) or die dbh->errstr; - - $sth->execute( getotaker() ) or die $sth->errstr; - - my %saw = (); - my @custnums = grep { !$saw{$_}++ } map $_->[0], @{ $sth->fetchall_arrayref }; - - @custnums = splice(@custnums, 0, 10); - - if ( @custnums ) { - -%> - - <%= include('/elements/table-grid.html') %> - - <% my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor; - %> <TR> <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=1>Customers I recently added or modified</TH> </TR> +% foreach my $custnum ( @custnums ) { +% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); +% next unless $cust_main; - <% foreach my $custnum ( @custnums ) { %> - <% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); %> - <% next unless $cust_main; %> <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF="view/cust_main.cgi?<%= $custnum %>"><%= $custnum %>: <%= $cust_main->name %></A></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="view/cust_main.cgi?<% $custnum %>"><% $custnum %>: <% $cust_main->name %></A></TD> </TR> +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% } - <% - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - %> - - <% } %> </TABLE> +% } -<% } %> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/misc/batch-cust_pay.html b/httemplate/misc/batch-cust_pay.html index ed093ac08..d85f3b6c3 100644 --- a/httemplate/misc/batch-cust_pay.html +++ b/httemplate/misc/batch-cust_pay.html @@ -1,14 +1,15 @@ -<%= include("/elements/header.html", 'Quick payment entry', +<% include("/elements/header.html", 'Quick payment entry', menubar( 'Main Menu' => $p, #popurl(1), ), ( $cgi->param('error') ? '' : 'onload="addRow()"' ), ) %> +% if ( $cgi->param('error') ) { + + <FONT SIZE="+1" COLOR="#ff0000"><% $cgi->param('error') %></FONT><BR><BR> +% } -<% if ( $cgi->param('error') ) { %> - <FONT SIZE="+1" COLOR="#ff0000"><%= $cgi->param('error') %></FONT><BR><BR> -<% } %> <FORM ACTION="process/batch-cust_pay.cgi" NAME="OneTrueForm" METHOD="POST" onsubmit="document.OneTrueForm.submit.disabled=true;"> @@ -237,60 +238,60 @@ <TH>Check #</TH> <TH BGCOLOR="#e8e8e8"></TH> </TR> +% my $row = 0; +% if ( $cgi->param('error') ) { +% my $param = $cgi->Vars; +% +% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { -<% my $row = 0; - if ( $cgi->param('error') ) { - my $param = $cgi->Vars; -%> - - <% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { %> <TR> <TD> - <INPUT TYPE="text" NAME="custnum<%= $row %>" ID="custnum<%= $row %>" SIZE=8 MAXLENGTH=12 VALUE="<%= $param->{"custnum$row"} %>" rownum="<%= $row %>"> + <INPUT TYPE="text" NAME="custnum<% $row %>" ID="custnum<% $row %>" SIZE=8 MAXLENGTH=12 VALUE="<% $param->{"custnum$row"} %>" rownum="<% $row %>"> <SCRIPT TYPE="text/javascript"> - var custnum_input<%= $row %> = document.getElementById("custnum<%= $row %>"); - custnum_input<%= $row %>.onfocus = clearhint_custnum; - custnum_input<%= $row %>.onchange = search_custnum; + var custnum_input<% $row %> = document.getElementById("custnum<% $row %>"); + custnum_input<% $row %>.onfocus = clearhint_custnum; + custnum_input<% $row %>.onchange = search_custnum; </SCRIPT> </TD> <TD> - <INPUT TYPE="text" NAME="customer<%= $row %>" ID="customer<%= $row %>" SIZE=64 VALUE="<%= $param->{"customer$row"} %>" rownum="<%= $row %>"> + <INPUT TYPE="text" NAME="customer<% $row %>" ID="customer<% $row %>" SIZE=64 VALUE="<% $param->{"customer$row"} %>" rownum="<% $row %>"> <SCRIPT TYPE="text/javascript"> - var customer_input<%= $row %> = document.getElementById("customer<%= $row %>"); - customer_input<%= $row %>.onfocus = clearhint_customer; - customer_input<%= $row %>.onclick = clearhint_customer; - customer_input<%= $row %>.onchange = search_customer; + var customer_input<% $row %> = document.getElementById("customer<% $row %>"); + customer_input<% $row %>.onfocus = clearhint_customer; + customer_input<% $row %>.onclick = clearhint_customer; + customer_input<% $row %>.onchange = search_customer; </SCRIPT> - <SELECT NAME="cust_select<%= $row %>" ID="cust_select<%= $row %>" rownum="<%= $row %>" STYLE="color:#ff0000; display:none"> + <SELECT NAME="cust_select<% $row %>" ID="cust_select<% $row %>" rownum="<% $row %>" STYLE="color:#ff0000; display:none"> </SELECT> <SCRIPT TYPE="text/javascript"> - var customer_select<%= $row %> = document.getElementById("cust_select<%= $row %>"); - customer_select<%= $row %>.onchange = select_customer; + var customer_select<% $row %> = document.getElementById("cust_select<% $row %>"); + customer_select<% $row %>.onchange = select_customer; </SCRIPT> </TD> <TD> - $<INPUT TYPE="text" NAME="paid<%= $row %>" SIZE=8 MAXLENGTH=8 VALUE="<%= $param->{"paid$row"} %>" > + $<INPUT TYPE="text" NAME="paid<% $row %>" SIZE=8 MAXLENGTH=8 VALUE="<% $param->{"paid$row"} %>" > </TD> <TD> - <INPUT TYPE="text" NAME="payinfo<%= $row %>" SIZE=10 VALUE="<%= $param->{"payinfo$row"} %>" > + <INPUT TYPE="text" NAME="payinfo<% $row %>" SIZE=10 VALUE="<% $param->{"payinfo$row"} %>" > </TD> <TD BGCOLOR="#e8e8e8"> - <% if ( $param->{"error$row"} ) { %> - <FONT SIZE="-1" COLOR="#ff0000">Error: <%= $param->{"error$row"} %></FONT> - <% } %> +% if ( $param->{"error$row"} ) { + + <FONT SIZE="-1" COLOR="#ff0000">Error: <% $param->{"error$row"} %></FONT> +% } + </TD> </TR> +% } +% } - <% } %> - -<% } %> </TABLE> @@ -303,7 +304,7 @@ </FORM> -<%= include('/elements/xmlhttp.html', +<% include('/elements/xmlhttp.html', 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi', 'subs' => [qw( custnum_search smart_search )], ) @@ -311,7 +312,7 @@ <SCRIPT TYPE="text/javascript"> - var rownum = <%= $row %>; + var rownum = <% $row %>; function addRow() { diff --git a/httemplate/misc/bill.cgi b/httemplate/misc/bill.cgi index 44d85b880..1532a44eb 100755 --- a/httemplate/misc/bill.cgi +++ b/httemplate/misc/bill.cgi @@ -1,38 +1,40 @@ -<% +% +% +%#untaint custnum +%my($query) = $cgi->keywords; +%$query =~ /^(\d*)$/; +%my $custnum = $1; +%my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); +%die "Can't find customer!\n" unless $cust_main; +% +%my $error = $cust_main->bill( +%# 'time'=>$time +% ); +%#&eidiot($error) if $error; +% +%unless ( $error ) { +% $cust_main->apply_payments; +% $cust_main->apply_credits; +% +% $error = $cust_main->collect( +% # 'invoice-time'=>$time, +% #'batch_card'=> 'yes', +% #'batch_card'=> 'no', +% #'report_badcard'=> 'yes', +% #'retry_card' => 'yes', +% 'retry' => 'yes', +% ); +%} +%#&eidiot($error) if $error; +% +%if ( $error ) { +% -#untaint custnum -my($query) = $cgi->keywords; -$query =~ /^(\d*)$/; -my $custnum = $1; -my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); -die "Can't find customer!\n" unless $cust_main; - -my $error = $cust_main->bill( -# 'time'=>$time - ); -#&eidiot($error) if $error; - -unless ( $error ) { - $cust_main->apply_payments; - $cust_main->apply_credits; - - $error = $cust_main->collect( - # 'invoice-time'=>$time, - #'batch_card'=> 'yes', - #'batch_card'=> 'no', - #'report_badcard'=> 'yes', - #'retry_card' => 'yes', - 'retry' => 'yes', - ); -} -#&eidiot($error) if $error; - -if ( $error ) { -%> <!-- mason kludge --> -<% - &idiot($error); -} else { - print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum"); -} -%> +% +% &idiot($error); +%} else { +% print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum"); +%} +% + diff --git a/httemplate/misc/cancel-unaudited.cgi b/httemplate/misc/cancel-unaudited.cgi index 43e439b58..6f070a444 100755 --- a/httemplate/misc/cancel-unaudited.cgi +++ b/httemplate/misc/cancel-unaudited.cgi @@ -1,34 +1,36 @@ -<% +% +% +%my $dbh = dbh; +% +%#untaint svcnum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +% +%#my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); +%#die "Unknown svcnum!" unless $svc_acct; +% +%my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +%die "Unknown svcnum!" unless $cust_svc; +%my $cust_pkg = $cust_svc->cust_pkg; +%if ( $cust_pkg ) { +% &eidiot( 'This account has already been audited. Cancel the '. +% qq!<A HREF="${p}view/cust_main.cgi?!. $cust_pkg->custnum. +% '#cust_pkg'. $cust_pkg->pkgnum. '">'. +% 'package</A> instead.'); +%} +% +%my $error = $cust_svc->cancel; +% +%if ( $error ) { +% -my $dbh = dbh; - -#untaint svcnum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; - -#my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); -#die "Unknown svcnum!" unless $svc_acct; - -my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -die "Unknown svcnum!" unless $cust_svc; -my $cust_pkg = $cust_svc->cust_pkg; -if ( $cust_pkg ) { - &eidiot( 'This account has already been audited. Cancel the '. - qq!<A HREF="${p}view/cust_main.cgi?!. $cust_pkg->custnum. - '#cust_pkg'. $cust_pkg->pkgnum. '">'. - 'package</A> instead.'); -} - -my $error = $cust_svc->cancel; - -if ( $error ) { - %> <!-- mason kludge --> -<% - &eidiot($error); -} else { - print $cgi->redirect(popurl(2)); -} +% +% &eidiot($error); +%} else { +% print $cgi->redirect(popurl(2)); +%} +% +% -%> diff --git a/httemplate/misc/cancel_pkg.cgi b/httemplate/misc/cancel_pkg.cgi index 0487677df..00b421f10 100755 --- a/httemplate/misc/cancel_pkg.cgi +++ b/httemplate/misc/cancel_pkg.cgi @@ -1,15 +1,16 @@ -<% +% +% +%#untaint pkgnum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal pkgnum"; +%my $pkgnum = $1; +% +%my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +% +%my $error = $cust_pkg->cancel; +%eidiot($error) if $error; +% +%print $cgi->redirect($p. "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); +% +% -#untaint pkgnum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal pkgnum"; -my $pkgnum = $1; - -my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - -my $error = $cust_pkg->cancel; -eidiot($error) if $error; - -print $cgi->redirect($p. "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); - -%> diff --git a/httemplate/misc/catchall.cgi b/httemplate/misc/catchall.cgi index 3402b61e6..8881746d1 100755 --- a/httemplate/misc/catchall.cgi +++ b/httemplate/misc/catchall.cgi @@ -1,133 +1,134 @@ <!-- mason kludge --> -<% +% +% +%my $conf = new FS::Conf; +% +%my($svc_domain, $svcnum, $pkgnum, $svcpart, $part_svc); +%if ( $cgi->param('error') ) { +% $svc_domain = new FS::svc_domain ( { +% map { $_, scalar($cgi->param($_)) } fields('svc_domain') +% } ); +% $svcnum = $svc_domain->svcnum; +% $pkgnum = $cgi->param('pkgnum'); +% $svcpart = $cgi->param('svcpart'); +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +%} else { +% my($query) = $cgi->keywords; +% if ( $query =~ /^(\d+)$/ ) { #editing +% $svcnum=$1; +% $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum}) +% or die "Unknown (svc_domain) svcnum!"; +% +% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) +% or die "Unknown (cust_svc) svcnum!"; +% +% $pkgnum=$cust_svc->pkgnum; +% $svcpart=$cust_svc->svcpart; +% +% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +% die "No part_svc entry!" unless $part_svc; +% +% } else { +% +% die "Invalid (svc_domain) svcnum!"; +% +% } +%} +% +%my %email; +%if ($pkgnum) { +% +% #find all possible user svcnums (and emails) +% +% #starting with that currently attached +% if ($svc_domain->catchall) { +% my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall}); +% $email{$svc_domain->catchall} = $svc_acct->email; +% } +% +% #and including the rest for this customer +% my($u_part_svc,@u_acct_svcparts); +% foreach $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) { +% push @u_acct_svcparts,$u_part_svc->getfield('svcpart'); +% } +% +% my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +% my($custnum)=$cust_pkg->getfield('custnum'); +% my($i_cust_pkg); +% foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { +% my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); +% my($acct_svcpart); +% foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding +% #record(s) in cust_svc ( for this +% #pkgnum ! ) +% my($i_cust_svc); +% foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) { +% my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')}); +% $email{$svc_acct->getfield('svcnum')}=$svc_acct->email; +% } +% } +% } +% +%} else { +% +% my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall}); +% $email{$svc_domain->catchall} = $svc_acct->email; +%} +% +%# add an absence of a catchall +%$email{''} = "(none)"; +% +%my $p1 = popurl(1); +%print header("Domain Catchall Edit", ''); +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT>" +% if $cgi->param('error'); +% +%print qq!<FORM ACTION="${p1}process/catchall.cgi" METHOD=POST>!; +% +%#display +% +% #formatting +% print "<PRE>"; +% +%#svcnum +%print qq!<INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">!; +%print qq!Service #<FONT SIZE=+1><B>!, $svcnum ? $svcnum : " (NEW)", "</B></FONT>"; +% +%#pkgnum +%print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!; +% +%#svcpart +%print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!; +% +%my($domain,$catchall)=( +% $svc_domain->domain, +% $svc_domain->catchall, +%); +% +%print qq!<INPUT TYPE="hidden" NAME="domain" VALUE="$domain">!; +% +%#catchall +%print qq!\n\nMail to <I>(anything)</I>@<B>$domain</B> forwards to <SELECT NAME="catchall" SIZE=1>!; +%foreach $_ (keys %email) { +% print "<OPTION", $_ eq $catchall ? " SELECTED" : "", +% qq! VALUE="$_">$email{$_}!; +%} +%print "</SELECT>"; +% +% #formatting +% print "</PRE>\n"; +% +%print qq!<CENTER><INPUT TYPE="submit" VALUE="Submit"></CENTER>!; +% +%print <<END; +% +% </FORM> +% </BODY> +%</HTML> +%END +% +% -my $conf = new FS::Conf; - -my($svc_domain, $svcnum, $pkgnum, $svcpart, $part_svc); -if ( $cgi->param('error') ) { - $svc_domain = new FS::svc_domain ( { - map { $_, scalar($cgi->param($_)) } fields('svc_domain') - } ); - $svcnum = $svc_domain->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $cgi->param('svcpart'); - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; -} else { - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum}) - or die "Unknown (svc_domain) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - } else { - - die "Invalid (svc_domain) svcnum!"; - - } -} - -my %email; -if ($pkgnum) { - - #find all possible user svcnums (and emails) - - #starting with that currently attached - if ($svc_domain->catchall) { - my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall}); - $email{$svc_domain->catchall} = $svc_acct->email; - } - - #and including the rest for this customer - my($u_part_svc,@u_acct_svcparts); - foreach $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) { - push @u_acct_svcparts,$u_part_svc->getfield('svcpart'); - } - - my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - my($custnum)=$cust_pkg->getfield('custnum'); - my($i_cust_pkg); - foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { - my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); - my($acct_svcpart); - foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding - #record(s) in cust_svc ( for this - #pkgnum ! ) - my($i_cust_svc); - foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) { - my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')}); - $email{$svc_acct->getfield('svcnum')}=$svc_acct->email; - } - } - } - -} else { - - my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall}); - $email{$svc_domain->catchall} = $svc_acct->email; -} - -# add an absence of a catchall -$email{''} = "(none)"; - -my $p1 = popurl(1); -print header("Domain Catchall Edit", ''); - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); - -print qq!<FORM ACTION="${p1}process/catchall.cgi" METHOD=POST>!; - -#display - - #formatting - print "<PRE>"; - -#svcnum -print qq!<INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">!; -print qq!Service #<FONT SIZE=+1><B>!, $svcnum ? $svcnum : " (NEW)", "</B></FONT>"; - -#pkgnum -print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!; - -#svcpart -print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!; - -my($domain,$catchall)=( - $svc_domain->domain, - $svc_domain->catchall, -); - -print qq!<INPUT TYPE="hidden" NAME="domain" VALUE="$domain">!; - -#catchall -print qq!\n\nMail to <I>(anything)</I>@<B>$domain</B> forwards to <SELECT NAME="catchall" SIZE=1>!; -foreach $_ (keys %email) { - print "<OPTION", $_ eq $catchall ? " SELECTED" : "", - qq! VALUE="$_">$email{$_}!; -} -print "</SELECT>"; - - #formatting - print "</PRE>\n"; - -print qq!<CENTER><INPUT TYPE="submit" VALUE="Submit"></CENTER>!; - -print <<END; - - </FORM> - </BODY> -</HTML> -END - -%> diff --git a/httemplate/misc/cdr-import.html b/httemplate/misc/cdr-import.html index 93de6e43f..5e9e2690d 100644 --- a/httemplate/misc/cdr-import.html +++ b/httemplate/misc/cdr-import.html @@ -1,4 +1,4 @@ -<%= include("/elements/header.html",'Call Detail Record Import') %> +<% include("/elements/header.html",'Call Detail Record Import') %> <FORM ACTION="process/cdr-import.html" METHOD="POST" ENCTYPE="multipart/form-data"> Import a CSV file containing Call Detail Records (CDRs).<BR><BR> CDR Format: <SELECT NAME="format"> @@ -12,5 +12,5 @@ Filename: <INPUT TYPE="file" NAME="csvfile"><BR><BR> <INPUT TYPE="submit" VALUE="Upload"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi index 5346fd9d8..17dc8b859 100755 --- a/httemplate/misc/change_pkg.cgi +++ b/httemplate/misc/change_pkg.cgi @@ -1,66 +1,67 @@ <!-- mason kludge --> -<% +% +% +%my $pkgnum; +%if ( $cgi->param('error') ) { +% #$custnum = $cgi->param('custnum'); +% #%remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg'); +% $pkgnum = ($cgi->param('remove_pkg'))[0]; +%} else { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% #$custnum = $1; +% $pkgnum = $1; +% #%remove_pkg = (); +%} +% +%my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ) +% or die "unknown pkgnum $pkgnum"; +%my $custnum = $cust_pkg->custnum; +% +%my $conf = new FS::Conf; +% +%my $p1 = popurl(1); +% +%my $cust_main = $cust_pkg->cust_main +% or die "can't get cust_main record for custnum ". $cust_pkg->custnum. +% " ( pkgnum ". cust_pkg->pkgnum. ")"; +%my $agent = $cust_main->agent; +% +%print header("Change Package", menubar( +% "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", +% 'Main Menu' => $p, +%)); +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT><BR><BR>" +% if $cgi->param('error'); +% +%my $part_pkg = $cust_pkg->part_pkg; +% +%print small_custview( $cust_main, $conf->config('countrydefault') ). +% qq!<FORM ACTION="${p}edit/process/cust_pkg.cgi" METHOD=POST>!. +% qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!. +% qq!<INPUT TYPE="hidden" NAME="remove_pkg" VALUE="$pkgnum">!. +% '<BR>Current package: '. $part_pkg->pkg. ' - '. $part_pkg->comment. +% qq!<BR>New package: <SELECT NAME="new_pkgpart"><OPTION VALUE=0></OPTION>!; +% +%foreach my $part_pkg ( +% grep { ! $_->disabled && $_->pkgpart != $cust_pkg->pkgpart } +% map { $_->part_pkg } $agent->agent_type->type_pkgs +%) { +% my $pkgpart = $part_pkg->pkgpart; +% print qq!<OPTION VALUE="$pkgpart"!; +% print ' SELECTED' if $cgi->param('error') +% && $cgi->param('new_pkgpart') == $pkgpart; +% print qq!>$pkgpart: !. $part_pkg->pkg. ' - '. $part_pkg->comment. '</OPTION>'; +%} +% +%print <<END; +%</SELECT> +%<BR><BR><INPUT TYPE="submit" VALUE="Change package"> +% </FORM> +% </BODY> +%</HTML> +%END +% -my $pkgnum; -if ( $cgi->param('error') ) { - #$custnum = $cgi->param('custnum'); - #%remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg'); - $pkgnum = ($cgi->param('remove_pkg'))[0]; -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - #$custnum = $1; - $pkgnum = $1; - #%remove_pkg = (); -} - -my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ) - or die "unknown pkgnum $pkgnum"; -my $custnum = $cust_pkg->custnum; - -my $conf = new FS::Conf; - -my $p1 = popurl(1); - -my $cust_main = $cust_pkg->cust_main - or die "can't get cust_main record for custnum ". $cust_pkg->custnum. - " ( pkgnum ". cust_pkg->pkgnum. ")"; -my $agent = $cust_main->agent; - -print header("Change Package", menubar( - "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", - 'Main Menu' => $p, -)); - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT><BR><BR>" - if $cgi->param('error'); - -my $part_pkg = $cust_pkg->part_pkg; - -print small_custview( $cust_main, $conf->config('countrydefault') ). - qq!<FORM ACTION="${p}edit/process/cust_pkg.cgi" METHOD=POST>!. - qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!. - qq!<INPUT TYPE="hidden" NAME="remove_pkg" VALUE="$pkgnum">!. - '<BR>Current package: '. $part_pkg->pkg. ' - '. $part_pkg->comment. - qq!<BR>New package: <SELECT NAME="new_pkgpart"><OPTION VALUE=0></OPTION>!; - -foreach my $part_pkg ( - grep { ! $_->disabled && $_->pkgpart != $cust_pkg->pkgpart } - map { $_->part_pkg } $agent->agent_type->type_pkgs -) { - my $pkgpart = $part_pkg->pkgpart; - print qq!<OPTION VALUE="$pkgpart"!; - print ' SELECTED' if $cgi->param('error') - && $cgi->param('new_pkgpart') == $pkgpart; - print qq!>$pkgpart: !. $part_pkg->pkg. ' - '. $part_pkg->comment. '</OPTION>'; -} - -print <<END; -</SELECT> -<BR><BR><INPUT TYPE="submit" VALUE="Change package"> - </FORM> - </BODY> -</HTML> -END -%> diff --git a/httemplate/misc/counties.cgi b/httemplate/misc/counties.cgi index 80ae616c9..c9eb98500 100644 --- a/httemplate/misc/counties.cgi +++ b/httemplate/misc/counties.cgi @@ -1,17 +1,18 @@ -<% - - my( $state, $country ) = $cgi->param('arg'); - - my @counties = - sort - map { s/[\n\r]//g; $_; } - map { $_->county; } - qsearch( 'cust_main_county', - { 'state' => $state, - 'country' => $country, - }, - ) - ; - - -%>[ <%= join(', ', map { qq("$_") } @counties) %> ] +% +% +% my( $state, $country ) = $cgi->param('arg'); +% +% my @counties = +% sort +% map { s/[\n\r]//g; $_; } +% map { $_->county; } +% qsearch( 'cust_main_county', +% { 'state' => $state, +% 'country' => $country, +% }, +% ) +% ; +% +% +% +[ <% join(', ', map { qq("$_") } @counties) %> ] diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 519e6c2b2..d29e4f5fc 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -1,22 +1,23 @@ -<% +% +% +%my $custnum; +%my $ban = ''; +%if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { +% $custnum = $1; +% $ban = $cgi->param('ban'); +%} else { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/ || die "Illegal custnum"; +% $custnum = $1; +%} +% +%my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); +% +%my @errors = $cust_main->cancel( 'ban' => $ban ); +%eidiot(join(' / ', @errors)) if scalar(@errors); +% +%#print $cgi->redirect($p. "view/cust_main.cgi?". $cust_main->custnum); +%print $cgi->redirect($p); +% +% -my $custnum; -my $ban = ''; -if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { - $custnum = $1; - $ban = $cgi->param('ban'); -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/ || die "Illegal custnum"; - $custnum = $1; -} - -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); - -my @errors = $cust_main->cancel( 'ban' => $ban ); -eidiot(join(' / ', @errors)) if scalar(@errors); - -#print $cgi->redirect($p. "view/cust_main.cgi?". $cust_main->custnum); -print $cgi->redirect($p); - -%> diff --git a/httemplate/misc/cust_main-import.cgi b/httemplate/misc/cust_main-import.cgi index 2ad4d95b4..f7a8d8b52 100644 --- a/httemplate/misc/cust_main-import.cgi +++ b/httemplate/misc/cust_main-import.cgi @@ -1,4 +1,4 @@ -<%= include("/elements/header.html",'Batch Customer Import') %> +<% include("/elements/header.html",'Batch Customer Import') %> <FORM ACTION="process/cust_main-import.cgi" METHOD="post" ENCTYPE="multipart/form-data"> @@ -16,9 +16,9 @@ of an integer, the string is searched for and if necessary auto-created in the target table. <BR><BR> -<%= &ntable("#cccccc") %> +<% &ntable("#cccccc") %> -<%= include('/elements/tr-select-agent.html', '', #$agentnum, +<% include('/elements/tr-select-agent.html', '', #$agentnum, 'label' => "<B>Agent</B>", 'empty_label' => 'Select agent', ) @@ -38,18 +38,20 @@ target table. <TH ALIGN="right">CSV filename</TH> <TD><INPUT TYPE="file" NAME="csvfile"></TD> </TR> +% #include('/elements/tr-select-part_referral.html') +% -<% #include('/elements/tr-select-part_referral.html') -%> <!-- <TR> <TH>First package</TH> <TD> <SELECT NAME="pkgpart"><OPTION VALUE="">(none)</OPTION> - <% foreach my $part_pkg ( qsearch('part_pkg',{'disabled'=>'' }) ) { %> - <OPTION VALUE="<%= $part_pkg->pkgpart %>"><%= $part_pkg->pkg. ' - '. $part_pkg->comment %></OPTION> - <% } %> +% foreach my $part_pkg ( qsearch('part_pkg',{'disabled'=>'' }) ) { + + <OPTION VALUE="<% $part_pkg->pkgpart %>"><% $part_pkg->pkg. ' - '. $part_pkg->comment %></OPTION> +% } + </SELECT> </TD> </TR> @@ -61,5 +63,5 @@ target table. <INPUT TYPE="submit" VALUE="Import"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/misc/cust_main-import_charges.cgi b/httemplate/misc/cust_main-import_charges.cgi index 8402386d5..cd4441e0b 100644 --- a/httemplate/misc/cust_main-import_charges.cgi +++ b/httemplate/misc/cust_main-import_charges.cgi @@ -1,5 +1,5 @@ <!-- mason kludge --> -<%= include("/elements/header.html",'Batch Customer Charge') %> +<% include("/elements/header.html",'Batch Customer Charge') %> <FORM ACTION="process/cust_main-import_charges.cgi" METHOD="post" ENCTYPE="multipart/form-data"> Import a CSV file containing customer charges.<BR><BR> Default file format is CSV, with the following field order: <i>custnum, amount, description</i><BR><BR> diff --git a/httemplate/misc/delete-cust_credit.cgi b/httemplate/misc/delete-cust_credit.cgi index 30de04d27..e4756a922 100755 --- a/httemplate/misc/delete-cust_credit.cgi +++ b/httemplate/misc/delete-cust_credit.cgi @@ -1,16 +1,17 @@ -<% +% +% +%#untaint crednum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal crednum"; +%my $crednum = $1; +% +%my $cust_credit = qsearchs('cust_credit',{'crednum'=>$crednum}); +%my $custnum = $cust_credit->custnum; +% +%my $error = $cust_credit->delete; +%eidiot($error) if $error; +% +%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); +% +% -#untaint crednum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal crednum"; -my $crednum = $1; - -my $cust_credit = qsearchs('cust_credit',{'crednum'=>$crednum}); -my $custnum = $cust_credit->custnum; - -my $error = $cust_credit->delete; -eidiot($error) if $error; - -print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); - -%> diff --git a/httemplate/misc/delete-cust_pay.cgi b/httemplate/misc/delete-cust_pay.cgi index 3efd918ab..1fda82e2a 100755 --- a/httemplate/misc/delete-cust_pay.cgi +++ b/httemplate/misc/delete-cust_pay.cgi @@ -1,16 +1,17 @@ -<% +% +% +%#untaint paynum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal paynum"; +%my $paynum = $1; +% +%my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}); +%my $custnum = $cust_pay->custnum; +% +%my $error = $cust_pay->delete; +%eidiot($error) if $error; +% +%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); +% +% -#untaint paynum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal paynum"; -my $paynum = $1; - -my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}); -my $custnum = $cust_pay->custnum; - -my $error = $cust_pay->delete; -eidiot($error) if $error; - -print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); - -%> diff --git a/httemplate/misc/delete-customer.cgi b/httemplate/misc/delete-customer.cgi index 430231737..378f69e61 100755 --- a/httemplate/misc/delete-customer.cgi +++ b/httemplate/misc/delete-customer.cgi @@ -1,60 +1,61 @@ <!-- mason kludge --> -<% +% +% +%my $conf = new FS::Conf; +%die "Customer deletions not enabled" unless $conf->exists('deletecustomers'); +% +%my($custnum, $new_custnum); +%if ( $cgi->param('error') ) { +% $custnum = $cgi->param('custnum'); +% $new_custnum = $cgi->param('new_custnum'); +%} else { +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/ or die "Illegal query: $query"; +% $custnum = $1; +% $new_custnum = ''; +%} +%my $cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } ) +% or die "Customer not found: $custnum"; +% +%print header('Delete customer'); +% +%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), +% "</FONT>" +% if $cgi->param('error'); +% +%print +% qq!<form action="!, popurl(1), qq!process/delete-customer.cgi" method=post>!, +% qq!<input type="hidden" name="custnum" value="$custnum">!; +% +%if ( qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ) ) { +% print "Move uncancelled packages to customer number ", +% qq!<input type="text" name="new_custnum" value="$new_custnum"><br><br>!; +%} +% +%print <<END; +%This will <b>completely remove</b> all traces of this customer record. This +%is <B>not</B> what you want if this is a real customer who has simply +%canceled service with you. For that, cancel all of the customer's packages. +%(you can optionally hide cancelled customers with the <a href="../config/config-view.cgi#hidecancelledcustomers">hidecancelledcustomers</a> configuration option) +%<br> +%<br>Are you <b>absolutely sure</b> you want to delete this customer? +%<br><input type="submit" value="Yes"> +%</form></body></html> +%END +% +%#Deleting a customer you have financial records on (i.e. credits) is +%#typically considered fraudulant bookkeeping. Remember, deleting +%#customers should ONLY be used for completely bogus records. You should +%#NOT delete real customers who simply discontinue service. +%# +%#For real customers who simply discontinue service, cancel all of the +%#customer's packages. Customers with all cancelled packages are not +%#billed. There is no need to take further action to prevent billing on +%#customers with all cancelled packages. +%# +%#Also see the "hidecancelledcustomers" and "hidecancelledpackages" +%#configuration options, which will allow you to surpress the display of +%#cancelled customers and packages, respectively. +% +% -my $conf = new FS::Conf; -die "Customer deletions not enabled" unless $conf->exists('deletecustomers'); - -my($custnum, $new_custnum); -if ( $cgi->param('error') ) { - $custnum = $cgi->param('custnum'); - $new_custnum = $cgi->param('new_custnum'); -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/ or die "Illegal query: $query"; - $custnum = $1; - $new_custnum = ''; -} -my $cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } ) - or die "Customer not found: $custnum"; - -print header('Delete customer'); - -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); - -print - qq!<form action="!, popurl(1), qq!process/delete-customer.cgi" method=post>!, - qq!<input type="hidden" name="custnum" value="$custnum">!; - -if ( qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ) ) { - print "Move uncancelled packages to customer number ", - qq!<input type="text" name="new_custnum" value="$new_custnum"><br><br>!; -} - -print <<END; -This will <b>completely remove</b> all traces of this customer record. This -is <B>not</B> what you want if this is a real customer who has simply -canceled service with you. For that, cancel all of the customer's packages. -(you can optionally hide cancelled customers with the <a href="../config/config-view.cgi#hidecancelledcustomers">hidecancelledcustomers</a> configuration option) -<br> -<br>Are you <b>absolutely sure</b> you want to delete this customer? -<br><input type="submit" value="Yes"> -</form></body></html> -END - -#Deleting a customer you have financial records on (i.e. credits) is -#typically considered fraudulant bookkeeping. Remember, deleting -#customers should ONLY be used for completely bogus records. You should -#NOT delete real customers who simply discontinue service. -# -#For real customers who simply discontinue service, cancel all of the -#customer's packages. Customers with all cancelled packages are not -#billed. There is no need to take further action to prevent billing on -#customers with all cancelled packages. -# -#Also see the "hidecancelledcustomers" and "hidecancelledpackages" -#configuration options, which will allow you to surpress the display of -#cancelled customers and packages, respectively. - -%> diff --git a/httemplate/misc/delete-domain_record.cgi b/httemplate/misc/delete-domain_record.cgi index dcc2d5022..cccce357e 100755 --- a/httemplate/misc/delete-domain_record.cgi +++ b/httemplate/misc/delete-domain_record.cgi @@ -1,15 +1,16 @@ -<% +% +% +%#untaint recnum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal recnum"; +%my $recnum = $1; +% +%my $domain_record = qsearchs('domain_record',{'recnum'=>$recnum}); +% +%my $error = $domain_record->delete; +%eidiot($error) if $error; +% +%print $cgi->redirect($p. "view/svc_domain.cgi?". $domain_record->svcnum); +% +% -#untaint recnum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal recnum"; -my $recnum = $1; - -my $domain_record = qsearchs('domain_record',{'recnum'=>$recnum}); - -my $error = $domain_record->delete; -eidiot($error) if $error; - -print $cgi->redirect($p. "view/svc_domain.cgi?". $domain_record->svcnum); - -%> diff --git a/httemplate/misc/delete-part_export.cgi b/httemplate/misc/delete-part_export.cgi index 7c4ab8b9d..16389a90c 100755 --- a/httemplate/misc/delete-part_export.cgi +++ b/httemplate/misc/delete-part_export.cgi @@ -1,15 +1,16 @@ -<% +% +% +%#untaint exportnum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal exportnum"; +%my $exportnum = $1; +% +%my $part_export = qsearchs('part_export',{'exportnum'=>$exportnum}); +% +%my $error = $part_export->delete; +%eidiot($error) if $error; +% +%print $cgi->redirect($p. "browse/part_export.cgi"); +% +% -#untaint exportnum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal exportnum"; -my $exportnum = $1; - -my $part_export = qsearchs('part_export',{'exportnum'=>$exportnum}); - -my $error = $part_export->delete; -eidiot($error) if $error; - -print $cgi->redirect($p. "browse/part_export.cgi"); - -%> diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi index 2c6481493..038aa2049 100644 --- a/httemplate/misc/download-batch.cgi +++ b/httemplate/misc/download-batch.cgi @@ -1,117 +1,132 @@ -<% - -my $conf=new FS::Conf; - -#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes -http_header('Content-Type' => 'text/plain' ); - -my $batchnum; -if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) { - $batchnum = $1; -} else { - die "No batch number (bad URL) \n"; -} - -my $format; -if ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) { - $format = $1; -} else { - $format = $conf->config('batch-default_format'); -} - -my $oldAutoCommit = $FS::UID::AutoCommit; -local $FS::UID::AutoCommit = 0; -my $dbh = dbh; - -my $pay_batch = qsearchs('pay_batch', {'batchnum'=>$batchnum, 'status'=>'O'} ); -die "No pending batch. \n" unless $pay_batch; - -my %batchhash = $pay_batch->hash; -$batchhash{'status'} = 'I'; -$batchhash{'download'} = time unless $batchhash{'download'}; -my $new = new FS::pay_batch \%batchhash; -my $error = $new->replace($pay_batch); -die "error updating batch status: $error\n" if $error; - -my $batchtotal=0; -my $batchcount=0; - -my (@date)=localtime($new->download); -my $jdate = sprintf("%03d", $date[5] % 100).sprintf("%03d", $date[7] + 1); -my $cdate = sprintf("%02d", $date[3]).sprintf("%02d", $date[4] + 1). - sprintf("%02d", $date[5] % 100); - -if ($format eq "BoM") { - - my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) = - $conf->config("batchconfig-$format"); - %><%= sprintf( "A%10s%04u%06u%05u%54s\n",$origid,$pay_batch->batchnum,$jdate,$datacenter,""). +% +% +%my $conf=new FS::Conf; +% +%#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes +%http_header('Content-Type' => 'text/plain' ); +% +%my $batchnum; +%if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) { +% $batchnum = $1; +%} else { +% die "No batch number (bad URL) \n"; +%} +% +%my $format; +%if ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) { +% $format = $1; +%} else { +% $format = $conf->config('batch-default_format'); +%} +% +%my $oldAutoCommit = $FS::UID::AutoCommit; +%local $FS::UID::AutoCommit = 0; +%my $dbh = dbh; +% +%my $pay_batch = qsearchs('pay_batch', {'batchnum'=>$batchnum, 'status'=>'O'} ); +%die "No pending batch. \n" unless $pay_batch; +% +%my %batchhash = $pay_batch->hash; +%$batchhash{'status'} = 'I'; +%$batchhash{'download'} = time unless $batchhash{'download'}; +%my $new = new FS::pay_batch \%batchhash; +%my $error = $new->replace($pay_batch); +%die "error updating batch status: $error\n" if $error; +% +%my $batchtotal=0; +%my $batchcount=0; +% +%my (@date)=localtime($new->download); +%my $jdate = sprintf("%03d", $date[5] % 100).sprintf("%03d", $date[7] + 1); +%my $cdate = sprintf("%02d", $date[3]).sprintf("%02d", $date[4] + 1). +% sprintf("%02d", $date[5] % 100); +% +%if ($format eq "BoM") { +% +% my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) = +% $conf->config("batchconfig-$format"); +% +<% sprintf( "A%10s%04u%06u%05u%54s\n",$origid,$pay_batch->batchnum,$jdate,$datacenter,""). sprintf( "XD%03u%06u%-15s%-30s%09u%-12s \n",$typecode,$jdate,$shortname,$longname,$mybank,$myacct ) - %><% - -}elsif ($format eq "PAP"){ - - my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) = - $conf->config("batchconfig-$format"); - %><%= sprintf( "H%10sD%3s%06u%-15s%09u%-12s%04u%19s\n",$origid,$typecode,$cdate,$shortname,$mybank,$myacct,$pay_batch->batchnum,"") - - %><% - -}elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){ -# 1; -}else{ - die "Unknown format for batch in batchconfig. \n"; -} - - -for my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum } - qsearch('cust_pay_batch', - {'batchnum'=>$pay_batch->batchnum} ) -) { - - $cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; - my( $mon, $y ) = ( $2, $1 ); - $mon = "0$mon" if $mon < 10; - my $exp = "$mon$y"; - $batchcount++; - $batchtotal += $cust_pay_batch->amount; - - if ($format eq "BoM") { - - my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); - %><%= sprintf( "D%010.0f%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->paybatchnum) %><% - - } elsif ($format eq "PAP"){ - - my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); - %><%= sprintf( "D%-23s%06u%-19s%09u%-12s%010.0f\n",$cust_pay_batch->payname,$cdate,$cust_pay_batch->paybatchnum,$aba,$account,$cust_pay_batch->amount*100) %><% - - } elsif ($format eq "csv-td_canada_trust-merchant_pc_batch") { - - %>,,,,<%= $cust_pay_batch->payinfo %>,<%= $exp %>,<%= $cust_pay_batch->amount %>,<%= $cust_pay_batch->paybatchnum %><% - - } else { - die "I'm already dead, but you did not know that.\n"; - } - -} - -if ($format eq "BoM") { - - %><%= sprintf( "YD%08u%014.0f%56s\n",$batchcount,$batchtotal*100,"" ). - sprintf( "Z%014u%05u%014u%05u%41s\n",$batchtotal*100,$batchcount,"0","0","" ) %><% - -} elsif ($format eq "PAP"){ - - %><%= sprintf( "T%08u%014.0f%57s\n",$batchcount,$batchtotal*100,"" ) %><% - -} elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){ - #1; -} else { - die "I'm already dead (again), but you did not know that.\n"; -} - -$dbh->commit or die $dbh->errstr if $oldAutoCommit; + %> +% +% +%}elsif ($format eq "PAP"){ +% +% my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) = +% $conf->config("batchconfig-$format"); +% +<% sprintf( "H%10sD%3s%06u%-15s%09u%-12s%04u%19s\n",$origid,$typecode,$cdate,$shortname,$mybank,$myacct,$pay_batch->batchnum,"") + + %> +% +% +%}elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){ +%# 1; +%}else{ +% die "Unknown format for batch in batchconfig. \n"; +%} +% +% +%for my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum } +% qsearch('cust_pay_batch', +% {'batchnum'=>$pay_batch->batchnum} ) +%) { +% +% $cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; +% my( $mon, $y ) = ( $2, $1 ); +% $mon = "0$mon" if $mon < 10; +% my $exp = "$mon$y"; +% $batchcount++; +% $batchtotal += $cust_pay_batch->amount; +% +% if ($format eq "BoM") { +% +% my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); +% +<% sprintf( "D%010.0f%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->paybatchnum) %> +% +% +% } elsif ($format eq "PAP"){ +% +% my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); +% +<% sprintf( "D%-23s%06u%-19s%09u%-12s%010.0f\n",$cust_pay_batch->payname,$cdate,$cust_pay_batch->paybatchnum,$aba,$account,$cust_pay_batch->amount*100) %> +% +% +% } elsif ($format eq "csv-td_canada_trust-merchant_pc_batch") { +% +% +,,,,<% $cust_pay_batch->payinfo %>,<% $exp %>,<% $cust_pay_batch->amount %>,<% $cust_pay_batch->paybatchnum %> +% +% +% } else { +% die "I'm already dead, but you did not know that.\n"; +% } +% +%} +% +%if ($format eq "BoM") { +% +% +<% sprintf( "YD%08u%014.0f%56s\n",$batchcount,$batchtotal*100,"" ). + sprintf( "Z%014u%05u%014u%05u%41s\n",$batchtotal*100,$batchcount,"0","0","" ) %> +% +% +%} elsif ($format eq "PAP"){ +% +% +<% sprintf( "T%08u%014.0f%57s\n",$batchcount,$batchtotal*100,"" ) %> +% +% +%} elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){ +% #1; +%} else { +% die "I'm already dead (again), but you did not know that.\n"; +%} +% +%$dbh->commit or die $dbh->errstr if $oldAutoCommit; +% +% -%> diff --git a/httemplate/misc/dump.cgi b/httemplate/misc/dump.cgi index dc1323bb3..e8f4b6f38 100644 --- a/httemplate/misc/dump.cgi +++ b/httemplate/misc/dump.cgi @@ -1,19 +1,20 @@ -<% - if ( driver_name =~ /^Pg$/ ) { - my $dbname = (split(':', datasrc))[2]; - if ( $dbname =~ /[;=]/ ) { - my %elements = map { /^(\w+)=(.*)$/; $1=>$2 } split(';', $dbname); - $dbname = $elements{'dbname'}; - } - open(DUMP,"pg_dump $dbname |"); - } else { - eidiot "don't (yet) know how to dump ". driver_name. " databases\n"; - } +% +% if ( driver_name =~ /^Pg$/ ) { +% my $dbname = (split(':', datasrc))[2]; +% if ( $dbname =~ /[;=]/ ) { +% my %elements = map { /^(\w+)=(.*)$/; $1=>$2 } split(';', $dbname); +% $dbname = $elements{'dbname'}; +% } +% open(DUMP,"pg_dump $dbname |"); +% } else { +% eidiot "don't (yet) know how to dump ". driver_name. " databases\n"; +% } +% +% http_header('Content-Type' => 'text/plain' ); +% +% while (<DUMP>) { +% print $_; +% } +% close DUMP; +% - http_header('Content-Type' => 'text/plain' ); - - while (<DUMP>) { - print $_; - } - close DUMP; -%> diff --git a/httemplate/misc/email-invoice.cgi b/httemplate/misc/email-invoice.cgi index ad9ba1abb..8a3dd90b1 100755 --- a/httemplate/misc/email-invoice.cgi +++ b/httemplate/misc/email-invoice.cgi @@ -1,17 +1,18 @@ -<% +% +% +%#untaint invnum +%my($query) = $cgi->keywords; +%$query =~ /^((.+)-)?(\d+)$/; +%my $template = $2; +%my $invnum = $3; +%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +%die "Can't find invoice!\n" unless $cust_bill; +% +%$cust_bill->email($template); +% +%my $custnum = $cust_bill->getfield('custnum'); +% +%print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); +% +% -#untaint invnum -my($query) = $cgi->keywords; -$query =~ /^((.+)-)?(\d+)$/; -my $template = $2; -my $invnum = $3; -my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); -die "Can't find invoice!\n" unless $cust_bill; - -$cust_bill->email($template); - -my $custnum = $cust_bill->getfield('custnum'); - -print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); - -%> diff --git a/httemplate/misc/email_invoice_events.cgi b/httemplate/misc/email_invoice_events.cgi index 3a39bcd19..ba6e72c1a 100644 --- a/httemplate/misc/email_invoice_events.cgi +++ b/httemplate/misc/email_invoice_events.cgi @@ -1,3 +1,4 @@ -<% -my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_reemail', $cgi; -%><%= $server->process %> +% +%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_reemail', $cgi; +% +<% $server->process %> diff --git a/httemplate/misc/email_invoices.cgi b/httemplate/misc/email_invoices.cgi index 490c42f52..6c2103f7b 100644 --- a/httemplate/misc/email_invoices.cgi +++ b/httemplate/misc/email_invoices.cgi @@ -1,3 +1,4 @@ -<% -my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_reemail', $cgi; -%><%= $server->process %> +% +%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_reemail', $cgi; +% +<% $server->process %> diff --git a/httemplate/misc/expire_pkg.cgi b/httemplate/misc/expire_pkg.cgi index f8f69dafd..55364c652 100755 --- a/httemplate/misc/expire_pkg.cgi +++ b/httemplate/misc/expire_pkg.cgi @@ -1,22 +1,23 @@ <!-- mason kludge --> -<% - -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $pkgnum = $1; - -#get package record -my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); -die "Unknown pkgnum $pkgnum" unless $cust_pkg; -my $part_pkg = $cust_pkg->part_pkg; - -my $custnum = $cust_pkg->getfield('custnum'); - -my $date = $cust_pkg->expire ? time2str('%D', $cust_pkg->expire) : ''; - -%> - -<%= include("/elements/header.html",'Expire package', menubar( +% +% +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $pkgnum = $1; +% +%#get package record +%my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +%die "Unknown pkgnum $pkgnum" unless $cust_pkg; +%my $part_pkg = $cust_pkg->part_pkg; +% +%my $custnum = $cust_pkg->getfield('custnum'); +% +%my $date = $cust_pkg->expire ? time2str('%D', $cust_pkg->expire) : ''; +% +% + + +<% include("/elements/header.html",'Expire package', menubar( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", 'Main Menu' => popurl(2) )) %> @@ -26,15 +27,15 @@ my $date = $cust_pkg->expire ? time2str('%D', $cust_pkg->expire) : ''; <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT> -<%= $pkgnum %>: <%= $part_pkg->pkg. ' - '. $part_pkg->comment %> +<% $pkgnum %>: <% $part_pkg->pkg. ' - '. $part_pkg->comment %> <FORM NAME="formname" ACTION="process/expire_pkg.cgi" METHOD="post"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>"> <TABLE> <TR> <TD>Cancel package on </TD> - <TD><INPUT TYPE="text" NAME="date" ID="expire_date" VALUE="<%= $date %>"> - <IMG SRC="<%= $p %>images/calendar.png" ID="expire_button" STYLE="cursor:pointer" TITLE="Select date"> + <TD><INPUT TYPE="text" NAME="date" ID="expire_date" VALUE="<% $date %>"> + <IMG SRC="<% $p %>images/calendar.png" ID="expire_button" STYLE="cursor:pointer" TITLE="Select date"> <BR><I>m/d/y</I> </TD> </TR> diff --git a/httemplate/misc/fax-invoice.cgi b/httemplate/misc/fax-invoice.cgi index 94fee2cf2..1ddc23ece 100755 --- a/httemplate/misc/fax-invoice.cgi +++ b/httemplate/misc/fax-invoice.cgi @@ -1,17 +1,18 @@ -<% +% +% +%#untaint invnum +%my($query) = $cgi->keywords; +%$query =~ /^((.+)-)?(\d+)$/; +%my $template = $2; +%my $invnum = $3; +%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +%die "Can't find invoice!\n" unless $cust_bill; +% +%$cust_bill->fax($template); +% +%my $custnum = $cust_bill->getfield('custnum'); +% +%print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); +% +% -#untaint invnum -my($query) = $cgi->keywords; -$query =~ /^((.+)-)?(\d+)$/; -my $template = $2; -my $invnum = $3; -my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); -die "Can't find invoice!\n" unless $cust_bill; - -$cust_bill->fax($template); - -my $custnum = $cust_bill->getfield('custnum'); - -print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); - -%> diff --git a/httemplate/misc/fax_invoice_events.cgi b/httemplate/misc/fax_invoice_events.cgi index 778c4291e..deb78d456 100644 --- a/httemplate/misc/fax_invoice_events.cgi +++ b/httemplate/misc/fax_invoice_events.cgi @@ -1,3 +1,4 @@ -<% -my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_refax', $cgi; -%><%= $server->process %> +% +%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_refax', $cgi; +% +<% $server->process %> diff --git a/httemplate/misc/fax_invoices.cgi b/httemplate/misc/fax_invoices.cgi index b3238885f..4bdac970c 100644 --- a/httemplate/misc/fax_invoices.cgi +++ b/httemplate/misc/fax_invoices.cgi @@ -1,3 +1,4 @@ -<% -my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_refax', $cgi; -%><%= $server->process %> +% +%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_refax', $cgi; +% +<% $server->process %> diff --git a/httemplate/misc/inventory_item-import.html b/httemplate/misc/inventory_item-import.html index a702fbc49..87c6af34c 100644 --- a/httemplate/misc/inventory_item-import.html +++ b/httemplate/misc/inventory_item-import.html @@ -1,20 +1,21 @@ -<% - -my $classnum = $cgi->param('classnum'); -$classnum =~ /^(\d+)$/ or eidiot "illegal classnum $classnum"; -$classnum = $1; -my $inventory_class = qsearchs('inventory_class', { 'classnum' => $classnum } ); - -%><%= include("/elements/header.html", $inventory_class->classname. 's') %> +% +% +%my $classnum = $cgi->param('classnum'); +%$classnum =~ /^(\d+)$/ or eidiot "illegal classnum $classnum"; +%$classnum = $1; +%my $inventory_class = qsearchs('inventory_class', { 'classnum' => $classnum } ); +% +% +<% include("/elements/header.html", $inventory_class->classname. 's') %> <FORM ACTION="process/inventory_item-import.html" METHOD="POST" ENCTYPE="multipart/form-data"> -<INPUT TYPE="hidden" NAME="classnum" VALUE="<%= $classnum %>"> -Import a file containing <%= $inventory_class->classname %>s, one per line.<BR><BR> +<INPUT TYPE="hidden" NAME="classnum" VALUE="<% $classnum %>"> +Import a file containing <% $inventory_class->classname %>s, one per line.<BR><BR> Filename: <INPUT TYPE="file" NAME="filename"><BR><BR> <INPUT TYPE="submit" VALUE="Upload"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/misc/link.cgi b/httemplate/misc/link.cgi index e2bdda7d5..1d1f5e133 100755 --- a/httemplate/misc/link.cgi +++ b/httemplate/misc/link.cgi @@ -1,73 +1,83 @@ <!-- mason kludge --> -<% +% +% +%my %link_field = ( +% 'svc_acct' => 'username', +% 'svc_domain' => 'domain', +%); +% +%my %link_field2 = ( +% 'svc_acct' => { label => 'Domain', +% field => 'domsvc', +% type => 'select', +% select_table => 'svc_domain', +% select_key => 'svcnum', +% select_label => 'domain' +% }, +%); +% +%my($query) = $cgi->keywords; +%my($pkgnum, $svcpart) = ('', ''); +%foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart +% $pkgnum=$1 if /^pkgnum(\d+)$/; +% $svcpart=$1 if /^svcpart(\d+)$/; +%} +% +%my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart}); +%my $svc = $part_svc->getfield('svc'); +%my $svcdb = $part_svc->getfield('svcdb'); +%my $link_field = $link_field{$svcdb}; +%my $link_field2 = $link_field2{$svcdb}; +% +% -my %link_field = ( - 'svc_acct' => 'username', - 'svc_domain' => 'domain', -); -my %link_field2 = ( - 'svc_acct' => { label => 'Domain', - field => 'domsvc', - type => 'select', - select_table => 'svc_domain', - select_key => 'svcnum', - select_label => 'domain' - }, -); +<% include("/elements/header.html","Link to existing $svc") %> +<FORM ACTION="<% popurl(1) %>process/link.cgi" METHOD=POST> +% if ( $link_field ) { -my($query) = $cgi->keywords; -my($pkgnum, $svcpart) = ('', ''); -foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart - $pkgnum=$1 if /^pkgnum(\d+)$/; - $svcpart=$1 if /^svcpart(\d+)$/; -} - -my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart}); -my $svc = $part_svc->getfield('svc'); -my $svcdb = $part_svc->getfield('svcdb'); -my $link_field = $link_field{$svcdb}; -my $link_field2 = $link_field2{$svcdb}; - -%> - -<%= include("/elements/header.html","Link to existing $svc") %> -<FORM ACTION="<%= popurl(1) %>process/link.cgi" METHOD=POST> - -<% if ( $link_field ) { %> <INPUT TYPE="hidden" NAME="svcnum" VALUE=""> - <INPUT TYPE="hidden" NAME="link_field" VALUE="<%= $link_field %>"> - <%= $link_field %> of existing service: <INPUT TYPE="text" NAME="link_value"> + <INPUT TYPE="hidden" NAME="link_field" VALUE="<% $link_field %>"> + <% $link_field %> of existing service: <INPUT TYPE="text" NAME="link_value"> <BR> - <% if ( $link_field2 ) { %> - <INPUT TYPE="hidden" NAME="link_field2" VALUE="<%= $link_field2->{field} %>"> - <%= $link_field2->{'label'} %> of existing service: - <% if ( $link_field2->{'type'} eq 'select' ) { %> - <% if ( $link_field2->{'select_table'} ) { %> +% if ( $link_field2 ) { + + <INPUT TYPE="hidden" NAME="link_field2" VALUE="<% $link_field2->{field} %>"> + <% $link_field2->{'label'} %> of existing service: +% if ( $link_field2->{'type'} eq 'select' ) { +% if ( $link_field2->{'select_table'} ) { + <SELECT NAME="link_value2"> <OPTION> </OPTION> - <% foreach my $r ( qsearch( $link_field2->{'select_table'}, {})) { %> - <% my $key = $link_field2->{'select_key'}; %> - <% my $label = $link_field2->{'select_label'}; %> - <OPTION VALUE="<%= $r->$key() %>"><%= $r->$label() %></OPTION> - <% } %> +% foreach my $r ( qsearch( $link_field2->{'select_table'}, {})) { +% my $key = $link_field2->{'select_key'}; +% my $label = $link_field2->{'select_label'}; + + <OPTION VALUE="<% $r->$key() %>"><% $r->$label() %></OPTION> +% } + </SELECT> - <% } else { %> - Don't know how to process secondary link field for <%= $svcdb %> +% } else { + + Don't know how to process secondary link field for <% $svcdb %> (type=>select but no select_table) - <% } %> - <% } else { %> - Don't know how to process secondary link field for <%= $svcdb %> - (unknown type <%= $link_field2->{'type'} %>) - <% } %> +% } +% } else { + + Don't know how to process secondary link field for <% $svcdb %> + (unknown type <% $link_field2->{'type'} %>) +% } + <BR> - <% } %> -<% } else { %> +% } +% } else { + Service # of existing service: <INPUT TYPE="text" NAME="svcnum" VALUE=""> -<% } %> +% } + -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> -<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>"> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>"> +<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>"> <BR><INPUT TYPE="submit" VALUE="Link"> </FORM> </BODY> diff --git a/httemplate/misc/meta-import.cgi b/httemplate/misc/meta-import.cgi index b2fcfe450..fc249a2ab 100644 --- a/httemplate/misc/meta-import.cgi +++ b/httemplate/misc/meta-import.cgi @@ -1,45 +1,54 @@ <!-- mason kludge --> -<%= include("/elements/header.html",'Import') %> +<% include("/elements/header.html",'Import') %> <FORM ACTION="process/meta-import.cgi" METHOD="post" ENCTYPE="multipart/form-data"> Import data from a DBI data source<BR><BR> +% +% #false laziness with edit/cust_main.cgi +% my @agents = qsearch( 'agent', {} ); +% die "No agents created!" unless @agents; +% my $agentnum = $agents[0]->agentnum; #default to first +% +% if ( scalar(@agents) == 1 ) { +% -<% - #false laziness with edit/cust_main.cgi - my @agents = qsearch( 'agent', {} ); - die "No agents created!" unless @agents; - my $agentnum = $agents[0]->agentnum; #default to first + <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agentnum %>"> +% } else { - if ( scalar(@agents) == 1 ) { -%> - <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agentnum %>"> -<% } else { %> <BR><BR>Agent <SELECT NAME="agentnum" SIZE="1"> - <% foreach my $agent (sort { $a->agent cmp $b->agent } @agents) { %> - <OPTION VALUE="<%= $agent->agentnum %>" <%= " SELECTED"x($agent->agentnum==$agentnum) %>><%= $agent->agent %></OPTION> - <% } %> +% foreach my $agent (sort { $a->agent cmp $b->agent } @agents) { + + <OPTION VALUE="<% $agent->agentnum %>" <% " SELECTED"x($agent->agentnum==$agentnum) %>><% $agent->agent %></OPTION> +% } + </SELECT><BR><BR> -<% } %> +% } +% +% my @referrals = qsearch('part_referral',{}); +% die "No advertising sources created!" unless @referrals; +% my $refnum = $referrals[0]->refnum; #default to first +% +% if ( scalar(@referrals) == 1 ) { +% -<% - my @referrals = qsearch('part_referral',{}); - die "No advertising sources created!" unless @referrals; - my $refnum = $referrals[0]->refnum; #default to first + <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>"> +% } else { - if ( scalar(@referrals) == 1 ) { -%> - <INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $refnum %>"> -<% } else { %> <BR><BR>Advertising source <SELECT NAME="refnum" SIZE="1"> - <% foreach my $referral ( sort { $a->referral <=> $b->referral } @referrals) { %> - <OPTION VALUE="<%= $referral->refnum %>" <%= " SELECTED"x($referral->refnum==$refnum) %>><%= $referral->refnum %>: <%= $referral->referral %></OPTION> - <% } %> +% foreach my $referral ( sort { $a->referral <=> $b->referral } @referrals) { + + <OPTION VALUE="<% $referral->refnum %>" <% " SELECTED"x($referral->refnum==$refnum) %>><% $referral->refnum %>: <% $referral->referral %></OPTION> +% } + </SELECT><BR><BR> -<% } %> +% } + First package: <SELECT NAME="pkgpart"><OPTION VALUE="">(none)</OPTION> -<% foreach my $part_pkg ( qsearch('part_pkg',{'disabled'=>'' }) ) { %> - <OPTION VALUE="<%= $part_pkg->pkgpart %>"><%= $part_pkg->pkg. ' - '. $part_pkg->comment %></OPTION> -<% } %> +% foreach my $part_pkg ( qsearch('part_pkg',{'disabled'=>'' }) ) { + + <OPTION VALUE="<% $part_pkg->pkgpart %>"><% $part_pkg->pkg. ' - '. $part_pkg->comment %></OPTION> +% } + </SELECT><BR><BR> <table> diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index ec50c03f1..4c6ae3349 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -1,40 +1,41 @@ -<% - my %type = ( 'CARD' => 'credit card', - 'CHEK' => 'electronic check (ACH)', - ); +% +% my %type = ( 'CARD' => 'credit card', +% 'CHEK' => 'electronic check (ACH)', +% ); +% +% $cgi->param('payby') =~ /^(CARD|CHEK)$/ +% or die "unknown payby ". $cgi->param('payby'); +% my $payby = $1; +% +% $cgi->param('custnum') =~ /^(\d+)$/ +% or die "illegal custnum ". $cgi->param('custnum'); +% my $custnum = $1; +% +% my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } ); +% die "unknown custnum $custnum" unless $cust_main; +% +% my $balance = $cust_main->balance; +% +% my $payinfo = ''; +% +% #false laziness w/selfservice make_payment.html shortcut for one-country +% my $conf = new FS::Conf; +% my %states = map { $_->state => 1 } +% qsearch('cust_main_county', { +% 'country' => $conf->config('countrydefault') || 'US' +% } ); +% my @states = sort { $a cmp $b } keys %states; +% +% my $paybatch = "webui-payment-". time. "-$$-". rand() * 2**32; +% +% - $cgi->param('payby') =~ /^(CARD|CHEK)$/ - or die "unknown payby ". $cgi->param('payby'); - my $payby = $1; - - $cgi->param('custnum') =~ /^(\d+)$/ - or die "illegal custnum ". $cgi->param('custnum'); - my $custnum = $1; - - my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } ); - die "unknown custnum $custnum" unless $cust_main; - - my $balance = $cust_main->balance; - - my $payinfo = ''; - - #false laziness w/selfservice make_payment.html shortcut for one-country - my $conf = new FS::Conf; - my %states = map { $_->state => 1 } - qsearch('cust_main_county', { - 'country' => $conf->config('countrydefault') || 'US' - } ); - my @states = sort { $a cmp $b } keys %states; - - my $paybatch = "webui-payment-". time. "-$$-". rand() * 2**32; - -%> -<%= include( '/elements/header.html', "Process $type{$payby} payment" ) %> -<%= include( '/elements/small_custview.html', $cust_main ) %> +<% include( '/elements/header.html', "Process $type{$payby} payment" ) %> +<% include( '/elements/small_custview.html', $cust_main ) %> <FORM NAME="OneTrueForm" ACTION="process/payment.cgi" METHOD="POST" onSubmit="document.OneTrueForm.process.disabled=true"> -<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>"> -<INPUT TYPE="hidden" NAME="payby" VALUE="<%= $payby %>"> -<INPUT TYPE="hidden" NAME="paybatch" VALUE="<%= $paybatch %>"> +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> +<INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>"> +<INPUT TYPE="hidden" NAME="paybatch" VALUE="<% $paybatch %>"> <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT> @@ -46,53 +47,58 @@ function OLiframeContent(src, width, height, name) { +'<div>[iframe not supported]</div></iframe>'); } </SCRIPT> +% #include( '/elements/table.html', '#cccccc' ) -<% #include( '/elements/table.html', '#cccccc' ) %> -<%= ntable('#cccccc') %> +<% ntable('#cccccc') %> <TR> <TD ALIGN="right">Payment amount</TD> <TD> <TABLE><TR><TD BGCOLOR="#ffffff"> - $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<%= $balance > 0 ? sprintf("%.2f", $balance) : '' %>"> + $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<% $balance > 0 ? sprintf("%.2f", $balance) : '' %>"> </TD></TR></TABLE> </TD> </TR> -<% if ( $payby eq 'CARD' ) { - my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' ); - my $payname = $cust_main->first. ' '. $cust_main->getfield('last'); - my $address1 = $cust_main->address1; - my $address2 = $cust_main->address2; - my $city = $cust_main->city; - my $state = $cust_main->state; - my $zip = $cust_main->zip; - if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { - $payinfo = $cust_main->payinfo; - $paycvv = $cust_main->paycvv; - ( $month, $year ) = $cust_main->paydate_monthyear; - $payname = $cust_main->payname if $cust_main->payname; - } -%> +% if ( $payby eq 'CARD' ) { +% my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' ); +% my $payname = $cust_main->first. ' '. $cust_main->getfield('last'); +% my $address1 = $cust_main->address1; +% my $address2 = $cust_main->address2; +% my $city = $cust_main->city; +% my $state = $cust_main->state; +% my $zip = $cust_main->zip; +% if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { +% $payinfo = $cust_main->payinfo; +% $paycvv = $cust_main->paycvv; +% ( $month, $year ) = $cust_main->paydate_monthyear; +% $payname = $cust_main->payname if $cust_main->payname; +% } +% + <TR> <TD ALIGN="right">Card number</TD> <TD> <TABLE> <TR> <TD> - <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%=$payinfo%>"> </TD> + <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD> <TD>Exp.</TD> <TD> <SELECT NAME="month"> - <% for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) { %> - <OPTION<%= $_ == $month ? ' SELECTED' : '' %>><%= $_ %> - <% } %> +% for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) { + + <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %> +% } + </SELECT> </TD> <TD> / </TD> <TD> <SELECT NAME="year"> - <% my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) { %> - <OPTION<%= $_ == $year ? ' SELECTED' : '' %>><%= $_ %> - <% } %> +% my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) { + + <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %> +% } + </SELECT> </TD> </TR> @@ -101,22 +107,22 @@ function OLiframeContent(src, width, height, name) { </TR> <TR> <TD ALIGN="right">CVV2</TD> - <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<%= $paycvv %>" SIZE=4 MAXLENGTH=4> + <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4> (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>) </TD> </TR> <TR> <TD ALIGN="right">Exact name on card</TD> - <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%=$payname%>"></TD> + <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD> </TR><TR> <TD ALIGN="right">Card billing address</TD> <TD> - <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address1" VALUE="<%=$address1%>"> + <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address1" VALUE="<%$address1%>"> </TD> </TR><TR> <TD ALIGN="right">Address line 2</TD> <TD> - <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address2" VALUE="<%=$address2%>"> + <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address2" VALUE="<%$address2%>"> </TD> </TR><TR> <TD ALIGN="right">City</TD> @@ -124,61 +130,63 @@ function OLiframeContent(src, width, height, name) { <TABLE> <TR> <TD> - <INPUT TYPE="text" NAME="city" SIZE="12" MAXLENGTH=80 VALUE="<%=$city%>"> + <INPUT TYPE="text" NAME="city" SIZE="12" MAXLENGTH=80 VALUE="<%$city%>"> </TD> <TD>State</TD> <TD> <SELECT NAME="state"> - <% for ( @states ) { %> - <OPTION<%= $_ eq $state ? ' SELECTED' : '' %>><%= $_ %> - <% } %> +% for ( @states ) { + + <OPTION<% $_ eq $state ? ' SELECTED' : '' %>><% $_ %> +% } + </SELECT> </TD> <TD>Zip</TD> <TD> - <INPUT TYPE="text" NAME="zip" SIZE=11 MAXLENGTH=10 VALUE="<%=$zip%>"> + <INPUT TYPE="text" NAME="zip" SIZE=11 MAXLENGTH=10 VALUE="<%$zip%>"> </TD> </TR> </TABLE> </TD> </TR> +% } elsif ( $payby eq 'CHEK' ) { +% my( $payinfo1, $payinfo2, $payname, $ss ) = ( '', '', '', '' ); +% if ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) { +% $cust_main->payinfo =~ /^(\d+)\@(\d+)$/ +% or die "unparsable payinfo ". $cust_main->payinfo; +% ($payinfo1, $payinfo2) = ($1, $2); +% $payname = $cust_main->payname; +% $ss = $cust_main->ss; +% } +% -<% } elsif ( $payby eq 'CHEK' ) { - my( $payinfo1, $payinfo2, $payname, $ss ) = ( '', '', '', '' ); - if ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) { - $cust_main->payinfo =~ /^(\d+)\@(\d+)$/ - or die "unparsable payinfo ". $cust_main->payinfo; - ($payinfo1, $payinfo2) = ($1, $2); - $payname = $cust_main->payname; - $ss = $cust_main->ss; - } -%> <INPUT TYPE="hidden" NAME="month" VALUE="12"> <INPUT TYPE="hidden" NAME="year" VALUE="2037"> <TR> <TD ALIGN="right">Account number</TD> - <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%=$payinfo1%>"></TD> + <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$payinfo1%>"></TD> </TR> <TR> <TD ALIGN="right">ABA/Routing number</TD> <TD> - <INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="<%=$payinfo2%>"> + <INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="<%$payinfo2%>"> (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>) </TD> </TR> <TR> <TD ALIGN="right">Bank name</TD> - <TD><INPUT TYPE="text" NAME="payname" VALUE="<%=$payname%>"></TD> + <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD> </TR> <TR> <TD ALIGN="right"> Account holder<BR> Social security or tax ID # </TD> - <TD><INPUT TYPE="text" NAME="ss" VALUE="<%=$ss%>"></TD> + <TD><INPUT TYPE="text" NAME="ss" VALUE="<%$ss%>"></TD> </TR> +% } -<% } %> <TR> <TD COLSPAN=2> @@ -187,8 +195,8 @@ function OLiframeContent(src, width, height, name) { </TD> </TR><TR> <TD COLSPAN=2> - <INPUT TYPE="checkbox"<%= ( ( $payby eq 'CARD' && $cust_main->payby ne 'DCRD' ) || ( $payby eq 'CHEK' && $cust_main->payby eq 'CHEK' ) ) ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }"> - Charge future payments to this <%= $type{$payby} %> automatically + <INPUT TYPE="checkbox"<% ( ( $payby eq 'CARD' && $cust_main->payby ne 'DCRD' ) || ( $payby eq 'CHEK' && $cust_main->payby eq 'CHEK' ) ) ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }"> + Charge future payments to this <% $type{$payby} %> automatically </TD> </TR> </TABLE> @@ -196,4 +204,4 @@ function OLiframeContent(src, width, height, name) { <INPUT TYPE="submit" NAME="process" VALUE="Process payment"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/misc/print-invoice.cgi b/httemplate/misc/print-invoice.cgi index 6a4c2d7f1..511bdce19 100755 --- a/httemplate/misc/print-invoice.cgi +++ b/httemplate/misc/print-invoice.cgi @@ -1,17 +1,18 @@ -<% +% +% +%#untaint invnum +%my($query) = $cgi->keywords; +%$query =~ /^((.+)-)?(\d+)$/; +%my $template = $2; +%my $invnum = $3; +%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +%die "Can't find invoice!\n" unless $cust_bill; +% +%$cust_bill->print($template); +% +%my $custnum = $cust_bill->getfield('custnum'); +% +%print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); +% +% -#untaint invnum -my($query) = $cgi->keywords; -$query =~ /^((.+)-)?(\d+)$/; -my $template = $2; -my $invnum = $3; -my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); -die "Can't find invoice!\n" unless $cust_bill; - -$cust_bill->print($template); - -my $custnum = $cust_bill->getfield('custnum'); - -print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); - -%> diff --git a/httemplate/misc/print_invoice_events.cgi b/httemplate/misc/print_invoice_events.cgi index 897c39ede..913e2683f 100644 --- a/httemplate/misc/print_invoice_events.cgi +++ b/httemplate/misc/print_invoice_events.cgi @@ -1,3 +1,4 @@ -<% -my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_reprint', $cgi; %> -<%= $server->process %> +% +%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_reprint', $cgi; + +<% $server->process %> diff --git a/httemplate/misc/print_invoices.cgi b/httemplate/misc/print_invoices.cgi index 218262077..826a081fd 100644 --- a/httemplate/misc/print_invoices.cgi +++ b/httemplate/misc/print_invoices.cgi @@ -1,3 +1,4 @@ -<% -my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_reprint', $cgi; -%><%= $server->process %> +% +%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_reprint', $cgi; +% +<% $server->process %> diff --git a/httemplate/misc/process/batch-cust_pay.cgi b/httemplate/misc/process/batch-cust_pay.cgi index 12d72e8a0..e4d1bbff5 100644 --- a/httemplate/misc/process/batch-cust_pay.cgi +++ b/httemplate/misc/process/batch-cust_pay.cgi @@ -1,42 +1,45 @@ -<% - my $param = $cgi->Vars; +% +% my $param = $cgi->Vars; +% +% #my $paybatch = $param->{'paybatch'}; +% my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); +% +% my @cust_pay = (); +% #my $row = 0; +% #while ( exists($param->{"custnum$row"}) ) { +% for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) { +% push @cust_pay, new FS::cust_pay { +% 'custnum' => $param->{"custnum$row"}, +% 'paid' => $param->{"paid$row"}, +% 'payby' => 'BILL', +% 'payinfo' => $param->{"payinfo$row"}, +% 'paybatch' => $paybatch, +% } +% if $param->{"custnum$row"} +% || $param->{"paid$row"} +% || $param->{"payinfo$row"}; +% #$row++; +% } +% +% my @errors = FS::cust_pay->batch_insert(@cust_pay); +% my $num_errors = scalar(grep $_, @errors); +% +% if ( $num_errors ) { +% +% $cgi->param('error', "$num_errors error". ($num_errors>1 ? 's' : ''). +% ' - Batch not processed, correct and resubmit' +% ); +% +% my $erow=0; +% $cgi->param('error'. $erow++, shift @errors) while @errors; +% +% +<% $cgi->redirect($p.'batch-cust_pay.html?'. $cgi->query_string) + + %> +% } else { +% +% +<% $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %> +% } - #my $paybatch = $param->{'paybatch'}; - my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); - - my @cust_pay = (); - #my $row = 0; - #while ( exists($param->{"custnum$row"}) ) { - for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) { - push @cust_pay, new FS::cust_pay { - 'custnum' => $param->{"custnum$row"}, - 'paid' => $param->{"paid$row"}, - 'payby' => 'BILL', - 'payinfo' => $param->{"payinfo$row"}, - 'paybatch' => $paybatch, - } - if $param->{"custnum$row"} - || $param->{"paid$row"} - || $param->{"payinfo$row"}; - #$row++; - } - - my @errors = FS::cust_pay->batch_insert(@cust_pay); - my $num_errors = scalar(grep $_, @errors); - - if ( $num_errors ) { - - $cgi->param('error', "$num_errors error". ($num_errors>1 ? 's' : ''). - ' - Batch not processed, correct and resubmit' - ); - - my $erow=0; - $cgi->param('error'. $erow++, shift @errors) while @errors; - - %><%= $cgi->redirect($p.'batch-cust_pay.html?'. $cgi->query_string) - - %><% } else { - - %><%= $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %> - - <% } %> diff --git a/httemplate/misc/process/catchall.cgi b/httemplate/misc/process/catchall.cgi index 44a63f9f8..f2899c720 100755 --- a/httemplate/misc/process/catchall.cgi +++ b/httemplate/misc/process/catchall.cgi @@ -1,33 +1,34 @@ -<% +% +% +%$FS::svc_domain::whois_hack=1; +% +%$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +%my $svcnum =$1; +% +%my $old = qsearchs('svc_domain',{'svcnum'=>$svcnum}) if $svcnum; +% +%my $new = new FS::svc_domain ( { +% map { +% ($_, scalar($cgi->param($_))); +% } ( fields('svc_domain'), qw( pkgnum svcpart ) ) +%} ); +% +%$new->setfield('action' => 'M'); +% +%my $error; +%if ( $svcnum ) { +% $error = $new->replace($old); +%} else { +% $error = $new->insert; +% $svcnum = $new->getfield('svcnum'); +%} +% +%if ($error) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "catchall.cgi?". $cgi->query_string ); +%} else { +% print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum"); +%} +% +% -$FS::svc_domain::whois_hack=1; - -$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; -my $svcnum =$1; - -my $old = qsearchs('svc_domain',{'svcnum'=>$svcnum}) if $svcnum; - -my $new = new FS::svc_domain ( { - map { - ($_, scalar($cgi->param($_))); - } ( fields('svc_domain'), qw( pkgnum svcpart ) ) -} ); - -$new->setfield('action' => 'M'); - -my $error; -if ( $svcnum ) { - $error = $new->replace($old); -} else { - $error = $new->insert; - $svcnum = $new->getfield('svcnum'); -} - -if ($error) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "catchall.cgi?". $cgi->query_string ); -} else { - print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum"); -} - -%> diff --git a/httemplate/misc/process/cdr-import.html b/httemplate/misc/process/cdr-import.html index 653dd479e..68edaa21c 100644 --- a/httemplate/misc/process/cdr-import.html +++ b/httemplate/misc/process/cdr-import.html @@ -1,26 +1,30 @@ -<% +% +% +% my $fh = $cgi->upload('csvfile'); +% +% my $error = defined($fh) +% ? FS::cdr::batch_import( { +% 'filehandle' => $fh, +% 'format' => $cgi->param('format'), +% } ) +% : 'No file'; +% +% if ( $error ) { +% - my $fh = $cgi->upload('csvfile'); - - my $error = defined($fh) - ? FS::cdr::batch_import( { - 'filehandle' => $fh, - 'format' => $cgi->param('format'), - } ) - : 'No file'; - - if ( $error ) { - %> <!-- mason kludge --> - <% - eidiot($error); -# $cgi->param('error', $error); -# print $cgi->redirect( "${p}cust_main-import.cgi - } else { - %> +% +% eidiot($error); +%# $cgi->param('error', $error); +%# print $cgi->redirect( "${p}cust_main-import.cgi +% } else { +% + <!-- mason kludge --> - <%= include("/elements/header.html",'Import successful') %> + <% include("/elements/header.html",'Import successful') %> <!-- XXX redirect to batch search like the payment entry... --> - <%= include("/elements/footer.html",'Import successful') %> <% - } -%> + <% include("/elements/footer.html",'Import successful') %> +% +% } +% + diff --git a/httemplate/misc/process/cust_main-import.cgi b/httemplate/misc/process/cust_main-import.cgi index aff6b39ef..a5ede99a1 100644 --- a/httemplate/misc/process/cust_main-import.cgi +++ b/httemplate/misc/process/cust_main-import.cgi @@ -1,31 +1,35 @@ -<% +% +% +% my $fh = $cgi->upload('csvfile'); +% #warn $cgi; +% #warn $fh; +% +% my $error = defined($fh) +% ? FS::cust_main::batch_import( { +% filehandle => $fh, +% agentnum => scalar($cgi->param('agentnum')), +% refnum => scalar($cgi->param('refnum')), +% pkgpart => scalar($cgi->param('pkgpart')), +% #'fields' => [qw( cust_pkg.setup dayphone first last address1 address2 +% # city state zip comments )], +% 'format' => scalar($cgi->param('format')), +% } ) +% : 'No file'; +% +% if ( $error ) { +% - my $fh = $cgi->upload('csvfile'); - #warn $cgi; - #warn $fh; - - my $error = defined($fh) - ? FS::cust_main::batch_import( { - filehandle => $fh, - agentnum => scalar($cgi->param('agentnum')), - refnum => scalar($cgi->param('refnum')), - pkgpart => scalar($cgi->param('pkgpart')), - #'fields' => [qw( cust_pkg.setup dayphone first last address1 address2 - # city state zip comments )], - 'format' => scalar($cgi->param('format')), - } ) - : 'No file'; - - if ( $error ) { - %> <!-- mason kludge --> - <% - eidiot($error); -# $cgi->param('error', $error); -# print $cgi->redirect( "${p}cust_main-import.cgi - } else { - %> +% +% eidiot($error); +%# $cgi->param('error', $error); +%# print $cgi->redirect( "${p}cust_main-import.cgi +% } else { +% + <!-- mason kludge --> - <%= include("/elements/header.html",'Import successful') %> <% - } -%> + <% include("/elements/header.html",'Import successful') %> +% +% } +% + diff --git a/httemplate/misc/process/cust_main-import_charges.cgi b/httemplate/misc/process/cust_main-import_charges.cgi index 404dfde2e..e0ede576b 100644 --- a/httemplate/misc/process/cust_main-import_charges.cgi +++ b/httemplate/misc/process/cust_main-import_charges.cgi @@ -1,26 +1,30 @@ -<% +% +% +% my $fh = $cgi->upload('csvfile'); +% #warn $cgi; +% #warn $fh; +% +% my $error = defined($fh) +% ? FS::cust_main::batch_charge( { +% filehandle => $fh, +% 'fields' => [qw( custnum amount pkg )], +% } ) +% : 'No file'; +% +% if ( $error ) { +% - my $fh = $cgi->upload('csvfile'); - #warn $cgi; - #warn $fh; - - my $error = defined($fh) - ? FS::cust_main::batch_charge( { - filehandle => $fh, - 'fields' => [qw( custnum amount pkg )], - } ) - : 'No file'; - - if ( $error ) { - %> <!-- mason kludge --> - <% - eidiot($error); -# $cgi->param('error', $error); -# print $cgi->redirect( "${p}cust_main-import_charges.cgi - } else { - %> +% +% eidiot($error); +%# $cgi->param('error', $error); +%# print $cgi->redirect( "${p}cust_main-import_charges.cgi +% } else { +% + <!-- mason kludge --> - <%= include("/elements/header.html",'Import successful') %> <% - } -%> + <% include("/elements/header.html",'Import successful') %> +% +% } +% + diff --git a/httemplate/misc/process/delete-customer.cgi b/httemplate/misc/process/delete-customer.cgi index 16bdbaea8..d0d237ee8 100755 --- a/httemplate/misc/process/delete-customer.cgi +++ b/httemplate/misc/process/delete-customer.cgi @@ -1,29 +1,30 @@ -<% +% +% +%my $conf = new FS::Conf; +%die "Customer deletions not enabled" unless $conf->exists('deletecustomers'); +% +%$cgi->param('custnum') =~ /^(\d+)$/; +%my $custnum = $1; +%my $new_custnum; +%if ( $cgi->param('new_custnum') ) { +% $cgi->param('new_custnum') =~ /^(\d+)$/ +% or die "Illegal new customer number: ". $cgi->param('new_custnum'); +% $new_custnum = $1; +%} else { +% $new_custnum = ''; +%} +%my $cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } ) +% or die "Customer not found: $custnum"; +% +%my $error = $cust_main->delete($new_custnum); +% +%if ( $error ) { +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). "delete-customer.cgi?". $cgi->query_string ); +%} elsif ( $new_custnum ) { +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$new_custnum"); +%} else { +% print $cgi->redirect(popurl(3)); +%} +% -my $conf = new FS::Conf; -die "Customer deletions not enabled" unless $conf->exists('deletecustomers'); - -$cgi->param('custnum') =~ /^(\d+)$/; -my $custnum = $1; -my $new_custnum; -if ( $cgi->param('new_custnum') ) { - $cgi->param('new_custnum') =~ /^(\d+)$/ - or die "Illegal new customer number: ". $cgi->param('new_custnum'); - $new_custnum = $1; -} else { - $new_custnum = ''; -} -my $cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } ) - or die "Customer not found: $custnum"; - -my $error = $cust_main->delete($new_custnum); - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect(popurl(2). "delete-customer.cgi?". $cgi->query_string ); -} elsif ( $new_custnum ) { - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$new_custnum"); -} else { - print $cgi->redirect(popurl(3)); -} -%> diff --git a/httemplate/misc/process/expire_pkg.cgi b/httemplate/misc/process/expire_pkg.cgi index dc35592ce..d1963e2f5 100755 --- a/httemplate/misc/process/expire_pkg.cgi +++ b/httemplate/misc/process/expire_pkg.cgi @@ -1,25 +1,26 @@ -<% +% +% +%#untaint date & pkgnum +% +%my $date; +%if ( $cgi->param('date') ) { +% str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date"; +% $date=$1; +%} else { +% $date=''; +%} +% +%$cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum"; +%my $pkgnum = $1; +% +%my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +%my %hash = $cust_pkg->hash; +%$hash{expire}=$date; +%my $new = new FS::cust_pkg ( \%hash ); +%my $error = $new->replace($cust_pkg); +%&eidiot($error) if $error; +% +%print $cgi->redirect(popurl(3). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); +% +% -#untaint date & pkgnum - -my $date; -if ( $cgi->param('date') ) { - str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date"; - $date=$1; -} else { - $date=''; -} - -$cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum"; -my $pkgnum = $1; - -my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); -my %hash = $cust_pkg->hash; -$hash{expire}=$date; -my $new = new FS::cust_pkg ( \%hash ); -my $error = $new->replace($cust_pkg); -&eidiot($error) if $error; - -print $cgi->redirect(popurl(3). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); - -%> diff --git a/httemplate/misc/process/inventory_item-import.html b/httemplate/misc/process/inventory_item-import.html index e98a6ed2a..f6159dc99 100644 --- a/httemplate/misc/process/inventory_item-import.html +++ b/httemplate/misc/process/inventory_item-import.html @@ -1,27 +1,31 @@ -<% +% +% +% my $fh = $cgi->upload('filename'); +% +% my $error = defined($fh) +% ? FS::inventory_item::batch_import( { +% 'filehandle' => $fh, +% 'classnum' => $cgi->param('classnum'), +% } ) +% : 'No file'; +% +% if ( $error ) { +% - my $fh = $cgi->upload('filename'); - - my $error = defined($fh) - ? FS::inventory_item::batch_import( { - 'filehandle' => $fh, - 'classnum' => $cgi->param('classnum'), - } ) - : 'No file'; - - if ( $error ) { - %> <!-- mason kludge --> - <% - eidiot($error); -# $cgi->param('error', $error); -# print $cgi->redirect( "${p}cust_main-import.cgi - } else { - %> +% +% eidiot($error); +%# $cgi->param('error', $error); +%# print $cgi->redirect( "${p}cust_main-import.cgi +% } else { +% + <!-- mason kludge --> - <%= include("/elements/header.html",'Import successful') %> + <% include("/elements/header.html",'Import successful') %> <!-- XXX redirect to batch search like the payment entry... --> - <%= include("/elements/footer.html",'Import successful') %> <% - } -%> + <% include("/elements/footer.html",'Import successful') %> +% +% } +% + diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index c3d79e22c..fd3d8bb13 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -1,76 +1,78 @@ -<% +% +% +%my $DEBUG = 0; +% +%$cgi->param('pkgnum') =~ /^(\d+)$/; +%my $pkgnum = $1; +%$cgi->param('svcpart') =~ /^(\d+)$/; +%my $svcpart = $1; +%$cgi->param('svcnum') =~ /^(\d*)$/; +%my $svcnum = $1; +% +%unless ( $svcnum ) { +% my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart}); +% my $svcdb = $part_svc->getfield('svcdb'); +% $cgi->param('link_field') =~ /^(\w+)$/; +% my $link_field = $1; +% my %search = ( $link_field => $cgi->param('link_value') ); +% if ( $cgi->param('link_field2') =~ /^(\w+)$/ ) { +% $search{$1} = $cgi->param('link_value2'); +% } +% +% my @svc_x = ( sort { ($a->cust_svc->pkgnum > 0) <=> ($b->cust_svc->pkgnum > 0) +% or ($b->cust_svc->svcpart == $svcpart) +% <=> ($a->cust_svc->svcpart == $svcpart) +% } +% qsearch( $svcdb, \%search ) +% ); +% +% if ( $DEBUG ) { +% warn scalar(@svc_x). " candidate accounts found for linking ". +% "(svcpart $svcpart):\n"; +% foreach my $svc_x ( @svc_x ) { +% warn " ". $svc_x->email. +% " (svcnum ". $svc_x->svcnum. ",". +% " pkgnum ". $svc_x->cust_svc->pkgnum. ",". +% " svcpart ". $svc_x->cust_svc->svcpart. ")\n"; +% } +% } +% +% my $svc_x = $svc_x[0]; +% +% eidiot("$link_field not found!") unless $svc_x; +% +% $svcnum = $svc_x->svcnum; +% +%} +% +%my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +%die "svcnum not found!" unless $old; +%my $conf = new FS::Conf; +%my($error, $new); +%if ( $old->pkgnum && ! $conf->exists('legacy_link-steal') ) { +% $error = "svcnum $svcnum already linked to package ". $old->pkgnum; +%} else { +% $new = new FS::cust_svc ({ +% 'svcnum' => $svcnum, +% 'pkgnum' => $pkgnum, +% 'svcpart' => $svcpart, +% }); +% +% $error = $new->replace($old); +%} +% +%unless ($error) { +% #no errors, so let's view this customer. +% my $custnum = $new->cust_pkg->custnum; +% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". +% "#cust_pkg$pkgnum" ); +%} else { +% -my $DEBUG = 0; - -$cgi->param('pkgnum') =~ /^(\d+)$/; -my $pkgnum = $1; -$cgi->param('svcpart') =~ /^(\d+)$/; -my $svcpart = $1; -$cgi->param('svcnum') =~ /^(\d*)$/; -my $svcnum = $1; - -unless ( $svcnum ) { - my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart}); - my $svcdb = $part_svc->getfield('svcdb'); - $cgi->param('link_field') =~ /^(\w+)$/; - my $link_field = $1; - my %search = ( $link_field => $cgi->param('link_value') ); - if ( $cgi->param('link_field2') =~ /^(\w+)$/ ) { - $search{$1} = $cgi->param('link_value2'); - } - - my @svc_x = ( sort { ($a->cust_svc->pkgnum > 0) <=> ($b->cust_svc->pkgnum > 0) - or ($b->cust_svc->svcpart == $svcpart) - <=> ($a->cust_svc->svcpart == $svcpart) - } - qsearch( $svcdb, \%search ) - ); - - if ( $DEBUG ) { - warn scalar(@svc_x). " candidate accounts found for linking ". - "(svcpart $svcpart):\n"; - foreach my $svc_x ( @svc_x ) { - warn " ". $svc_x->email. - " (svcnum ". $svc_x->svcnum. ",". - " pkgnum ". $svc_x->cust_svc->pkgnum. ",". - " svcpart ". $svc_x->cust_svc->svcpart. ")\n"; - } - } - - my $svc_x = $svc_x[0]; - - eidiot("$link_field not found!") unless $svc_x; - - $svcnum = $svc_x->svcnum; - -} - -my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -die "svcnum not found!" unless $old; -my $conf = new FS::Conf; -my($error, $new); -if ( $old->pkgnum && ! $conf->exists('legacy_link-steal') ) { - $error = "svcnum $svcnum already linked to package ". $old->pkgnum; -} else { - $new = new FS::cust_svc ({ - 'svcnum' => $svcnum, - 'pkgnum' => $pkgnum, - 'svcpart' => $svcpart, - }); - - $error = $new->replace($old); -} - -unless ($error) { - #no errors, so let's view this customer. - my $custnum = $new->cust_pkg->custnum; - print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". - "#cust_pkg$pkgnum" ); -} else { -%> <!-- mason kludge --> -<% - idiot($error); -} +% +% idiot($error); +%} +% +% -%> diff --git a/httemplate/misc/process/meta-import.cgi b/httemplate/misc/process/meta-import.cgi index 4cdecafc4..5a97d1160 100644 --- a/httemplate/misc/process/meta-import.cgi +++ b/httemplate/misc/process/meta-import.cgi @@ -1,5 +1,5 @@ <!-- mason kludge --> -<%= include("/elements/header.html",'Map tables') %> +<% include("/elements/header.html",'Map tables') %> <SCRIPT> var gSafeOnload = new Array(); @@ -22,157 +22,164 @@ function SafeOnsubmit() { </SCRIPT> <FORM NAME="OneTrueForm" METHOD="POST" ACTION="meta-import.cgi"> +% +% #use DBIx::DBSchema; +% my $schema = new_native DBIx::DBSchema +% map { $cgi->param($_) } qw( data_source username password ); +% foreach my $field (qw( data_source username password )) { + + <INPUT TYPE="hidden" NAME=<% $field %> VALUE="<% $cgi->param($field) %>"> +% } +% +% my %schema; +% use Tie::DxHash; +% tie %schema, 'Tie::DxHash'; +% if ( $cgi->param('schema') ) { +% my $schema_string = $cgi->param('schema'); +% + <INPUT TYPE="hidden" NAME="schema" VALUE="<%$schema_string%>"> +% +% %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/ +% or die "guru meditation #420: $_"; +% ( $1 => $2 ); +% } +% split( /\n/, $schema_string ); +% } +% +% #first page +% unless ( $cgi->param('magic') ) { -<% - #use DBIx::DBSchema; - my $schema = new_native DBIx::DBSchema - map { $cgi->param($_) } qw( data_source username password ); - foreach my $field (qw( data_source username password )) { %> - <INPUT TYPE="hidden" NAME=<%= $field %> VALUE="<%= $cgi->param($field) %>"> - <% } - - my %schema; - use Tie::DxHash; - tie %schema, 'Tie::DxHash'; - if ( $cgi->param('schema') ) { - my $schema_string = $cgi->param('schema'); - %> <INPUT TYPE="hidden" NAME="schema" VALUE="<%=$schema_string%>"> <% - %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/ - or die "guru meditation #420: $_"; - ( $1 => $2 ); - } - split( /\n/, $schema_string ); - } - - #first page - unless ( $cgi->param('magic') ) { %> <INPUT TYPE="hidden" NAME="magic" VALUE="process"> - <%= hashmaker('schema', [ $schema->tables ], + <% hashmaker('schema', [ $schema->tables ], [ grep !/^h_/, dbdef->tables ], ) %> <br><INPUT TYPE="submit" VALUE="done"> - <% +% +% +% #second page +% } elsif ( $cgi->param('magic') eq 'process' ) { - #second page - } elsif ( $cgi->param('magic') eq 'process' ) { %> <INPUT TYPE="hidden" NAME="magic" VALUE="process2"> - <% - - my %unique; - foreach my $table ( keys %schema ) { - - my @from_columns = $schema->table($table)->columns; - my @fs_columns = dbdef->table($schema{$table})->columns; - - %> - <%= hashmaker( $table.'__'.$unique{$table}++, +% +% +% my %unique; +% foreach my $table ( keys %schema ) { +% +% my @from_columns = $schema->table($table)->columns; +% my @fs_columns = dbdef->table($schema{$table})->columns; +% +% + + <% hashmaker( $table.'__'.$unique{$table}++, \@from_columns => \@fs_columns, $table => $schema{$table}, ) %> <br><hr><br> - <% - - } +% +% +% } +% +% - %> <br><INPUT TYPE="submit" VALUE="done"> - <% +% +% +% #third (results) +% } elsif ( $cgi->param('magic') eq 'process2' ) { +% +% print "<pre>\n"; +% +% my %unique; +% foreach my $table ( keys %schema ) { +% ( my $spaces = $table ) =~ s/./ /g; +% print "'$table' => { 'table' => '$schema{$table}',\n". +% #(length($table) x ' '). " 'map' => {\n"; +% "$spaces 'map' => {\n"; +% my %map = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/ +% or die "guru meditation #420: $_"; +% ( $1 => $2 ); +% } +% split( /\n/, $cgi->param($table.'__'.$unique{$table}++) ); +% foreach ( keys %map ) { +% print "$spaces '$_' => '$map{$_}',\n"; +% } +% print "$spaces },\n"; +% print "$spaces },\n"; +% +% } +% print "\n</pre>"; +% +% } else { +% warn "unrecognized magic: ". $cgi->param('magic'); +% } +% +% - #third (results) - } elsif ( $cgi->param('magic') eq 'process2' ) { - - print "<pre>\n"; - - my %unique; - foreach my $table ( keys %schema ) { - ( my $spaces = $table ) =~ s/./ /g; - print "'$table' => { 'table' => '$schema{$table}',\n". - #(length($table) x ' '). " 'map' => {\n"; - "$spaces 'map' => {\n"; - my %map = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/ - or die "guru meditation #420: $_"; - ( $1 => $2 ); - } - split( /\n/, $cgi->param($table.'__'.$unique{$table}++) ); - foreach ( keys %map ) { - print "$spaces '$_' => '$map{$_}',\n"; - } - print "$spaces },\n"; - print "$spaces },\n"; - - } - print "\n</pre>"; - - } else { - warn "unrecognized magic: ". $cgi->param('magic'); - } - - %> </FORM> </BODY> </HTML> +% +% #hashmaker widget +% sub hashmaker { +% my($name, $from, $to, $labelfrom, $labelto) = @_; +% my $fromsize = scalar(@$from); +% my $tosize = scalar(@$to); +% "<TABLE><TR><TH>$labelfrom</TH><TH>$labelto</TH></TR><TR><TD>". +% qq!<SELECT NAME="${name}_from" SIZE=$fromsize>\n!. +% join("\n", map { qq!<OPTION VALUE="$_">$_</OPTION>! } sort { $a cmp $b } @$from ). +% "</SELECT>\n<BR>". +% qq!<INPUT TYPE="button" VALUE="refill" onClick="repack_${name}_from()">!. +% '</TD><TD>'. +% qq!<SELECT NAME="${name}_to" SIZE=$tosize>\n!. +% join("\n", map { qq!<OPTION VALUE="$_">$_</OPTION>! } sort { $a cmp $b } @$to ). +% "</SELECT>\n<BR>". +% qq!<INPUT TYPE="button" VALUE="refill" onClick="repack_${name}_to()">!. +% '</TD></TR>'. +% '<TR><TD COLSPAN=2>'. +% qq!<INPUT TYPE="button" VALUE="map" onClick="toke_$name(this.form)">!. +% '</TD></TR><TR><TD COLSPAN=2>'. +% qq!<TEXTAREA NAME="$name" COLS=80 ROWS=8></TEXTAREA>!. +% '</TD></TR></TABLE>'. +% "<script> +% function toke_$name() { +% fromObject = document.OneTrueForm.${name}_from; +% for (var i=fromObject.options.length-1;i>-1;i--) { +% if (fromObject.options[i].selected) +% fromname = deleteOption_$name(fromObject,i); +% } +% toObject = document.OneTrueForm.${name}_to; +% for (var i=toObject.options.length-1;i>-1;i--) { +% if (toObject.options[i].selected) +% toname = deleteOption_$name(toObject,i); +% } +% document.OneTrueForm.$name.value = document.OneTrueForm.$name.value + fromname + ' => ' + toname + '\\n'; +% } +% function deleteOption_$name(object,index) { +% value = object.options[index].value; +% object.options[index] = null; +% return value; +% } +% function repack_${name}_from() { +% var object = document.OneTrueForm.${name}_from; +% object.options.length = 0; +% ". join("\n", +% map { "addOption_$name(object, '$_');\n" } +% ( sort { $a cmp $b } @$from ) ). " +% } +% function repack_${name}_to() { +% var object = document.OneTrueForm.${name}_to; +% object.options.length = 0; +% ". join("\n", +% map { "addOption_$name(object, '$_');\n" } +% ( sort { $a cmp $b } @$to ) ). " +% } +% function addOption_$name(object,value) { +% var length = object.length; +% object.options[length] = new Option(value, value, false, false); +% } +% </script>". +% ''; +% } +% +% - <% - #hashmaker widget - sub hashmaker { - my($name, $from, $to, $labelfrom, $labelto) = @_; - my $fromsize = scalar(@$from); - my $tosize = scalar(@$to); - "<TABLE><TR><TH>$labelfrom</TH><TH>$labelto</TH></TR><TR><TD>". - qq!<SELECT NAME="${name}_from" SIZE=$fromsize>\n!. - join("\n", map { qq!<OPTION VALUE="$_">$_</OPTION>! } sort { $a cmp $b } @$from ). - "</SELECT>\n<BR>". - qq!<INPUT TYPE="button" VALUE="refill" onClick="repack_${name}_from()">!. - '</TD><TD>'. - qq!<SELECT NAME="${name}_to" SIZE=$tosize>\n!. - join("\n", map { qq!<OPTION VALUE="$_">$_</OPTION>! } sort { $a cmp $b } @$to ). - "</SELECT>\n<BR>". - qq!<INPUT TYPE="button" VALUE="refill" onClick="repack_${name}_to()">!. - '</TD></TR>'. - '<TR><TD COLSPAN=2>'. - qq!<INPUT TYPE="button" VALUE="map" onClick="toke_$name(this.form)">!. - '</TD></TR><TR><TD COLSPAN=2>'. - qq!<TEXTAREA NAME="$name" COLS=80 ROWS=8></TEXTAREA>!. - '</TD></TR></TABLE>'. - "<script> - function toke_$name() { - fromObject = document.OneTrueForm.${name}_from; - for (var i=fromObject.options.length-1;i>-1;i--) { - if (fromObject.options[i].selected) - fromname = deleteOption_$name(fromObject,i); - } - toObject = document.OneTrueForm.${name}_to; - for (var i=toObject.options.length-1;i>-1;i--) { - if (toObject.options[i].selected) - toname = deleteOption_$name(toObject,i); - } - document.OneTrueForm.$name.value = document.OneTrueForm.$name.value + fromname + ' => ' + toname + '\\n'; - } - function deleteOption_$name(object,index) { - value = object.options[index].value; - object.options[index] = null; - return value; - } - function repack_${name}_from() { - var object = document.OneTrueForm.${name}_from; - object.options.length = 0; - ". join("\n", - map { "addOption_$name(object, '$_');\n" } - ( sort { $a cmp $b } @$from ) ). " - } - function repack_${name}_to() { - var object = document.OneTrueForm.${name}_to; - object.options.length = 0; - ". join("\n", - map { "addOption_$name(object, '$_');\n" } - ( sort { $a cmp $b } @$to ) ). " - } - function addOption_$name(object,value) { - var length = object.length; - object.options[length] = new Option(value, value, false, false); - } - </script>". - ''; - } - -%> diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index d21c57c40..188d1dd04 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -1,140 +1,141 @@ -<% - -#some false laziness w/MyAccount::process_payment - -$cgi->param('custnum') =~ /^(\d+)$/ - or die "illegal custnum ". $cgi->param('custnum'); -my $custnum = $1; - -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); -die "unknown custnum $custnum" unless $cust_main; - -$cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/ - or eidiot "illegal amount ". $cgi->param('amount'); -my $amount = $1; -eidiot "amount <= 0" unless $amount > 0; - -$cgi->param('year') =~ /^(\d+)$/ - or die "illegal year ". $cgi->param('year'); -my $year = $1; - -$cgi->param('month') =~ /^(\d+)$/ - or die "illegal month ". $cgi->param('month'); -my $month = $1; - -$cgi->param('payby') =~ /^(CARD|CHEK)$/ - or die "illegal payby ". $cgi->param('payby'); -my $payby = $1; -my %payby2bop = ( - 'CARD' => 'CC', - 'CHEK' => 'ECHECK', -); -my %payby2fields = ( - 'CARD' => [ qw( address1 address2 city state zip ) ], - 'CHEK' => [ qw( ss ) ], -); -my %type = ( 'CARD' => 'credit card', - 'CHEK' => 'electronic check (ACH)', - ); - -$cgi->param('payname') =~ /^([\w \,\.\-\']+)$/ - or eidiot gettext('illegal_name'). " payname: ". $cgi->param('payname'); -my $payname = $1; - -$cgi->param('paybatch') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/ - or eidiot gettext('illegal_text'). " paybatch: ". $cgi->param('paybatch'); -my $paybatch = $1; - -my $payinfo; -my $paycvv = ''; -if ( $payby eq 'CHEK' ) { - - $cgi->param('payinfo1') =~ /^(\d+)$/ - or eidiot "illegal account number ". $cgi->param('payinfo1'); - my $payinfo1 = $1; - $cgi->param('payinfo2') =~ /^(\d+)$/ - or eidiot "illegal ABA/routing number ". $cgi->param('payinfo2'); - my $payinfo2 = $1; - $payinfo = $payinfo1. '@'. $payinfo2; - -} elsif ( $payby eq 'CARD' ) { - - $payinfo = $cgi->param('payinfo'); - $payinfo =~ s/\D//g; - $payinfo =~ /^(\d{13,16})$/ - or eidiot gettext('invalid_card'); # . ": ". $self->payinfo; - $payinfo = $1; - validate($payinfo) - or eidiot gettext('invalid_card'); # . ": ". $self->payinfo; - eidiot gettext('unknown_card_type') - if cardtype($payinfo) eq "Unknown"; - - if ( defined $cust_main->dbdef_table->column('paycvv') ) { - if ( length($cgi->param('paycvv') ) ) { - if ( cardtype($payinfo) eq 'American Express card' ) { - $cgi->param('paycvv') =~ /^(\d{4})$/ - or eidiot "CVV2 (CID) for American Express cards is four digits."; - $paycvv = $1; - } else { - $cgi->param('paycvv') =~ /^(\d{3})$/ - or eidiot "CVV2 (CVC2/CID) is three digits."; - $paycvv = $1; - } - } - } - -} else { - die "unknown payby $payby"; -} - -my $error = $cust_main->realtime_bop( $payby2bop{$payby}, $amount, - 'quiet' => 1, - 'payinfo' => $payinfo, - 'paydate' => "$year-$month-01", - 'payname' => $payname, - 'paybatch' => $paybatch, - 'paycvv' => $paycvv, - map { $_ => $cgi->param($_) } @{$payby2fields{$payby}} -); -eidiot($error) if $error; - -$cust_main->apply_payments; - -if ( $cgi->param('save') ) { - my $new = new FS::cust_main { $cust_main->hash }; - if ( $payby eq 'CARD' ) { - $new->set( 'payby' => ( $cgi->param('auto') ? 'CARD' : 'DCRD' ) ); - } elsif ( $payby eq 'CHEK' ) { - $new->set( 'payby' => ( $cgi->param('auto') ? 'CHEK' : 'DCHK' ) ); - } else { - die "unknown payby $payby"; - } - $new->set( 'payinfo' => $payinfo ); - $new->set( 'paydate' => "$year-$month-01" ); - $new->set( 'payname' => $payname ); - - #false laziness w/FS:;cust_main::realtime_bop - check both to make sure - # working correctly - my $conf = new FS::Conf; - if ( $payby eq 'CARD' && - grep { $_ eq cardtype($payinfo) } $conf->config('cvv-save') ) { - $new->set( 'paycvv' => $paycvv ); - } else { - $new->set( 'paycvv' => ''); - } - - $new->set( $_ => $cgi->param($_) ) foreach @{$payby2fields{$payby}}; - - my $error = $new->replace($cust_main); - eidiot "payment processed successfully, but error saving info: $error" - if $error; - $cust_main = $new; -} - -#success! - -%> -<%= include( '/elements/header.html', ucfirst($type{$payby}). ' processing successful', +% +% +%#some false laziness w/MyAccount::process_payment +% +%$cgi->param('custnum') =~ /^(\d+)$/ +% or die "illegal custnum ". $cgi->param('custnum'); +%my $custnum = $1; +% +%my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); +%die "unknown custnum $custnum" unless $cust_main; +% +%$cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/ +% or eidiot "illegal amount ". $cgi->param('amount'); +%my $amount = $1; +%eidiot "amount <= 0" unless $amount > 0; +% +%$cgi->param('year') =~ /^(\d+)$/ +% or die "illegal year ". $cgi->param('year'); +%my $year = $1; +% +%$cgi->param('month') =~ /^(\d+)$/ +% or die "illegal month ". $cgi->param('month'); +%my $month = $1; +% +%$cgi->param('payby') =~ /^(CARD|CHEK)$/ +% or die "illegal payby ". $cgi->param('payby'); +%my $payby = $1; +%my %payby2bop = ( +% 'CARD' => 'CC', +% 'CHEK' => 'ECHECK', +%); +%my %payby2fields = ( +% 'CARD' => [ qw( address1 address2 city state zip ) ], +% 'CHEK' => [ qw( ss ) ], +%); +%my %type = ( 'CARD' => 'credit card', +% 'CHEK' => 'electronic check (ACH)', +% ); +% +%$cgi->param('payname') =~ /^([\w \,\.\-\']+)$/ +% or eidiot gettext('illegal_name'). " payname: ". $cgi->param('payname'); +%my $payname = $1; +% +%$cgi->param('paybatch') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/ +% or eidiot gettext('illegal_text'). " paybatch: ". $cgi->param('paybatch'); +%my $paybatch = $1; +% +%my $payinfo; +%my $paycvv = ''; +%if ( $payby eq 'CHEK' ) { +% +% $cgi->param('payinfo1') =~ /^(\d+)$/ +% or eidiot "illegal account number ". $cgi->param('payinfo1'); +% my $payinfo1 = $1; +% $cgi->param('payinfo2') =~ /^(\d+)$/ +% or eidiot "illegal ABA/routing number ". $cgi->param('payinfo2'); +% my $payinfo2 = $1; +% $payinfo = $payinfo1. '@'. $payinfo2; +% +%} elsif ( $payby eq 'CARD' ) { +% +% $payinfo = $cgi->param('payinfo'); +% $payinfo =~ s/\D//g; +% $payinfo =~ /^(\d{13,16})$/ +% or eidiot gettext('invalid_card'); # . ": ". $self->payinfo; +% $payinfo = $1; +% validate($payinfo) +% or eidiot gettext('invalid_card'); # . ": ". $self->payinfo; +% eidiot gettext('unknown_card_type') +% if cardtype($payinfo) eq "Unknown"; +% +% if ( defined $cust_main->dbdef_table->column('paycvv') ) { +% if ( length($cgi->param('paycvv') ) ) { +% if ( cardtype($payinfo) eq 'American Express card' ) { +% $cgi->param('paycvv') =~ /^(\d{4})$/ +% or eidiot "CVV2 (CID) for American Express cards is four digits."; +% $paycvv = $1; +% } else { +% $cgi->param('paycvv') =~ /^(\d{3})$/ +% or eidiot "CVV2 (CVC2/CID) is three digits."; +% $paycvv = $1; +% } +% } +% } +% +%} else { +% die "unknown payby $payby"; +%} +% +%my $error = $cust_main->realtime_bop( $payby2bop{$payby}, $amount, +% 'quiet' => 1, +% 'payinfo' => $payinfo, +% 'paydate' => "$year-$month-01", +% 'payname' => $payname, +% 'paybatch' => $paybatch, +% 'paycvv' => $paycvv, +% map { $_ => $cgi->param($_) } @{$payby2fields{$payby}} +%); +%eidiot($error) if $error; +% +%$cust_main->apply_payments; +% +%if ( $cgi->param('save') ) { +% my $new = new FS::cust_main { $cust_main->hash }; +% if ( $payby eq 'CARD' ) { +% $new->set( 'payby' => ( $cgi->param('auto') ? 'CARD' : 'DCRD' ) ); +% } elsif ( $payby eq 'CHEK' ) { +% $new->set( 'payby' => ( $cgi->param('auto') ? 'CHEK' : 'DCHK' ) ); +% } else { +% die "unknown payby $payby"; +% } +% $new->set( 'payinfo' => $payinfo ); +% $new->set( 'paydate' => "$year-$month-01" ); +% $new->set( 'payname' => $payname ); +% +% #false laziness w/FS:;cust_main::realtime_bop - check both to make sure +% # working correctly +% my $conf = new FS::Conf; +% if ( $payby eq 'CARD' && +% grep { $_ eq cardtype($payinfo) } $conf->config('cvv-save') ) { +% $new->set( 'paycvv' => $paycvv ); +% } else { +% $new->set( 'paycvv' => ''); +% } +% +% $new->set( $_ => $cgi->param($_) ) foreach @{$payby2fields{$payby}}; +% +% my $error = $new->replace($cust_main); +% eidiot "payment processed successfully, but error saving info: $error" +% if $error; +% $cust_main = $new; +%} +% +%#success! +% +% + +<% include( '/elements/header.html', ucfirst($type{$payby}). ' processing successful', include('/elements/menubar.html', 'Main menu' => popurl(3), "View this customer (#$custnum)" => @@ -143,6 +144,6 @@ if ( $cgi->param('save') ) { ) %> -<%= include( '/elements/small_custview.html', $cust_main ) %> +<% include( '/elements/small_custview.html', $cust_main ) %> </BODY> </HTML> diff --git a/httemplate/misc/queue.cgi b/httemplate/misc/queue.cgi index d8e910fb7..7370aabe1 100644 --- a/httemplate/misc/queue.cgi +++ b/httemplate/misc/queue.cgi @@ -1,47 +1,48 @@ -<% +% +% +%$cgi->param('action') =~ /^(new|del|(retry|remove) selected)$/ +% or die "Illegal action"; +%my $action = $1; +% +%my $job; +%if ( $action eq 'new' || $action eq 'del' ) { +% $cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum"; +% my $jobnum = $1; +% $job = qsearchs('queue', { 'jobnum' => $1 }) +% or die "unknown jobnum $jobnum - ". +% "it probably completed normally or was removed by another user"; +%} +% +%if ( $action eq 'new' ) { +% my %hash = $job->hash; +% $hash{'status'} = 'new'; +% $hash{'statustext'} = ''; +% my $new = new FS::queue \%hash; +% my $error = $new->replace($job); +% die $error if $error; +%} elsif ( $action eq 'del' ) { +% my $error = $job->delete; +% die $error if $error; +%} elsif ( $action =~ /^(retry|remove) selected$/ ) { +% foreach my $jobnum ( +% map { /^jobnum(\d+)$/; $1; } grep /^jobnum\d+$/, $cgi->param +% ) { +% my $job = qsearchs('queue', { 'jobnum' => $jobnum }); +% if ( $action eq 'retry selected' && $job ) { #new +% my %hash = $job->hash; +% $hash{'status'} = 'new'; +% $hash{'statustext'} = ''; +% my $new = new FS::queue \%hash; +% my $error = $new->replace($job); +% die $error if $error; +% } elsif ( $action eq 'remove selected' && $job ) { #del +% my $error = $job->delete; +% die $error if $error; +% } +% } +%} +% +%print $cgi->redirect(popurl(2). "search/queue.html"); +% +% -$cgi->param('action') =~ /^(new|del|(retry|remove) selected)$/ - or die "Illegal action"; -my $action = $1; - -my $job; -if ( $action eq 'new' || $action eq 'del' ) { - $cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum"; - my $jobnum = $1; - $job = qsearchs('queue', { 'jobnum' => $1 }) - or die "unknown jobnum $jobnum - ". - "it probably completed normally or was removed by another user"; -} - -if ( $action eq 'new' ) { - my %hash = $job->hash; - $hash{'status'} = 'new'; - $hash{'statustext'} = ''; - my $new = new FS::queue \%hash; - my $error = $new->replace($job); - die $error if $error; -} elsif ( $action eq 'del' ) { - my $error = $job->delete; - die $error if $error; -} elsif ( $action =~ /^(retry|remove) selected$/ ) { - foreach my $jobnum ( - map { /^jobnum(\d+)$/; $1; } grep /^jobnum\d+$/, $cgi->param - ) { - my $job = qsearchs('queue', { 'jobnum' => $jobnum }); - if ( $action eq 'retry selected' && $job ) { #new - my %hash = $job->hash; - $hash{'status'} = 'new'; - $hash{'statustext'} = ''; - my $new = new FS::queue \%hash; - my $error = $new->replace($job); - die $error if $error; - } elsif ( $action eq 'remove selected' && $job ) { #del - my $error = $job->delete; - die $error if $error; - } - } -} - -print $cgi->redirect(popurl(2). "search/queue.html"); - -%> diff --git a/httemplate/misc/states.cgi b/httemplate/misc/states.cgi index 63c494d15..cf2b46ee2 100644 --- a/httemplate/misc/states.cgi +++ b/httemplate/misc/states.cgi @@ -1,6 +1,7 @@ -<% - - my $country = $cgi->param('arg'); - my @output = states_hash($country); - -%>[ <%= join(', ', map { qq("$_") } @output) %> ] +% +% +% my $country = $cgi->param('arg'); +% my @output = states_hash($country); +% +% +[ <% join(', ', map { qq("$_") } @output) %> ] diff --git a/httemplate/misc/susp_pkg.cgi b/httemplate/misc/susp_pkg.cgi index 4a19fa830..ea9edc7bb 100755 --- a/httemplate/misc/susp_pkg.cgi +++ b/httemplate/misc/susp_pkg.cgi @@ -1,15 +1,16 @@ -<% +% +% +%#untaint pkgnum +%my ($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal pkgnum"; +%my $pkgnum = $1; +% +%my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +% +%my $error = $cust_pkg->suspend; +%&eidiot($error) if $error; +% +%print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); +% +% -#untaint pkgnum -my ($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal pkgnum"; -my $pkgnum = $1; - -my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - -my $error = $cust_pkg->suspend; -&eidiot($error) if $error; - -print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); - -%> diff --git a/httemplate/misc/unapply-cust_credit.cgi b/httemplate/misc/unapply-cust_credit.cgi index c658d2acc..56a3ff854 100755 --- a/httemplate/misc/unapply-cust_credit.cgi +++ b/httemplate/misc/unapply-cust_credit.cgi @@ -1,18 +1,19 @@ -<% +% +% +%#untaint crednum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal crednum"; +%my $crednum = $1; +% +%my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } ); +%my $custnum = $cust_credit->custnum; +% +%foreach my $cust_credit_bill ( $cust_credit->cust_credit_bill ) { +% my $error = $cust_credit_bill->delete; +% eidiot($error) if $error; +%} +% +%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); +% +% -#untaint crednum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal crednum"; -my $crednum = $1; - -my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } ); -my $custnum = $cust_credit->custnum; - -foreach my $cust_credit_bill ( $cust_credit->cust_credit_bill ) { - my $error = $cust_credit_bill->delete; - eidiot($error) if $error; -} - -print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); - -%> diff --git a/httemplate/misc/unapply-cust_pay.cgi b/httemplate/misc/unapply-cust_pay.cgi index 28643ef6e..b28f61b0f 100755 --- a/httemplate/misc/unapply-cust_pay.cgi +++ b/httemplate/misc/unapply-cust_pay.cgi @@ -1,18 +1,19 @@ -<% +% +% +%#untaint paynum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal paynum"; +%my $paynum = $1; +% +%my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ); +%my $custnum = $cust_pay->custnum; +% +%foreach my $cust_bill_pay ( $cust_pay->cust_bill_pay ) { +% my $error = $cust_bill_pay->delete; +% eidiot($error) if $error; +%} +% +%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); +% +% -#untaint paynum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal paynum"; -my $paynum = $1; - -my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } ); -my $custnum = $cust_pay->custnum; - -foreach my $cust_bill_pay ( $cust_pay->cust_bill_pay ) { - my $error = $cust_bill_pay->delete; - eidiot($error) if $error; -} - -print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); - -%> diff --git a/httemplate/misc/unprovision.cgi b/httemplate/misc/unprovision.cgi index 3c92a4e2e..e42feda8a 100755 --- a/httemplate/misc/unprovision.cgi +++ b/httemplate/misc/unprovision.cgi @@ -1,29 +1,31 @@ -<% +% +% +%my $dbh = dbh; +% +%#untaint svcnum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +% +%#my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); +%#die "Unknown svcnum!" unless $svc_acct; +% +%my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +%die "Unknown svcnum!" unless $cust_svc; +% +%my $custnum = $cust_svc->cust_pkg->custnum; +% +%my $error = $cust_svc->cancel; +% +%if ( $error ) { +% -my $dbh = dbh; - -#untaint svcnum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; - -#my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); -#die "Unknown svcnum!" unless $svc_acct; - -my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -die "Unknown svcnum!" unless $cust_svc; - -my $custnum = $cust_svc->cust_pkg->custnum; - -my $error = $cust_svc->cancel; - -if ( $error ) { - %> <!-- mason kludge --> -<% - &eidiot($error); -} else { - print $cgi->redirect(popurl(2)."view/cust_main.cgi?$custnum"); -} +% +% &eidiot($error); +%} else { +% print $cgi->redirect(popurl(2)."view/cust_main.cgi?$custnum"); +%} +% +% -%> diff --git a/httemplate/misc/unsusp_pkg.cgi b/httemplate/misc/unsusp_pkg.cgi index 500872983..79c07a72a 100755 --- a/httemplate/misc/unsusp_pkg.cgi +++ b/httemplate/misc/unsusp_pkg.cgi @@ -1,15 +1,16 @@ -<% +% +% +%#untaint pkgnum +%my ($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal pkgnum"; +%my $pkgnum = $1; +% +%my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +% +%my $error = $cust_pkg->unsuspend; +%&eidiot($error) if $error; +% +%print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); +% +% -#untaint pkgnum -my ($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal pkgnum"; -my $pkgnum = $1; - -my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - -my $error = $cust_pkg->unsuspend; -&eidiot($error) if $error; - -print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); - -%> diff --git a/httemplate/misc/unvoid-cust_pay_void.cgi b/httemplate/misc/unvoid-cust_pay_void.cgi index 539cd4a23..75c3edc06 100755 --- a/httemplate/misc/unvoid-cust_pay_void.cgi +++ b/httemplate/misc/unvoid-cust_pay_void.cgi @@ -1,16 +1,17 @@ -<% +% +% +%#untaint paynum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal paynum"; +%my $paynum = $1; +% +%my $cust_pay_void = qsearchs('cust_pay_void', { 'paynum' => $paynum } ); +%my $custnum = $cust_pay_void->custnum; +% +%my $error = $cust_pay_void->unvoid; +%eidiot($error) if $error; +% +%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); +% +% -#untaint paynum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal paynum"; -my $paynum = $1; - -my $cust_pay_void = qsearchs('cust_pay_void', { 'paynum' => $paynum } ); -my $custnum = $cust_pay_void->custnum; - -my $error = $cust_pay_void->unvoid; -eidiot($error) if $error; - -print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); - -%> diff --git a/httemplate/misc/upload-batch.cgi b/httemplate/misc/upload-batch.cgi index 746b81b17..742bbc0c6 100644 --- a/httemplate/misc/upload-batch.cgi +++ b/httemplate/misc/upload-batch.cgi @@ -1,30 +1,34 @@ -<% +% +% +% my $fh = $cgi->upload('batch_results'); +% my $filename = $cgi->param('batch_results'); +% $filename =~ /^(.*[\/\\])?([^\/\\]+)$/ +% or die "unparsable filename: $filename\n"; +% my $paybatch = $2; +% +% my $error = defined($fh) +% ? FS::cust_pay_batch::import_results( { +% 'filehandle' => $fh, +% 'format' => $cgi->param('format'), +% 'paybatch' => $paybatch, +% } ) +% : 'No file'; +% +% if ( $error ) { +% - my $fh = $cgi->upload('batch_results'); - my $filename = $cgi->param('batch_results'); - $filename =~ /^(.*[\/\\])?([^\/\\]+)$/ - or die "unparsable filename: $filename\n"; - my $paybatch = $2; - - my $error = defined($fh) - ? FS::cust_pay_batch::import_results( { - 'filehandle' => $fh, - 'format' => $cgi->param('format'), - 'paybatch' => $paybatch, - } ) - : 'No file'; - - if ( $error ) { - %> <!-- mason kludge --> - <% - eidiot($error); -# $cgi->param('error', $error); -# print $cgi->redirect( "${p}cust_main-import.cgi - } else { - %> +% +% eidiot($error); +%# $cgi->param('error', $error); +%# print $cgi->redirect( "${p}cust_main-import.cgi +% } else { +% + <!-- mason kludge --> - <%= include("/elements/header.html",'Batch results upload successful') %> <% - } -%> + <% include("/elements/header.html",'Batch results upload successful') %> +% +% } +% + diff --git a/httemplate/misc/void-cust_pay.cgi b/httemplate/misc/void-cust_pay.cgi index 4eec60892..b55d22c41 100755 --- a/httemplate/misc/void-cust_pay.cgi +++ b/httemplate/misc/void-cust_pay.cgi @@ -1,16 +1,17 @@ -<% +% +% +%#untaint paynum +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/ || die "Illegal paynum"; +%my $paynum = $1; +% +%my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}); +%my $custnum = $cust_pay->custnum; +% +%my $error = $cust_pay->void; +%eidiot($error) if $error; +% +%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); +% +% -#untaint paynum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal paynum"; -my $paynum = $1; - -my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}); -my $custnum = $cust_pay->custnum; - -my $error = $cust_pay->void; -eidiot($error) if $error; - -print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); - -%> diff --git a/httemplate/misc/whois.cgi b/httemplate/misc/whois.cgi index 919add42a..d3d9649fd 100644 --- a/httemplate/misc/whois.cgi +++ b/httemplate/misc/whois.cgi @@ -1,10 +1,11 @@ -<% - my $svcnum = $cgi->param('svcnum'); - my $custnum = $cgi->param('custnum'); - my $domain = $cgi->param('domain'); +% +% my $svcnum = $cgi->param('svcnum'); +% my $custnum = $cgi->param('custnum'); +% my $domain = $cgi->param('domain'); +% +% -%> -<%= include("/elements/header.html","Whois $domain", menubar( +<% include("/elements/header.html","Whois $domain", menubar( ( $custnum ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", ) @@ -13,13 +14,14 @@ "View this domain (#$svcnum)" => "${p}view/svc_domain.cgi?$svcnum", "Main menu" => $p, )) %> -<% my $whois = eval { whois($domain) }; - if ( $@ ) { - ( $whois = $@ ) =~ s/ at \/.*Net\/Whois\/Raw\.pm line \d+.*$//s; - } else { - $whois =~ s/^\n+//; - } -%> -<PRE><%= $whois %></PRE> +% my $whois = eval { whois($domain) }; +% if ( $@ ) { +% ( $whois = $@ ) =~ s/ at \/.*Net\/Whois\/Raw\.pm line \d+.*$//s; +% } else { +% $whois =~ s/^\n+//; +% } +% + +<PRE><% $whois %></PRE> </BODY> </HTML> diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi index 8dbd5a4f2..67512fad9 100644 --- a/httemplate/misc/xmlhttp-cust_main-search.cgi +++ b/httemplate/misc/xmlhttp-cust_main-search.cgi @@ -1,21 +1,22 @@ -<% - my $sub = $cgi->param('sub'); - - if ( $sub eq 'custnum_search' ) { - - my $custnum = $cgi->param('arg'); - my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); +% +% my $sub = $cgi->param('sub'); +% +% if ( $sub eq 'custnum_search' ) { +% +% my $custnum = $cgi->param('arg'); +% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); +% +% +"<% $cust_main ? $cust_main->name : '' %>" +% } elsif ( $sub eq 'smart_search' ) { +% +% my $string = $cgi->param('arg'); +% my @cust_main = smart_search( 'search' => $string ); +% my $return = [ map [ $_->custnum, $_->name ], @cust_main ]; +% +% +<% objToJson($return) %> +% } - %>"<%= $cust_main ? $cust_main->name : '' %>" - -<% } elsif ( $sub eq 'smart_search' ) { - - my $string = $cgi->param('arg'); - my @cust_main = smart_search( 'search' => $string ); - my $return = [ map [ $_->custnum, $_->name ], @cust_main ]; - - %><%= objToJson($return) %> - -<% } %> diff --git a/httemplate/misc/xmlrpc.cgi b/httemplate/misc/xmlrpc.cgi index 53ef8fb80..1d0383f2a 100644 --- a/httemplate/misc/xmlrpc.cgi +++ b/httemplate/misc/xmlrpc.cgi @@ -1,17 +1,18 @@ -<% +% +% +% my $request_xml = $cgi->param('POSTDATA'); +% +% #$r->log_error($request_xml); +% +% my $fsxmlrpc = new FS::XMLRPC; +% my ($error, $response_xml) = $fsxmlrpc->serve($request_xml); +% +% #$r->log_error($error) if $error; +% +% http_header('Content-Type' => 'text/xml', +% 'Content-Length' => length($response_xml)); +% +% print $response_xml; +% +% - my $request_xml = $cgi->param('POSTDATA'); - - #$r->log_error($request_xml); - - my $fsxmlrpc = new FS::XMLRPC; - my ($error, $response_xml) = $fsxmlrpc->serve($request_xml); - - #$r->log_error($error) if $error; - - http_header('Content-Type' => 'text/xml', - 'Content-Length' => length($response_xml)); - - print $response_xml; - -%> diff --git a/httemplate/search/cdr.html b/httemplate/search/cdr.html index e3d6043e8..827a50895 100644 --- a/httemplate/search/cdr.html +++ b/httemplate/search/cdr.html @@ -1,29 +1,30 @@ -<% - -my $title = 'Call Detail Records'; -my $hashref = {}; -my $count_query = 'SELECT COUNT(*) FROM cdr'; - -#process params for CDR search, populate $hashref... -# and fixup $count_query - -if ( $cgi->param('freesidestatus') eq 'NULL' ) { - - my $title = "Unprocessed $title"; - $hashref->{'freesidestatus'} = ''; # Record.pm will take care of it - #$count_query .= " AND ( freesidestatus IS NULL OR freesidestatus = '' )"; - $count_query .= " WHERE ( freesidestatus IS NULL OR freesidestatus = '' )"; - -} elsif ( $cgi->param('freesidestatus') =~ /^([\w ]+)$/ ) { - - my $title = "Processed $title"; - $hashref->{'freesidestatus'} = $1; - #$count_query .= " AND freesidestatus = '$1'"; - $count_query .= " WHERE freesidestatus = '$1'"; - -} - -%><%= include( 'elements/search.html', +% +% +%my $title = 'Call Detail Records'; +%my $hashref = {}; +%my $count_query = 'SELECT COUNT(*) FROM cdr'; +% +%#process params for CDR search, populate $hashref... +%# and fixup $count_query +% +%if ( $cgi->param('freesidestatus') eq 'NULL' ) { +% +% my $title = "Unprocessed $title"; +% $hashref->{'freesidestatus'} = ''; # Record.pm will take care of it +% #$count_query .= " AND ( freesidestatus IS NULL OR freesidestatus = '' )"; +% $count_query .= " WHERE ( freesidestatus IS NULL OR freesidestatus = '' )"; +% +%} elsif ( $cgi->param('freesidestatus') =~ /^([\w ]+)$/ ) { +% +% my $title = "Processed $title"; +% $hashref->{'freesidestatus'} = $1; +% #$count_query .= " AND freesidestatus = '$1'"; +% $count_query .= " WHERE freesidestatus = '$1'"; +% +%} +% +% +<% include( 'elements/search.html', 'title' => $title, 'name' => 'call detail records', 'query' => { 'table' => 'cdr', diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 79c05dc42..894ddad51 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -1,166 +1,167 @@ -<% - - my $join_cust_main = 'LEFT JOIN cust_main USING ( custnum )'; - #here is the agent virtualization - my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql; - - my( $count_query, $sql_query ); - my( $count_addl ) = ( '' ); - my( $distinct ) = ( '' ); - my($begin, $end) = ( '', '' ); - my($agentnum) = ( '' ); - my($open, $days) = ( '', '' ); - if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) { - $count_query = - "SELECT COUNT(*) FROM cust_bill $join_cust_main". - " WHERE invnum = $2 AND $agentnums_sql"; #agent virtualization - $sql_query = { - 'table' => 'cust_bill', - 'addl_from' => $join_cust_main, - 'hashref' => { 'invnum' => $2 }, - #'select' => '*', - 'extra_sql' => " AND $agentnums_sql", #agent virtualization - }; - } else { - #if ( $cgi->param('begin') || $cgi->param('end') - # || $cgi->param('beginning') || $cgi->param('ending') - # || $cgi->keywords - # ) - #{ - - #some false laziness w/cust_bill::re_X - my @where; - my $orderby = 'ORDER BY cust_bill._date'; - - if ( $cgi->param('beginning') - && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { - $begin = str2time($1); - push @where, "cust_bill._date >= $begin"; - } - if ( $cgi->param('ending') - && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { - $end = str2time($1) + 86399; - push @where, "cust_bill._date < $end"; - } - - if ( $cgi->param('begin') =~ /^(\d+)$/ ) { - $begin = $1; - push @where, "cust_bill._date >= $begin"; - } - if ( $cgi->param('end') =~ /^(\d+)$/ ) { - $end = $1; - push @where, "cust_bill._date < $end"; - } - - if ( $cgi->param('invnum_min') =~ /^\s*(\d+)\s*$/ ) { - push @where, "cust_bill.invnum >= $1"; - } - if ( $cgi->param('invnum_max') =~ /^\s*(\d+)\s*$/ ) { - push @where, "cust_bill.invnum <= $1"; - } - - if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $agentnum = $1; - push @where, "cust_main.agentnum = $agentnum"; - } - - my $owed = - "charged - ( SELECT COALESCE(SUM(amount),0) FROM cust_bill_pay - WHERE cust_bill_pay.invnum = cust_bill.invnum ) - - ( SELECT COALESCE(SUM(amount),0) FROM cust_credit_bill - WHERE cust_credit_bill.invnum = cust_bill.invnum )"; - - if ( $cgi->param('open') ) { - push @where, "0 != $owed"; - $open = 1; - } - - my($query) = $cgi->keywords; - if ( $query =~ /^(OPEN(\d*)_)?(invnum|date|custnum)$/ ) { - ($open, $days, my $field) = ($1, $2, $3); - $field = "_date" if $field eq 'date'; - $orderby = "ORDER BY cust_bill.$field"; - push @where, "0 != $owed" if $open; - push @where, "cust_bill._date < ". (time-86400*$days) if $days; - } - - #here is the agent virtualization - push @where, $agentnums_sql; - my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; - - if ( $cgi->param('newest_percust') ) { - $distinct = 'DISTINCT ON ( cust_bill.custnum )'; - $orderby = 'ORDER BY cust_bill.custnum ASC, cust_bill._date DESC'; - #$count_query = "SELECT 'N/A', 'N/A', 'N/A'"; #XXXXXXX fix - $count_query = "SELECT COUNT(DISTINCT cust_bill.custnum), 'N/A', 'N/A'"; - } - - unless ( $count_query ) { - $count_query = "SELECT COUNT(*), sum(charged), sum($owed)"; - $count_addl = [ '$%.2f total invoiced', - '$%.2f total outstanding balance', - ]; - } - $count_query .= " FROM cust_bill $join_cust_main $extra_sql"; - - $sql_query = { - 'table' => 'cust_bill', - 'addl_from' => $join_cust_main, - 'hashref' => {}, - 'select' => "$distinct ". join(', ', - 'cust_bill.*', - #( map "cust_main.$_", qw(custnum last first company) ), - 'cust_main.custnum as cust_main_custnum', - FS::UI::Web::cust_sql_fields(), - "$owed as owed", - ), - 'extra_sql' => "$extra_sql $orderby" - }; - - } - - my $link = [ "${p}view/cust_bill.cgi?", 'invnum', ]; - my $clink = sub { - my $cust_bill = shift; - $cust_bill->cust_main_custnum - ? [ "${p}view/cust_main.cgi?", 'custnum' ] - : ''; - }; - - my $conf = new FS::Conf; - my $money_char = $conf->config('money_char') || '$'; - - my $html_init = join("\n", map { - ( my $action = $_ ) =~ s/_$//; - include('/elements/progress-init.html', - $_.'form', - [ 'begin', 'end', 'agentnum', 'open', 'days', 'newest_percust' ], - "../misc/${_}invoices.cgi", - { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but... - $_, #key - ), - qq!<FORM NAME="${_}form">!, - qq!<INPUT TYPE="hidden" NAME="begin" VALUE="$begin">!, - qq!<INPUT TYPE="hidden" NAME="end" VALUE="$end">!, - qq!<INPUT TYPE="hidden" NAME="agentnum" VALUE="$agentnum">!, - qq!<INPUT TYPE="hidden" NAME="open" VALUE="$open">!, - qq!<INPUT TYPE="hidden" NAME="days" VALUE="$days">!, - qq!</FORM>! - } qw( print_ email_ fax_ ) ); - - my $menubar = [ - 'Main menu' => $p, - 'Print these invoices' => - "javascript:print_process()", - 'Email these invoices' => - "javascript:email_process()", - ]; - - push @$menubar, 'Fax these invoices' => - "javascript:fax_process()" - if $conf->exists('hylafax'); - -%><%= include( 'elements/search.html', +% +% +% my $join_cust_main = 'LEFT JOIN cust_main USING ( custnum )'; +% #here is the agent virtualization +% my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql; +% +% my( $count_query, $sql_query ); +% my( $count_addl ) = ( '' ); +% my( $distinct ) = ( '' ); +% my($begin, $end) = ( '', '' ); +% my($agentnum) = ( '' ); +% my($open, $days) = ( '', '' ); +% if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) { +% $count_query = +% "SELECT COUNT(*) FROM cust_bill $join_cust_main". +% " WHERE invnum = $2 AND $agentnums_sql"; #agent virtualization +% $sql_query = { +% 'table' => 'cust_bill', +% 'addl_from' => $join_cust_main, +% 'hashref' => { 'invnum' => $2 }, +% #'select' => '*', +% 'extra_sql' => " AND $agentnums_sql", #agent virtualization +% }; +% } else { +% #if ( $cgi->param('begin') || $cgi->param('end') +% # || $cgi->param('beginning') || $cgi->param('ending') +% # || $cgi->keywords +% # ) +% #{ +% +% #some false laziness w/cust_bill::re_X +% my @where; +% my $orderby = 'ORDER BY cust_bill._date'; +% +% if ( $cgi->param('beginning') +% && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { +% $begin = str2time($1); +% push @where, "cust_bill._date >= $begin"; +% } +% if ( $cgi->param('ending') +% && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { +% $end = str2time($1) + 86399; +% push @where, "cust_bill._date < $end"; +% } +% +% if ( $cgi->param('begin') =~ /^(\d+)$/ ) { +% $begin = $1; +% push @where, "cust_bill._date >= $begin"; +% } +% if ( $cgi->param('end') =~ /^(\d+)$/ ) { +% $end = $1; +% push @where, "cust_bill._date < $end"; +% } +% +% if ( $cgi->param('invnum_min') =~ /^\s*(\d+)\s*$/ ) { +% push @where, "cust_bill.invnum >= $1"; +% } +% if ( $cgi->param('invnum_max') =~ /^\s*(\d+)\s*$/ ) { +% push @where, "cust_bill.invnum <= $1"; +% } +% +% if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $agentnum = $1; +% push @where, "cust_main.agentnum = $agentnum"; +% } +% +% my $owed = +% "charged - ( SELECT COALESCE(SUM(amount),0) FROM cust_bill_pay +% WHERE cust_bill_pay.invnum = cust_bill.invnum ) +% - ( SELECT COALESCE(SUM(amount),0) FROM cust_credit_bill +% WHERE cust_credit_bill.invnum = cust_bill.invnum )"; +% +% if ( $cgi->param('open') ) { +% push @where, "0 != $owed"; +% $open = 1; +% } +% +% my($query) = $cgi->keywords; +% if ( $query =~ /^(OPEN(\d*)_)?(invnum|date|custnum)$/ ) { +% ($open, $days, my $field) = ($1, $2, $3); +% $field = "_date" if $field eq 'date'; +% $orderby = "ORDER BY cust_bill.$field"; +% push @where, "0 != $owed" if $open; +% push @where, "cust_bill._date < ". (time-86400*$days) if $days; +% } +% +% #here is the agent virtualization +% push @where, $agentnums_sql; +% my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; +% +% if ( $cgi->param('newest_percust') ) { +% $distinct = 'DISTINCT ON ( cust_bill.custnum )'; +% $orderby = 'ORDER BY cust_bill.custnum ASC, cust_bill._date DESC'; +% #$count_query = "SELECT 'N/A', 'N/A', 'N/A'"; #XXXXXXX fix +% $count_query = "SELECT COUNT(DISTINCT cust_bill.custnum), 'N/A', 'N/A'"; +% } +% +% unless ( $count_query ) { +% $count_query = "SELECT COUNT(*), sum(charged), sum($owed)"; +% $count_addl = [ '$%.2f total invoiced', +% '$%.2f total outstanding balance', +% ]; +% } +% $count_query .= " FROM cust_bill $join_cust_main $extra_sql"; +% +% $sql_query = { +% 'table' => 'cust_bill', +% 'addl_from' => $join_cust_main, +% 'hashref' => {}, +% 'select' => "$distinct ". join(', ', +% 'cust_bill.*', +% #( map "cust_main.$_", qw(custnum last first company) ), +% 'cust_main.custnum as cust_main_custnum', +% FS::UI::Web::cust_sql_fields(), +% "$owed as owed", +% ), +% 'extra_sql' => "$extra_sql $orderby" +% }; +% +% } +% +% my $link = [ "${p}view/cust_bill.cgi?", 'invnum', ]; +% my $clink = sub { +% my $cust_bill = shift; +% $cust_bill->cust_main_custnum +% ? [ "${p}view/cust_main.cgi?", 'custnum' ] +% : ''; +% }; +% +% my $conf = new FS::Conf; +% my $money_char = $conf->config('money_char') || '$'; +% +% my $html_init = join("\n", map { +% ( my $action = $_ ) =~ s/_$//; +% include('/elements/progress-init.html', +% $_.'form', +% [ 'begin', 'end', 'agentnum', 'open', 'days', 'newest_percust' ], +% "../misc/${_}invoices.cgi", +% { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but... +% $_, #key +% ), +% qq!<FORM NAME="${_}form">!, +% qq!<INPUT TYPE="hidden" NAME="begin" VALUE="$begin">!, +% qq!<INPUT TYPE="hidden" NAME="end" VALUE="$end">!, +% qq!<INPUT TYPE="hidden" NAME="agentnum" VALUE="$agentnum">!, +% qq!<INPUT TYPE="hidden" NAME="open" VALUE="$open">!, +% qq!<INPUT TYPE="hidden" NAME="days" VALUE="$days">!, +% qq!</FORM>! +% } qw( print_ email_ fax_ ) ); +% +% my $menubar = [ +% 'Main menu' => $p, +% 'Print these invoices' => +% "javascript:print_process()", +% 'Email these invoices' => +% "javascript:email_process()", +% ]; +% +% push @$menubar, 'Fax these invoices' => +% "javascript:fax_process()" +% if $conf->exists('hylafax'); +% +% +<% include( 'elements/search.html', 'title' => 'Invoice Search Results', 'html_init' => $html_init, 'menubar' => $menubar, diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi index d82a83368..d1dd65d65 100644 --- a/httemplate/search/cust_bill_event.cgi +++ b/httemplate/search/cust_bill_event.cgi @@ -1,94 +1,95 @@ -<% - -my $title = $cgi->param('failed') ? 'Failed invoice events' : 'Invoice events'; - -my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - -##tie my %hash, 'Tie::DxHash', -#my %hash = ( -# _date => { op=> '>=', value=>$beginning }, -## i wish... -## _date => { op=> '<=', value=>$ending }, -#); -#$hash{'statustext'} = { op=> '!=', value=>'' } -# if $cgi->param('failed'); - -my $where = " WHERE cust_bill_event._date >= $beginning". - " AND cust_bill_event._date <= $ending"; - -if ( $cgi->param('failed') ) { - $where .= " AND statustext != '' ". - " AND statustext IS NOT NULL ". - " AND statustext != 'N/A' " -} - -if ( $cgi->param('part_bill_event.payby') =~ /^(\w+)$/ ) { - $where .= " AND part_bill_event.payby = '$1' "; -} - -my $sql_query = { - 'table' => 'cust_bill_event', - #'hashref' => \%hash, - 'hashref' => {}, - 'select' => join(', ', - 'cust_bill_event.*', - 'part_bill_event.event', - 'cust_bill.custnum', - 'cust_bill._date AS cust_bill_date', - 'cust_main.custnum AS cust_main_custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => "$where ORDER BY _date ASC", - 'addl_from' => 'LEFT JOIN part_bill_event USING ( eventpart ) '. - 'LEFT JOIN cust_bill USING ( invnum ) '. - 'LEFT JOIN cust_main USING ( custnum ) ', -}; - -my $count_sql = "SELECT COUNT(*) FROM cust_bill_event ". - "LEFT JOIN part_bill_event USING ( eventpart ) ". - $where; - -my $conf = new FS::Conf; - -my $failed = $cgi->param('failed'); - -my $html_init = join("\n", map { - ( my $action = $_ ) =~ s/_$//; - include('/elements/progress-init.html', - $_.'form', - [ 'action', 'beginning', 'ending', 'failed' ], - "../misc/${_}invoice_events.cgi", - { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but... - $_, #key - ), - qq!<FORM NAME="${_}form">!, - qq!<INPUT TYPE="hidden" NAME="action" VALUE="$_">!, #not used though - qq!<INPUT TYPE="hidden" NAME="beginning" VALUE="$beginning">!, - qq!<INPUT TYPE="hidden" NAME="ending" VALUE="$ending">!, - qq!<INPUT TYPE="hidden" NAME="failed" VALUE="$failed">!, - qq!</FORM>! -} qw( print_ email_ fax_ ) ); - -my $menubar = [ - 'Main menu' => $p, - 'Re-print these events' => - "javascript:print_process()", - 'Re-email these events' => - "javascript:email_process()", - ]; - -push @$menubar, 'Re-fax these events' => - "javascript:fax_process()" - if $conf->exists('hylafax'); - -my $link_cust = sub { - my $cust_bill_event = shift; - $cust_bill_event->cust_main_custnum - ? [ "${p}view/cust_main.cgi?", 'custnum' ] - : ''; -}; - -%><%= include( 'elements/search.html', +% +% +%my $title = $cgi->param('failed') ? 'Failed invoice events' : 'Invoice events'; +% +%my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +% +%##tie my %hash, 'Tie::DxHash', +%#my %hash = ( +%# _date => { op=> '>=', value=>$beginning }, +%## i wish... +%## _date => { op=> '<=', value=>$ending }, +%#); +%#$hash{'statustext'} = { op=> '!=', value=>'' } +%# if $cgi->param('failed'); +% +%my $where = " WHERE cust_bill_event._date >= $beginning". +% " AND cust_bill_event._date <= $ending"; +% +%if ( $cgi->param('failed') ) { +% $where .= " AND statustext != '' ". +% " AND statustext IS NOT NULL ". +% " AND statustext != 'N/A' " +%} +% +%if ( $cgi->param('part_bill_event.payby') =~ /^(\w+)$/ ) { +% $where .= " AND part_bill_event.payby = '$1' "; +%} +% +%my $sql_query = { +% 'table' => 'cust_bill_event', +% #'hashref' => \%hash, +% 'hashref' => {}, +% 'select' => join(', ', +% 'cust_bill_event.*', +% 'part_bill_event.event', +% 'cust_bill.custnum', +% 'cust_bill._date AS cust_bill_date', +% 'cust_main.custnum AS cust_main_custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'extra_sql' => "$where ORDER BY _date ASC", +% 'addl_from' => 'LEFT JOIN part_bill_event USING ( eventpart ) '. +% 'LEFT JOIN cust_bill USING ( invnum ) '. +% 'LEFT JOIN cust_main USING ( custnum ) ', +%}; +% +%my $count_sql = "SELECT COUNT(*) FROM cust_bill_event ". +% "LEFT JOIN part_bill_event USING ( eventpart ) ". +% $where; +% +%my $conf = new FS::Conf; +% +%my $failed = $cgi->param('failed'); +% +%my $html_init = join("\n", map { +% ( my $action = $_ ) =~ s/_$//; +% include('/elements/progress-init.html', +% $_.'form', +% [ 'action', 'beginning', 'ending', 'failed' ], +% "../misc/${_}invoice_events.cgi", +% { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but... +% $_, #key +% ), +% qq!<FORM NAME="${_}form">!, +% qq!<INPUT TYPE="hidden" NAME="action" VALUE="$_">!, #not used though +% qq!<INPUT TYPE="hidden" NAME="beginning" VALUE="$beginning">!, +% qq!<INPUT TYPE="hidden" NAME="ending" VALUE="$ending">!, +% qq!<INPUT TYPE="hidden" NAME="failed" VALUE="$failed">!, +% qq!</FORM>! +%} qw( print_ email_ fax_ ) ); +% +%my $menubar = [ +% 'Main menu' => $p, +% 'Re-print these events' => +% "javascript:print_process()", +% 'Re-email these events' => +% "javascript:email_process()", +% ]; +% +%push @$menubar, 'Re-fax these events' => +% "javascript:fax_process()" +% if $conf->exists('hylafax'); +% +%my $link_cust = sub { +% my $cust_bill_event = shift; +% $cust_bill_event->cust_main_custnum +% ? [ "${p}view/cust_main.cgi?", 'custnum' ] +% : ''; +%}; +% +% +<% include( 'elements/search.html', 'title' => $title, 'html_init' => $html_init, 'menubar' => $menubar, diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html index 197f28028..7cdf25112 100755 --- a/httemplate/search/cust_bill_event.html +++ b/httemplate/search/cust_bill_event.html @@ -1,4 +1,4 @@ -<%= include( +<% include( '/elements/header.html', ( $cgi->param('failed') ? 'Failed invoice events' : 'Invoice events' ), include('/elements/menubar.html', @@ -9,7 +9,7 @@ %> <FORM ACTION="cust_bill_event.cgi" METHOD="GET"> - <INPUT TYPE="hidden" NAME="failed" VALUE="<%= $cgi->param('failed') %>"> + <INPUT TYPE="hidden" NAME="failed" VALUE="<% $cgi->param('failed') %>"> <TABLE> <!--<TR> <TD ALIGN="right">Customer type</TD> @@ -23,15 +23,16 @@ </TD> </TR> --> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <% include( '/elements/tr-input-beginning_ending.html' ) %> <!-- <TR> <TD ALIGN="right">Events: </TD> <TD> <SELECT NAME="eventpart"> - <OPTION SELECTED VALUE=""><%= $cgi->param('failed') ? '(all failed events)' : '(all events)' %> - <% foreach my $part_bill_event ( qsearch( 'part_bill_event', {} ) ) { %> - <% } %> + <OPTION SELECTED VALUE=""><% $cgi->param('failed') ? '(all failed events)' : '(all events)' %> +% foreach my $part_bill_event ( qsearch( 'part_bill_event', {} ) ) { +% } + </SELECT> </TD> </TR> diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 4779071a4..b5289d713 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -1,130 +1,131 @@ -<% - -my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - -my $join_cust = " - JOIN cust_bill USING ( invnum ) - LEFT JOIN cust_main USING ( custnum ) -"; - -my $join_pkg = " - LEFT JOIN cust_pkg USING ( pkgnum ) - LEFT JOIN part_pkg USING ( pkgpart ) -"; - -my $where = " WHERE _date >= $beginning AND _date <= $ending "; - -$where .= " AND payby != 'COMP' " - unless $cgi->param('include_comp_cust'); - -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $where .= " AND agentnum = $1 "; -} - -if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { - if ( $1 == 0 ) { - $where .= " AND classnum IS NULL "; - } else { - $where .= " AND classnum = $1 "; - } -} - -if ( $cgi->param('out') ) { - - $where .= " - AND 0 = ( - SELECT COUNT(*) FROM cust_main_county - WHERE ( cust_main_county.county = cust_main.county - OR ( cust_main_county.county IS NULL AND cust_main.county = '' ) - OR ( cust_main_county.county = '' AND cust_main.county IS NULL) - OR ( cust_main_county.county IS NULL AND cust_main.county IS NULL) - ) - AND ( cust_main_county.state = cust_main.state - OR ( cust_main_county.state IS NULL AND cust_main.state = '' ) - OR ( cust_main_county.state = '' AND cust_main.state IS NULL ) - OR ( cust_main_county.state IS NULL AND cust_main.state IS NULL ) - ) - AND cust_main_county.country = cust_main.country - AND cust_main_county.tax > 0 - ) - "; - -} elsif ( $cgi->param('country' ) ) { - - my $county = dbh->quote( $cgi->param('county') ); - my $state = dbh->quote( $cgi->param('state') ); - my $country = dbh->quote( $cgi->param('country') ); - $where .= " - AND ( county = $county OR $county = '' ) - AND ( state = $state OR $state = '' ) - AND country = $country - "; - $where .= ' AND taxclass = '. dbh->quote( $cgi->param('taxclass') ) - if $cgi->param('taxclass'); - -} - -$where .= ' AND pkgnum != 0' if $cgi->param('nottax'); - -$where .= ' AND pkgnum = 0' if $cgi->param('istax'); - -$where .= " AND tax = 'Y'" if $cgi->param('cust_tax'); - -my $count_query; -if ( $cgi->param('pkg_tax') ) { - - $count_query = - "SELECT COUNT(*), SUM( - ( CASE WHEN part_pkg.setuptax = 'Y' - THEN cust_bill_pkg.setup - ELSE 0 - END - ) - + - ( CASE WHEN part_pkg.recurtax = 'Y' - THEN cust_bill_pkg.recur - ELSE 0 - END - ) - ) - "; - - $where .= " AND ( - ( part_pkg.setuptax = 'Y' AND cust_bill_pkg.setup > 0 ) - OR ( part_pkg.recurtax = 'Y' AND cust_bill_pkg.recur > 0 ) - ) - AND ( tax != 'Y' OR tax IS NULL ) - "; - -} else { - - $count_query = - "SELECT COUNT(*), SUM(cust_bill_pkg.setup + cust_bill_pkg.recur)"; - -} -$count_query .= " FROM cust_bill_pkg $join_cust $join_pkg $where"; - -my $query = { - 'table' => 'cust_bill_pkg', - 'addl_from' => "$join_cust $join_pkg", - 'hashref' => {}, - 'select' => join(', ', - 'cust_bill_pkg.*', - 'cust_bill._date', - 'part_pkg.pkg', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => $where, -}; - -my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ]; -my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; - -my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; - -%><%= include( 'elements/search.html', +% +% +%my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +% +%my $join_cust = " +% JOIN cust_bill USING ( invnum ) +% LEFT JOIN cust_main USING ( custnum ) +%"; +% +%my $join_pkg = " +% LEFT JOIN cust_pkg USING ( pkgnum ) +% LEFT JOIN part_pkg USING ( pkgpart ) +%"; +% +%my $where = " WHERE _date >= $beginning AND _date <= $ending "; +% +%$where .= " AND payby != 'COMP' " +% unless $cgi->param('include_comp_cust'); +% +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $where .= " AND agentnum = $1 "; +%} +% +%if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { +% if ( $1 == 0 ) { +% $where .= " AND classnum IS NULL "; +% } else { +% $where .= " AND classnum = $1 "; +% } +%} +% +%if ( $cgi->param('out') ) { +% +% $where .= " +% AND 0 = ( +% SELECT COUNT(*) FROM cust_main_county +% WHERE ( cust_main_county.county = cust_main.county +% OR ( cust_main_county.county IS NULL AND cust_main.county = '' ) +% OR ( cust_main_county.county = '' AND cust_main.county IS NULL) +% OR ( cust_main_county.county IS NULL AND cust_main.county IS NULL) +% ) +% AND ( cust_main_county.state = cust_main.state +% OR ( cust_main_county.state IS NULL AND cust_main.state = '' ) +% OR ( cust_main_county.state = '' AND cust_main.state IS NULL ) +% OR ( cust_main_county.state IS NULL AND cust_main.state IS NULL ) +% ) +% AND cust_main_county.country = cust_main.country +% AND cust_main_county.tax > 0 +% ) +% "; +% +%} elsif ( $cgi->param('country' ) ) { +% +% my $county = dbh->quote( $cgi->param('county') ); +% my $state = dbh->quote( $cgi->param('state') ); +% my $country = dbh->quote( $cgi->param('country') ); +% $where .= " +% AND ( county = $county OR $county = '' ) +% AND ( state = $state OR $state = '' ) +% AND country = $country +% "; +% $where .= ' AND taxclass = '. dbh->quote( $cgi->param('taxclass') ) +% if $cgi->param('taxclass'); +% +%} +% +%$where .= ' AND pkgnum != 0' if $cgi->param('nottax'); +% +%$where .= ' AND pkgnum = 0' if $cgi->param('istax'); +% +%$where .= " AND tax = 'Y'" if $cgi->param('cust_tax'); +% +%my $count_query; +%if ( $cgi->param('pkg_tax') ) { +% +% $count_query = +% "SELECT COUNT(*), SUM( +% ( CASE WHEN part_pkg.setuptax = 'Y' +% THEN cust_bill_pkg.setup +% ELSE 0 +% END +% ) +% + +% ( CASE WHEN part_pkg.recurtax = 'Y' +% THEN cust_bill_pkg.recur +% ELSE 0 +% END +% ) +% ) +% "; +% +% $where .= " AND ( +% ( part_pkg.setuptax = 'Y' AND cust_bill_pkg.setup > 0 ) +% OR ( part_pkg.recurtax = 'Y' AND cust_bill_pkg.recur > 0 ) +% ) +% AND ( tax != 'Y' OR tax IS NULL ) +% "; +% +%} else { +% +% $count_query = +% "SELECT COUNT(*), SUM(cust_bill_pkg.setup + cust_bill_pkg.recur)"; +% +%} +%$count_query .= " FROM cust_bill_pkg $join_cust $join_pkg $where"; +% +%my $query = { +% 'table' => 'cust_bill_pkg', +% 'addl_from' => "$join_cust $join_pkg", +% 'hashref' => {}, +% 'select' => join(', ', +% 'cust_bill_pkg.*', +% 'cust_bill._date', +% 'part_pkg.pkg', +% 'cust_main.custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'extra_sql' => $where, +%}; +% +%my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ]; +%my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; +% +%my $conf = new FS::Conf; +%my $money_char = $conf->config('money_char') || '$'; +% +% +<% include( 'elements/search.html', 'title' => 'Line items', 'name' => 'line items', 'query' => $query, diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index eb78db5cd..80cfc4585 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -1,70 +1,71 @@ -<% - my $title = 'Credit Search Results'; - #my( $count_query, $sql_query ); - - my @search = (); - - if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) { - push @search, "cust_credit.otaker = '$1'"; - } - - if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { - push @search, "agentnum = $1"; - my $agent = qsearchs('agent', { 'agentnum' => $1 } ); - die "unknown agentnum $1" unless $agent; - $title = $agent->agent. " $title"; - } - - #false laziness with cust_pkg.cgi and cust_pay.cgi - if ( $cgi->param('beginning') - && $cgi->param('beginning') =~ /^([ 0-9\-\/]{1,10})$/ ) { - my $beginning = str2time($1); - push @search, "_date >= $beginning "; - } - if ( $cgi->param('ending') - && $cgi->param('ending') =~ /^([ 0-9\-\/]{1,10})$/ ) { - my $ending = str2time($1) + 86399; - push @search, " _date <= $ending "; - } - - if ( $cgi->param('begin') - && $cgi->param('begin') =~ /^(\d+)$/ ) { - push @search, "_date >= $1 "; - } - if ( $cgi->param('end') - && $cgi->param('end') =~ /^(\d+)$/ ) { - push @search, " _date < $1 "; - } - - #here is the agent virtualization - push @search, $FS::CurrentUser::CurrentUser->agentnums_sql; - - my $where = 'WHERE '. join(' AND ', @search); - - my $count_query = 'SELECT COUNT(*), SUM(amount) '. - 'FROM cust_credit LEFT JOIN cust_main USING ( custnum ) '. - $where; - - my $sql_query = { - 'table' => 'cust_credit', - 'select' => join(', ', - 'cust_credit.*', - 'cust_main.custnum as cust_main_custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'hashref' => {}, - 'extra_sql' => $where, - 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', - }; - - my $clink = sub { - my $cust_bill = shift; - $cust_bill->cust_main_custnum - ? [ "${p}view/cust_main.cgi?", 'custnum' ] - : ''; - }; - -%><%= include( 'elements/search.html', +% +% my $title = 'Credit Search Results'; +% #my( $count_query, $sql_query ); +% +% my @search = (); +% +% if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) { +% push @search, "cust_credit.otaker = '$1'"; +% } +% +% if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% push @search, "agentnum = $1"; +% my $agent = qsearchs('agent', { 'agentnum' => $1 } ); +% die "unknown agentnum $1" unless $agent; +% $title = $agent->agent. " $title"; +% } +% +% #false laziness with cust_pkg.cgi and cust_pay.cgi +% if ( $cgi->param('beginning') +% && $cgi->param('beginning') =~ /^([ 0-9\-\/]{1,10})$/ ) { +% my $beginning = str2time($1); +% push @search, "_date >= $beginning "; +% } +% if ( $cgi->param('ending') +% && $cgi->param('ending') =~ /^([ 0-9\-\/]{1,10})$/ ) { +% my $ending = str2time($1) + 86399; +% push @search, " _date <= $ending "; +% } +% +% if ( $cgi->param('begin') +% && $cgi->param('begin') =~ /^(\d+)$/ ) { +% push @search, "_date >= $1 "; +% } +% if ( $cgi->param('end') +% && $cgi->param('end') =~ /^(\d+)$/ ) { +% push @search, " _date < $1 "; +% } +% +% #here is the agent virtualization +% push @search, $FS::CurrentUser::CurrentUser->agentnums_sql; +% +% my $where = 'WHERE '. join(' AND ', @search); +% +% my $count_query = 'SELECT COUNT(*), SUM(amount) '. +% 'FROM cust_credit LEFT JOIN cust_main USING ( custnum ) '. +% $where; +% +% my $sql_query = { +% 'table' => 'cust_credit', +% 'select' => join(', ', +% 'cust_credit.*', +% 'cust_main.custnum as cust_main_custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'hashref' => {}, +% 'extra_sql' => $where, +% 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', +% }; +% +% my $clink = sub { +% my $cust_bill = shift; +% $cust_bill->cust_main_custnum +% ? [ "${p}view/cust_main.cgi?", 'custnum' ] +% : ''; +% }; +% +% +<% include( 'elements/search.html', 'title' => $title, 'name' => 'credits', 'query' => $sql_query, diff --git a/httemplate/search/cust_main-otaker.cgi b/httemplate/search/cust_main-otaker.cgi index 6ac0bde18..210172fc0 100755 --- a/httemplate/search/cust_main-otaker.cgi +++ b/httemplate/search/cust_main-otaker.cgi @@ -1,23 +1,25 @@ -<%= include('/elements/header.html', 'Customer Search' ) %> +<% include('/elements/header.html', 'Customer Search' ) %> <FORM ACTION="cust_main.cgi" METHOD="GET"> Search for <B>Order taker</B>: <INPUT TYPE="hidden" NAME="otaker_on" VALUE="TRUE"> +% my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_main") +% or die dbh->errstr; +% $sth->execute() or die $sth->errstr; +% #my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref}; +% -<% my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_main") - or die dbh->errstr; - $sth->execute() or die $sth->errstr; - #my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref}; -%> <SELECT NAME="otaker"> -<% my $otaker; while ( $otaker = $sth->fetchrow_arrayref ) { %> - <OPTION><%= $otaker->[0] %> -<% } %> +% my $otaker; while ( $otaker = $sth->fetchrow_arrayref ) { + + <OPTION><% $otaker->[0] %> +% } + </SELECT> <P><INPUT TYPE="submit" VALUE="Search"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/cust_main-zip.html b/httemplate/search/cust_main-zip.html index 333a1e0b1..9790c0fef 100644 --- a/httemplate/search/cust_main-zip.html +++ b/httemplate/search/cust_main-zip.html @@ -1,89 +1,90 @@ -<% - -# XXX link to customers - -my @where = (); - -# select status - -if ( $cgi->param('status') =~ /^(prospect|uncancel|active|susp|cancel)$/ ) { - my $method = $1.'_sql'; - push @where, FS::cust_main->$method(); -} - -# select agent -# XXX this needs to be virtualized by agent too (like lots of stuff) - -my $agentnum = ''; -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $agentnum = $1; - push @where, "cust_main.agentnum = $agentnum"; -} -my $where = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; - -# bill zip vs ship zip - -sub fieldorempty { - my $field = shift; - "CASE WHEN $field IS NULL THEN '' ELSE $field END"; -} - -sub strip_plus4 { - my $field = shift; - "CASE WHEN $field is NULL - THEN '' - ELSE CASE WHEN $field LIKE '_____-____' - THEN SUBSTRING($field FROM 1 FOR 5) - ELSE $field - END - END"; -} - -my( $zip, $czip); -if ( $cgi->param('column') eq 'ship_zip' ) { - - my $casewhen_noship = - "CASE WHEN ( ship_last IS NULL OR ship_last = '' ) THEN "; - - $czip = "$casewhen_noship zip ELSE ship_zip END"; - - if ( $cgi->param('ignore_plus4') ) { - $zip = $casewhen_noship. strip_plus4('zip'). - " ELSE ". strip_plus4('ship_zip'). ' END'; - - } else { - $zip = $casewhen_noship. fieldorempty('zip'). - " ELSE ". fieldorempty('ship_zip'). ' END'; - } - -} else { - - $czip = 'zip'; - - if ( $cgi->param('ignore_plus4') ) { - $zip = strip_plus4('zip'); - } else { - $zip = fieldorempty('zip'); - } - -} - -# construct the queries and send 'em off - -my $sql_query = - "SELECT $zip AS zipcode, - COUNT(*) AS num_cust - FROM cust_main - $where - GROUP BY zipcode - ORDER BY num_cust DESC - "; - -my $count_sql = "select count(distinct $czip) from cust_main $where"; - -# XXX should link... - -%><%= include( 'elements/search.html', +% +% +%# XXX link to customers +% +%my @where = (); +% +%# select status +% +%if ( $cgi->param('status') =~ /^(prospect|uncancel|active|susp|cancel)$/ ) { +% my $method = $1.'_sql'; +% push @where, FS::cust_main->$method(); +%} +% +%# select agent +%# XXX this needs to be virtualized by agent too (like lots of stuff) +% +%my $agentnum = ''; +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $agentnum = $1; +% push @where, "cust_main.agentnum = $agentnum"; +%} +%my $where = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; +% +%# bill zip vs ship zip +% +%sub fieldorempty { +% my $field = shift; +% "CASE WHEN $field IS NULL THEN '' ELSE $field END"; +%} +% +%sub strip_plus4 { +% my $field = shift; +% "CASE WHEN $field is NULL +% THEN '' +% ELSE CASE WHEN $field LIKE '_____-____' +% THEN SUBSTRING($field FROM 1 FOR 5) +% ELSE $field +% END +% END"; +%} +% +%my( $zip, $czip); +%if ( $cgi->param('column') eq 'ship_zip' ) { +% +% my $casewhen_noship = +% "CASE WHEN ( ship_last IS NULL OR ship_last = '' ) THEN "; +% +% $czip = "$casewhen_noship zip ELSE ship_zip END"; +% +% if ( $cgi->param('ignore_plus4') ) { +% $zip = $casewhen_noship. strip_plus4('zip'). +% " ELSE ". strip_plus4('ship_zip'). ' END'; +% +% } else { +% $zip = $casewhen_noship. fieldorempty('zip'). +% " ELSE ". fieldorempty('ship_zip'). ' END'; +% } +% +%} else { +% +% $czip = 'zip'; +% +% if ( $cgi->param('ignore_plus4') ) { +% $zip = strip_plus4('zip'); +% } else { +% $zip = fieldorempty('zip'); +% } +% +%} +% +%# construct the queries and send 'em off +% +%my $sql_query = +% "SELECT $zip AS zipcode, +% COUNT(*) AS num_cust +% FROM cust_main +% $where +% GROUP BY zipcode +% ORDER BY num_cust DESC +% "; +% +%my $count_sql = "select count(distinct $czip) from cust_main $where"; +% +%# XXX should link... +% +% +<% include( 'elements/search.html', 'title' => 'Zip code Search Results', 'name' => 'zip codes', 'query' => $sql_query, diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index f6841a099..c484496e0 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -1,747 +1,745 @@ -<% +% +% +%my $conf = new FS::Conf; +%my $maxrecords = $conf->config('maxsearchrecordsperpage'); +% +%#my $cache; +% +%#my $monsterjoin = <<END; +%#cust_main left outer join ( +%# ( cust_pkg left outer join part_pkg using(pkgpart) +%# ) left outer join ( +%# ( +%# ( +%# ( cust_svc left outer join part_svc using (svcpart) +%# ) left outer join svc_acct using (svcnum) +%# ) left outer join svc_domain using(svcnum) +%# ) left outer join svc_forward using(svcnum) +%# ) using (pkgnum) +%#) using (custnum) +%#END +% +%#my $monsterjoin = <<END; +%#cust_main left outer join ( +%# ( cust_pkg left outer join part_pkg using(pkgpart) +%# ) left outer join ( +%# ( +%# ( +%# ( cust_svc left outer join part_svc using (svcpart) +%# ) left outer join ( +%# svc_acct left outer join ( +%# select svcnum, domain, catchall from svc_domain +%# ) as svc_acct_domsvc ( +%# svc_acct_svcnum, svc_acct_domain, svc_acct_catchall +%# ) on svc_acct.domsvc = svc_acct_domsvc.svc_acct_svcnum +%# ) using (svcnum) +%# ) left outer join svc_domain using(svcnum) +%# ) left outer join svc_forward using(svcnum) +%# ) using (pkgnum) +%#) using (custnum) +%#END +% +%my $limit = ''; +%$limit .= "LIMIT $maxrecords" if $maxrecords; +% +%my $offset = $cgi->param('offset') || 0; +%$limit .= " OFFSET $offset" if $offset; +% +%my $total = 0; +% +%my(@cust_main, $sortby, $orderby); +%my @select = (); +%my @addl_headers = (); +%my @addl_cols = (); +%if ( $cgi->param('browse') +% || $cgi->param('otaker_on') +% || $cgi->param('agentnum_on') +%) { +% +% my %search = (); +% +% if ( $cgi->param('browse') ) { +% my $query = $cgi->param('browse'); +% if ( $query eq 'custnum' ) { +% $sortby=\*custnum_sort; +% $orderby = "ORDER BY custnum"; +% } elsif ( $query eq 'last' ) { +% $sortby=\*last_sort; +% $orderby = "ORDER BY LOWER(last || ' ' || first)"; +% } elsif ( $query eq 'company' ) { +% $sortby=\*company_sort; +% $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; +% } elsif ( $query eq 'tickets' ) { +% $sortby = \*tickets_sort; +% $orderby = "ORDER BY tickets DESC"; +% push @select, FS::TicketSystem->sql_num_customer_tickets. " as tickets"; +% push @addl_headers, 'Tickets'; +% push @addl_cols, 'tickets'; +% } else { +% die "unknown browse field $query"; +% } +% } else { +% $sortby = \*last_sort; #?? +% $orderby = "ORDER BY LOWER(last || ' ' || first)"; #?? +% } +% +% if ( $cgi->param('otaker_on') ) { +% $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; +% $search{otaker} = $1; +% } elsif ( $cgi->param('agentnum_on') ) { +% $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; +% $search{agentnum} = $1; +%# } else { +%# die "unknown query..."; +% } +% +% my @qual = (); +% +% my $ncancelled = ''; +% +% if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me +% || ( $conf->exists('hidecancelledcustomers') +% && ! $cgi->param('showcancelledcustomers') ) +% ) { +% #grep { $_->ncancelled_pkgs || ! $_->all_pkgs } +% push @qual, FS::cust_main->uncancel_sql; +% +% } +% +% push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled'); +% push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect'); +% push @qual, FS::cust_main->active_sql if $cgi->param('active'); +% push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive'); +% push @qual, FS::cust_main->susp_sql if $cgi->param('suspended'); +% +% #EWWWWWW +% my $qual = join(' AND ', +% map { "$_ = ". dbh->quote($search{$_}) } keys %search ); +% +% my $addl_qual = join(' AND ', @qual); +% +% #here is the agent virtualization +% $addl_qual .= ( $addl_qual ? ' AND ' : '' ). +% $FS::CurrentUser::CurrentUser->agentnums_sql; +% +% if ( $addl_qual ) { +% $qual .= ' AND ' if $qual; +% $qual .= $addl_qual; +% } +% +% $qual = " WHERE $qual" if $qual; +% my $statement = "SELECT COUNT(*) FROM cust_main $qual"; +% my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; +% $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; +% +% $total = $sth->fetchrow_arrayref->[0]; +% +% if ( $addl_qual ) { +% if ( %search ) { +% $addl_qual = " AND $addl_qual"; +% } else { +% $addl_qual = " WHERE $addl_qual"; +% } +% } +% +% my $select; +% if ( @select ) { +% $select = 'cust_main.*, '. join (', ', @select); +% } else { +% $select = '*'; +% } +% +% @cust_main = qsearch('cust_main', \%search, $select, +% "$addl_qual $orderby $limit" ); +% +%# foreach my $cust_main ( @just_cust_main ) { +%# +%# my @one_cust_main; +%# $FS::Record::DEBUG=1; +%# ( $cache, @one_cust_main ) = jsearch( +%# "$monsterjoin", +%# { 'custnum' => $cust_main->custnum }, +%# '', +%# '', +%# 'cust_main', +%# 'custnum', +%# ); +%# push @cust_main, @one_cust_main; +%# } +% +%} else { +% @cust_main=(); +% $sortby = \*last_sort; +% +% push @cust_main, @{&custnumsearch} +% if $cgi->param('custnum_on') && $cgi->param('custnum_text'); +% push @cust_main, @{&cardsearch} +% if $cgi->param('card_on') && $cgi->param('card'); +% push @cust_main, @{&lastsearch} +% if $cgi->param('last_on') && $cgi->param('last_text'); +% push @cust_main, @{&companysearch} +% if $cgi->param('company_on') && $cgi->param('company_text'); +% push @cust_main, @{&address2search} +% if $cgi->param('address2_on') && $cgi->param('address2_text'); +% push @cust_main, @{&phonesearch} +% if $cgi->param('phone_on') && $cgi->param('phone_text'); +% push @cust_main, @{&referralsearch} +% if $cgi->param('referral_custnum'); +% +% if ( $cgi->param('company_on') && $cgi->param('company_text') ) { +% $sortby = \*company_sort; +% push @cust_main, @{&companysearch}; +% } +% +% if ( $cgi->param('search_cust') ) { +% $sortby = \*company_sort; +% $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; +% warn "smart searching for: ". $cgi->param('search_cust'); +% push @cust_main, smart_search( 'search' => $cgi->param('search_cust') ); +% } +% +% @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main +% if ! $cgi->param('cancelled') +% && ( +% $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me +% || ( $conf->exists('hidecancelledcustomers') +% && ! $cgi->param('showcancelledcustomers') ) +% ); +% +% my %saw = (); +% @cust_main = grep { !$saw{$_->custnum}++ } @cust_main; +%} +% +%my %all_pkgs; +%if ( $conf->exists('hidecancelledpackages' ) ) { +% %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main; +%} else { +% %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main; +%} +%#%all_pkgs = (); +% +%if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { +% if ( $cgi->param('quickpay') eq 'yes' ) { +% print $cgi->redirect(popurl(2). "edit/cust_pay.cgi?quickpay=yes;custnum=". $cust_main[0]->custnum); +% } else { +% print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum); +% } +% #exit; +%} elsif ( scalar(@cust_main) == 0 ) { +% -my $conf = new FS::Conf; -my $maxrecords = $conf->config('maxsearchrecordsperpage'); - -#my $cache; - -#my $monsterjoin = <<END; -#cust_main left outer join ( -# ( cust_pkg left outer join part_pkg using(pkgpart) -# ) left outer join ( -# ( -# ( -# ( cust_svc left outer join part_svc using (svcpart) -# ) left outer join svc_acct using (svcnum) -# ) left outer join svc_domain using(svcnum) -# ) left outer join svc_forward using(svcnum) -# ) using (pkgnum) -#) using (custnum) -#END - -#my $monsterjoin = <<END; -#cust_main left outer join ( -# ( cust_pkg left outer join part_pkg using(pkgpart) -# ) left outer join ( -# ( -# ( -# ( cust_svc left outer join part_svc using (svcpart) -# ) left outer join ( -# svc_acct left outer join ( -# select svcnum, domain, catchall from svc_domain -# ) as svc_acct_domsvc ( -# svc_acct_svcnum, svc_acct_domain, svc_acct_catchall -# ) on svc_acct.domsvc = svc_acct_domsvc.svc_acct_svcnum -# ) using (svcnum) -# ) left outer join svc_domain using(svcnum) -# ) left outer join svc_forward using(svcnum) -# ) using (pkgnum) -#) using (custnum) -#END - -my $limit = ''; -$limit .= "LIMIT $maxrecords" if $maxrecords; - -my $offset = $cgi->param('offset') || 0; -$limit .= " OFFSET $offset" if $offset; - -my $total = 0; - -my(@cust_main, $sortby, $orderby); -my @select = (); -my @addl_headers = (); -my @addl_cols = (); -if ( $cgi->param('browse') - || $cgi->param('otaker_on') - || $cgi->param('agentnum_on') -) { - - my %search = (); - - if ( $cgi->param('browse') ) { - my $query = $cgi->param('browse'); - if ( $query eq 'custnum' ) { - $sortby=\*custnum_sort; - $orderby = "ORDER BY custnum"; - } elsif ( $query eq 'last' ) { - $sortby=\*last_sort; - $orderby = "ORDER BY LOWER(last || ' ' || first)"; - } elsif ( $query eq 'company' ) { - $sortby=\*company_sort; - $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; - } elsif ( $query eq 'tickets' ) { - $sortby = \*tickets_sort; - $orderby = "ORDER BY tickets DESC"; - push @select, FS::TicketSystem->sql_num_customer_tickets. " as tickets"; - push @addl_headers, 'Tickets'; - push @addl_cols, 'tickets'; - } else { - die "unknown browse field $query"; - } - } else { - $sortby = \*last_sort; #?? - $orderby = "ORDER BY LOWER(last || ' ' || first)"; #?? - } - - if ( $cgi->param('otaker_on') ) { - $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; - $search{otaker} = $1; - } elsif ( $cgi->param('agentnum_on') ) { - $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; - $search{agentnum} = $1; -# } else { -# die "unknown query..."; - } - - my @qual = (); - - my $ncancelled = ''; - - if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me - || ( $conf->exists('hidecancelledcustomers') - && ! $cgi->param('showcancelledcustomers') ) - ) { - #grep { $_->ncancelled_pkgs || ! $_->all_pkgs } - push @qual, FS::cust_main->uncancel_sql; - - } - - push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled'); - push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect'); - push @qual, FS::cust_main->active_sql if $cgi->param('active'); - push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive'); - push @qual, FS::cust_main->susp_sql if $cgi->param('suspended'); - - #EWWWWWW - my $qual = join(' AND ', - map { "$_ = ". dbh->quote($search{$_}) } keys %search ); - - my $addl_qual = join(' AND ', @qual); - - #here is the agent virtualization - $addl_qual .= ( $addl_qual ? ' AND ' : '' ). - $FS::CurrentUser::CurrentUser->agentnums_sql; - - if ( $addl_qual ) { - $qual .= ' AND ' if $qual; - $qual .= $addl_qual; - } - - $qual = " WHERE $qual" if $qual; - my $statement = "SELECT COUNT(*) FROM cust_main $qual"; - my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; - $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; - - $total = $sth->fetchrow_arrayref->[0]; - - if ( $addl_qual ) { - if ( %search ) { - $addl_qual = " AND $addl_qual"; - } else { - $addl_qual = " WHERE $addl_qual"; - } - } - - my $select; - if ( @select ) { - $select = 'cust_main.*, '. join (', ', @select); - } else { - $select = '*'; - } - - @cust_main = qsearch('cust_main', \%search, $select, - "$addl_qual $orderby $limit" ); - -# foreach my $cust_main ( @just_cust_main ) { -# -# my @one_cust_main; -# $FS::Record::DEBUG=1; -# ( $cache, @one_cust_main ) = jsearch( -# "$monsterjoin", -# { 'custnum' => $cust_main->custnum }, -# '', -# '', -# 'cust_main', -# 'custnum', -# ); -# push @cust_main, @one_cust_main; -# } - -} else { - @cust_main=(); - $sortby = \*last_sort; - - push @cust_main, @{&custnumsearch} - if $cgi->param('custnum_on') && $cgi->param('custnum_text'); - push @cust_main, @{&cardsearch} - if $cgi->param('card_on') && $cgi->param('card'); - push @cust_main, @{&lastsearch} - if $cgi->param('last_on') && $cgi->param('last_text'); - push @cust_main, @{&companysearch} - if $cgi->param('company_on') && $cgi->param('company_text'); - push @cust_main, @{&address2search} - if $cgi->param('address2_on') && $cgi->param('address2_text'); - push @cust_main, @{&phonesearch} - if $cgi->param('phone_on') && $cgi->param('phone_text'); - push @cust_main, @{&referralsearch} - if $cgi->param('referral_custnum'); - - if ( $cgi->param('company_on') && $cgi->param('company_text') ) { - $sortby = \*company_sort; - push @cust_main, @{&companysearch}; - } - - if ( $cgi->param('search_cust') ) { - $sortby = \*company_sort; - $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; - warn "smart searching for: ". $cgi->param('search_cust'); - push @cust_main, smart_search( 'search' => $cgi->param('search_cust') ); - } - - @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main - if ! $cgi->param('cancelled') - && ( - $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me - || ( $conf->exists('hidecancelledcustomers') - && ! $cgi->param('showcancelledcustomers') ) - ); - - my %saw = (); - @cust_main = grep { !$saw{$_->custnum}++ } @cust_main; -} - -my %all_pkgs; -if ( $conf->exists('hidecancelledpackages' ) ) { - %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main; -} else { - %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main; -} -#%all_pkgs = (); - -if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { - if ( $cgi->param('quickpay') eq 'yes' ) { - print $cgi->redirect(popurl(2). "edit/cust_pay.cgi?quickpay=yes;custnum=". $cust_main[0]->custnum); - } else { - print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum); - } - #exit; -} elsif ( scalar(@cust_main) == 0 ) { -%> <!-- mason kludge --> -<% - eidiot "No matching customers found!\n"; -} else { -%> -<%= include('/elements/header.html', "Customer Search Results", '' ) %> - - <% $total ||= scalar(@cust_main); %> - - <%= $total %> matching customers found - - <% - #begin pager - my $pager = ''; - if ( $total != scalar(@cust_main) && $maxrecords ) { - unless ( $offset == 0 ) { - $cgi->param('offset', $offset - $maxrecords); - $pager .= '<A HREF="'. $cgi->self_url. - '"><B><FONT SIZE="+1">Previous</FONT></B></A> '; - } - my $poff; - my $page; - for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { - $page++; - if ( $offset == $poff ) { - $pager .= qq!<FONT SIZE="+2">$page</FONT> !; - } else { - $cgi->param('offset', $poff); - $pager .= qq!<A HREF="!. $cgi->self_url. qq!">$page</A> !; - } - } - unless ( $offset + $maxrecords > $total ) { - $cgi->param('offset', $offset + $maxrecords); - $pager .= '<A HREF="'. $cgi->self_url. - '"><B><FONT SIZE="+1">Next</FONT></B></A> '; - } - } - #end pager - - unless ( $cgi->param('cancelled') ) { - if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me - || ( $conf->exists('hidecancelledcustomers') - && ! $cgi->param('showcancelledcustomers') - ) - ) { - $cgi->param('showcancelledcustomers', 1); - $cgi->param('offset', 0); - print qq!( <a href="!. $cgi->self_url. qq!">show!; - } else { - $cgi->param('showcancelledcustomers', 0); - $cgi->param('offset', 0); - print qq!( <a href="!. $cgi->self_url. qq!">hide!; - } - print ' cancelled customers</a> )'; - } - - if ( $cgi->param('referral_custnum') ) { - $cgi->param('referral_custnum') =~ /^(\d+)$/ - or eidiot "Illegal referral_custnum\n"; - my $referral_custnum = $1; - my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } ); - print '<FORM METHOD="GET">'. - qq!<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="$referral_custnum">!. - 'referrals of <A HREF="'. popurl(2). - "view/cust_main.cgi?$referral_custnum\">$referral_custnum: ". - ( $cust_main->company - || $cust_main->last. ', '. $cust_main->first ). - '</A>'; - print "\n",<<END; - <SCRIPT> - function changed(what) { - what.form.submit(); - } - </SCRIPT> -END - print ' <SELECT NAME="referral_depth" SIZE="1" onChange="changed(this)">'; - my $max = 8; #config file - $cgi->param('referral_depth') =~ /^(\d*)$/ - or eidiot "Illegal referral_depth"; - my $referral_depth = $1; - - foreach my $depth ( 1 .. $max ) { - print '<OPTION', - ' SELECTED'x($depth == $referral_depth), - ">$depth"; - } - print "</SELECT> levels deep". - '<NOSCRIPT> <INPUT TYPE="submit" VALUE="change"></NOSCRIPT>'. - '</FORM>'; - } - - my @custom_priorities = (); - if ( $conf->config('ticket_system-custom_priority_field') - && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) { - @custom_priorities = - $conf->config('ticket_system-custom_priority_field-values'); - } - - print "<BR><BR>". $pager. include('/elements/table-grid.html'). <<END; - <TR> - <TH CLASS="grid" BGCOLOR="#cccccc"></TH> - <TH CLASS="grid" BGCOLOR="#cccccc">(bill) name</TH> - <TH CLASS="grid" BGCOLOR="#cccccc">company</TH> -END - -if ( defined dbdef->table('cust_main')->column('ship_last') ) { - print <<END; - <TH CLASS="grid" BGCOLOR="#cccccc">(service) name</TH> - <TH CLASS="grid" BGCOLOR="#cccccc">company</TH> -END -} - -foreach my $addl_header ( @addl_headers ) { - print '<TH CLASS="grid" BGCOLOR="#cccccc">'. "$addl_header</TH>"; -} - -print <<END; - <TH CLASS="grid" BGCOLOR="#cccccc">Packages</TH> - <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2>Services</TH> - </TR> -END +% +% eidiot "No matching customers found!\n"; +%} else { +% + +<% include('/elements/header.html', "Customer Search Results", '' ) %> +% $total ||= scalar(@cust_main); + + + <% $total %> matching customers found +% +% #begin pager +% my $pager = ''; +% if ( $total != scalar(@cust_main) && $maxrecords ) { +% unless ( $offset == 0 ) { +% $cgi->param('offset', $offset - $maxrecords); +% $pager .= '<A HREF="'. $cgi->self_url. +% '"><B><FONT SIZE="+1">Previous</FONT></B></A> '; +% } +% my $poff; +% my $page; +% for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { +% $page++; +% if ( $offset == $poff ) { +% $pager .= qq!<FONT SIZE="+2">$page</FONT> !; +% } else { +% $cgi->param('offset', $poff); +% $pager .= qq!<A HREF="!. $cgi->self_url. qq!">$page</A> !; +% } +% } +% unless ( $offset + $maxrecords > $total ) { +% $cgi->param('offset', $offset + $maxrecords); +% $pager .= '<A HREF="'. $cgi->self_url. +% '"><B><FONT SIZE="+1">Next</FONT></B></A> '; +% } +% } +% #end pager +% +% unless ( $cgi->param('cancelled') ) { +% if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me +% || ( $conf->exists('hidecancelledcustomers') +% && ! $cgi->param('showcancelledcustomers') +% ) +% ) { +% $cgi->param('showcancelledcustomers', 1); +% $cgi->param('offset', 0); +% print qq!( <a href="!. $cgi->self_url. qq!">show!; +% } else { +% $cgi->param('showcancelledcustomers', 0); +% $cgi->param('offset', 0); +% print qq!( <a href="!. $cgi->self_url. qq!">hide!; +% } +% print ' cancelled customers</a> )'; +% } +% +% if ( $cgi->param('referral_custnum') ) { +% $cgi->param('referral_custnum') =~ /^(\d+)$/ +% or eidiot "Illegal referral_custnum\n"; +% my $referral_custnum = $1; +% my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } ); +% print '<FORM METHOD="GET">'. +% qq!<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="$referral_custnum">!. +% 'referrals of <A HREF="'. popurl(2). +% "view/cust_main.cgi?$referral_custnum\">$referral_custnum: ". +% ( $cust_main->company +% || $cust_main->last. ', '. $cust_main->first ). +% '</A>'; +% print "\n",<<END; +% <SCRIPT> +% function changed(what) { +% what.form.submit(); +% } +% </SCRIPT> +%END +% print ' <SELECT NAME="referral_depth" SIZE="1" onChange="changed(this)">'; +% my $max = 8; #config file +% $cgi->param('referral_depth') =~ /^(\d*)$/ +% or eidiot "Illegal referral_depth"; +% my $referral_depth = $1; +% +% foreach my $depth ( 1 .. $max ) { +% print '<OPTION', +% ' SELECTED'x($depth == $referral_depth), +% ">$depth"; +% } +% print "</SELECT> levels deep". +% '<NOSCRIPT> <INPUT TYPE="submit" VALUE="change"></NOSCRIPT>'. +% '</FORM>'; +% } +% +% my @custom_priorities = (); +% if ( $conf->config('ticket_system-custom_priority_field') +% && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) { +% @custom_priorities = +% $conf->config('ticket_system-custom_priority_field-values'); +% } +% +% print "<BR><BR>". $pager. include('/elements/table-grid.html'). <<END; +% <TR> +% <TH CLASS="grid" BGCOLOR="#cccccc"></TH> +% <TH CLASS="grid" BGCOLOR="#cccccc">(bill) name</TH> +% <TH CLASS="grid" BGCOLOR="#cccccc">company</TH> +%END +% +%if ( defined dbdef->table('cust_main')->column('ship_last') ) { +% print <<END; +% <TH CLASS="grid" BGCOLOR="#cccccc">(service) name</TH> +% <TH CLASS="grid" BGCOLOR="#cccccc">company</TH> +%END +%} +% +%foreach my $addl_header ( @addl_headers ) { +% print '<TH CLASS="grid" BGCOLOR="#cccccc">'. "$addl_header</TH>"; +%} +% +%print <<END; +% <TH CLASS="grid" BGCOLOR="#cccccc">Packages</TH> +% <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2>Services</TH> +% </TR> +%END +% +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor; +% +% my(%saw,$cust_main); +% foreach $cust_main ( +% sort $sortby grep(!$saw{$_->custnum}++, @cust_main) +% ) { +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% my($custnum,$last,$first,$company)=( +% $cust_main->custnum, +% $cust_main->getfield('last'), +% $cust_main->getfield('first'), +% $cust_main->company, +% ); +% +% my(@lol_cust_svc); +% my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} ); +% foreach ( @{$all_pkgs{$custnum}} ) { +% #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); +% my @cust_svc = $_->cust_svc; +% push @lol_cust_svc, \@cust_svc; +% $rowspan += scalar(@cust_svc) || 1; +% } +% +% #my($rowspan) = scalar(@{$all_pkgs{$custnum}}); +% my $view; +% if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) { +% $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum; +% } else { +% $view = $p. 'view/cust_main.cgi?'. $custnum; +% } +% my $pcompany = $company +% ? qq!<A HREF="$view"><FONT SIZE=-1>$company</FONT></A>! +% : '<FONT SIZE=-1> </FONT>'; +% - my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor; - - my(%saw,$cust_main); - foreach $cust_main ( - sort $sortby grep(!$saw{$_->custnum}++, @cust_main) - ) { - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - - my($custnum,$last,$first,$company)=( - $cust_main->custnum, - $cust_main->getfield('last'), - $cust_main->getfield('first'), - $cust_main->company, - ); - - my(@lol_cust_svc); - my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} ); - foreach ( @{$all_pkgs{$custnum}} ) { - #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); - my @cust_svc = $_->cust_svc; - push @lol_cust_svc, \@cust_svc; - $rowspan += scalar(@cust_svc) || 1; - } - - #my($rowspan) = scalar(@{$all_pkgs{$custnum}}); - my $view; - if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) { - $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum; - } else { - $view = $p. 'view/cust_main.cgi?'. $custnum; - } - my $pcompany = $company - ? qq!<A HREF="$view"><FONT SIZE=-1>$company</FONT></A>! - : '<FONT SIZE=-1> </FONT>'; - %> <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %>><A HREF="<%= $view %>"><FONT SIZE=-1><%= $custnum %></FONT></A></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %>><A HREF="<%= $view %>"><FONT SIZE=-1><%= "$last, $first" %></FONT></A></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %>><%= $pcompany %></TD> - - <% - if ( defined dbdef->table('cust_main')->column('ship_last') ) { - my($ship_last,$ship_first,$ship_company)=( - $cust_main->ship_last || $cust_main->getfield('last'), - $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first, - $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company, - ); - my $pship_company = $ship_company - ? qq!<A HREF="$view"><FONT SIZE=-1>$ship_company</FONT></A>! - : '<FONT SIZE=-1> </FONT>'; - %> - - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %>><A HREF="<%= $view %>"><FONT SIZE=-1><%= "$ship_last, $ship_first" %></FONT></A></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %>><%= $pship_company %></A></TD> - - <% } - - foreach my $addl_col ( @addl_cols ) { %> - - <% if ( $addl_col eq 'tickets' ) { %> - - <% if ( @custom_priorities ) { %> - - <TD CLASS="inv" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %> ALIGN=right><FONT SIZE=-1> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% $custnum %></FONT></A></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" %></FONT></A></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pcompany %></TD> +% +% if ( defined dbdef->table('cust_main')->column('ship_last') ) { +% my($ship_last,$ship_first,$ship_company)=( +% $cust_main->ship_last || $cust_main->getfield('last'), +% $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first, +% $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company, +% ); +% my $pship_company = $ship_company +% ? qq!<A HREF="$view"><FONT SIZE=-1>$ship_company</FONT></A>! +% : '<FONT SIZE=-1> </FONT>'; +% + + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$ship_last, $ship_first" %></FONT></A></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pship_company %></A></TD> +% } +% +% foreach my $addl_col ( @addl_cols ) { +% if ( $addl_col eq 'tickets' ) { +% if ( @custom_priorities ) { + + + <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1> <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0> +% 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, '' ) { %> - - <% - my $num = - FS::TicketSystem->num_customer_tickets($custnum,$priority); - my $ahref = ''; - $ahref= '<A HREF="'. - FS::TicketSystem->href_customer_tickets($custnum,$priority). - '">' - if $num; - %> <TR> <TD ALIGN=right> - <FONT SIZE=-1><%= $ahref.$num %></A></FONT> + <FONT SIZE=-1><% $ahref.$num %></A></FONT> </TD> <TD ALIGN=left> - <FONT SIZE=-1><%= $ahref %><%= $priority || '<i>(none)</i>' %></A></FONT> + <FONT SIZE=-1><% $ahref %><% $priority || '<i>(none)</i>' %></A></FONT> </TD> </TR> - - <% } %> +% } + <TR> <TH ALIGN=right STYLE="border-top: dashed 1px black"> <FONT SIZE=-1> +% } else { - <% } else { %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %> ALIGN=right><FONT SIZE=-1> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1> +% } +% +% my $ahref = ''; +% $ahref = '<A HREF="'. +% FS::TicketSystem->href_customer_tickets($custnum). +% '">' +% if $cust_main->get($addl_col); +% - <% } %> - <% - my $ahref = ''; - $ahref = '<A HREF="'. - FS::TicketSystem->href_customer_tickets($custnum). - '">' - if $cust_main->get($addl_col); - %> + <% $ahref %><% $cust_main->get($addl_col) %></A> +% if ( @custom_priorities ) { - <%= $ahref %><%= $cust_main->get($addl_col) %></A> - - <% if ( @custom_priorities ) { %> </FONT></TH> <TH ALIGN=left STYLE="border-top: dashed 1px black"> - <FONT SIZE=-1><%= ${ahref} %>Total</A><FONT> + <FONT SIZE=-1><% ${ahref} %>Total</A><FONT> </TH> </TR> </TABLE> +% } - <% } %> </FONT></TD> +% } else { - <% } else { %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %> ALIGN=right><FONT SIZE=-1> - <%= $cust_main->get($addl_col) %> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1> + <% $cust_main->get($addl_col) %> </FONT></TD> +% +% } +% } +% +% my($n1)=''; +% foreach ( @{$all_pkgs{$custnum}} ) { +% my $pkgnum = $_->pkgnum; +%# my $part_pkg = qsearchs( 'part_pkg', { pkgpart => $_->pkgpart } ); +% my $part_pkg = $_->part_pkg; +% +% my $pkg = $part_pkg->pkg; +% my $comment = $part_pkg->comment; +% my $pkgview = "${p}view/cust_main.cgi?$custnum#cust_pkg$pkgnum"; +% my @cust_svc = @{shift @lol_cust_svc}; +% #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); +% my $rowspan = scalar(@cust_svc) || 1; +% +% print $n1, qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ROWSPAN=$rowspan><A HREF="$pkgview"><FONT SIZE=-1>$pkg - $comment</FONT></A></TD>!; +% +% my($n2)=''; +% foreach my $cust_svc ( @cust_svc ) { +% my($label, $value, $svcdb) = $cust_svc->label; +% my($svcnum) = $cust_svc->svcnum; +% my($sview) = $p.'view'; +% print $n2,qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!, +% qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!; +% $n2="</TR><TR>"; +% } +% +% unless ( @cust_svc ) { +% print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=2> </TD>!; +% } +% +% #print qq!</TR><TR>\n!; +% $n1="</TR><TR>"; +% } +% +% unless ( @{$all_pkgs{$custnum}} ) { +% print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=3> </TD>!; +% } +% +% print "</TR>"; +% } +% +% -<% - } - } - - my($n1)=''; - foreach ( @{$all_pkgs{$custnum}} ) { - my $pkgnum = $_->pkgnum; -# my $part_pkg = qsearchs( 'part_pkg', { pkgpart => $_->pkgpart } ); - my $part_pkg = $_->part_pkg; - - my $pkg = $part_pkg->pkg; - my $comment = $part_pkg->comment; - my $pkgview = "${p}view/cust_main.cgi?$custnum#cust_pkg$pkgnum"; - my @cust_svc = @{shift @lol_cust_svc}; - #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); - my $rowspan = scalar(@cust_svc) || 1; - - print $n1, qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ROWSPAN=$rowspan><A HREF="$pkgview"><FONT SIZE=-1>$pkg - $comment</FONT></A></TD>!; - - my($n2)=''; - foreach my $cust_svc ( @cust_svc ) { - my($label, $value, $svcdb) = $cust_svc->label; - my($svcnum) = $cust_svc->svcnum; - my($sview) = $p.'view'; - print $n2,qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!, - qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!; - $n2="</TR><TR>"; - } - - unless ( @cust_svc ) { - print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=2> </TD>!; - } - - #print qq!</TR><TR>\n!; - $n1="</TR><TR>"; - } - - unless ( @{$all_pkgs{$custnum}} ) { - print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=3> </TD>!; - } - - print "</TR>"; - } - - %> - </TABLE><%= $pager %> - - <%= include('/elements/footer.html') %> - -<% } - -#undef $cache; #does this help? - -# - -sub last_sort { - lc($a->getfield('last')) cmp lc($b->getfield('last')) - || lc($a->first) cmp lc($b->first); -} - -sub company_sort { - return -1 if $a->company && ! $b->company; - return 1 if ! $a->company && $b->company; - lc($a->company) cmp lc($b->company) - || lc($a->getfield('last')) cmp lc($b->getfield('last')) - || lc($a->first) cmp lc($b->first);; -} - -sub custnum_sort { - $a->getfield('custnum') <=> $b->getfield('custnum'); -} - -sub tickets_sort { - $b->getfield('tickets') <=> $a->getfield('tickets'); -} - -sub custnumsearch { - - my $custnum = $cgi->param('custnum_text'); - $custnum =~ s/\D//g; - $custnum =~ /^(\d{1,23})$/ or eidiot "Illegal customer number\n"; - $custnum = $1; - - [ qsearchs('cust_main', { 'custnum' => $custnum } ) ]; -} - -sub cardsearch { - - my($card)=$cgi->param('card'); - $card =~ s/\D//g; - $card =~ /^(\d{13,16})$/ or eidiot "Illegal card number\n"; - my($payinfo)=$1; - - [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}), - qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'}) - ]; -} - -sub referralsearch { - $cgi->param('referral_custnum') =~ /^(\d+)$/ - or eidiot "Illegal referral_custnum"; - my $cust_main = qsearchs('cust_main', { 'custnum' => $1 } ) - or eidiot "Customer $1 not found"; - my $depth; - if ( $cgi->param('referral_depth') ) { - $cgi->param('referral_depth') =~ /^(\d+)$/ - or eidiot "Illegal referral_depth"; - $depth = $1; - } else { - $depth = 1; - } - [ $cust_main->referral_cust_main($depth) ]; -} - -sub lastsearch { - my(%last_type); - my @cust_main; - foreach ( $cgi->param('last_type') ) { - $last_type{$_}++; - } - - $cgi->param('last_text') =~ /^([\w \,\.\-\']*)$/ - or eidiot "Illegal last name"; - my($last)=$1; - - if ( $last_type{'Exact'} || $last_type{'Fuzzy'} ) { - push @cust_main, qsearch( 'cust_main', - { 'last' => { 'op' => 'ILIKE', - 'value' => $last } } ); - - push @cust_main, qsearch( 'cust_main', - { 'ship_last' => { 'op' => 'ILIKE', - 'value' => $last } } ) - if defined dbdef->table('cust_main')->column('ship_last'); - } - - if ( $last_type{'Substring'} || $last_type{'All'} ) { - - push @cust_main, qsearch( 'cust_main', - { 'last' => { 'op' => 'ILIKE', - 'value' => "%$last%" } } ); - - push @cust_main, qsearch( 'cust_main', - { 'ship_last' => { 'op' => 'ILIKE', - 'value' => "%$last%" } } ) - if defined dbdef->table('cust_main')->column('ship_last'); - - } - - if ( $last_type{'Fuzzy'} || $last_type{'All'} ) { - push @cust_main, FS::cust_main->fuzzy_search( { 'last' => $last } ); - } - - #if ($last_type{'Sound-alike'}) { - #} - - \@cust_main; -} - -sub companysearch { - - my(%company_type); - my @cust_main; - foreach ( $cgi->param('company_type') ) { - $company_type{$_}++ - }; - - $cgi->param('company_text') =~ - /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/ - or eidiot "Illegal company"; - my $company = $1; - - if ( $company_type{'Exact'} || $company_type{'Fuzzy'} ) { - push @cust_main, qsearch( 'cust_main', - { 'company' => { 'op' => 'ILIKE', - 'value' => $company } } ); - - push @cust_main, qsearch( 'cust_main', - { 'ship_company' => { 'op' => 'ILIKE', - 'value' => $company } } ) - if defined dbdef->table('cust_main')->column('ship_last'); - } - - if ( $company_type{'Substring'} || $company_type{'All'} ) { - - push @cust_main, qsearch( 'cust_main', - { 'company' => { 'op' => 'ILIKE', - 'value' => "%$company%" } } ); - - push @cust_main, qsearch( 'cust_main', - { 'ship_company' => { 'op' => 'ILIKE', - 'value' => "%$company%" } }) - if defined dbdef->table('cust_main')->column('ship_last'); - - } - - if ( $company_type{'Fuzzy'} || $company_type{'All'} ) { - push @cust_main, FS::cust_main->fuzzy_search( { 'company' => $company } ); - } - - if ($company_type{'Sound-alike'}) { - } - - \@cust_main; -} - -sub address2search { - my @cust_main; - - $cgi->param('address2_text') =~ - /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/ - or eidiot "Illegal address2"; - my $address2 = $1; - - push @cust_main, qsearch( 'cust_main', - { 'address2' => { 'op' => 'ILIKE', - 'value' => $address2 } } ); - push @cust_main, qsearch( 'cust_main', - { 'address2' => { 'op' => 'ILIKE', - 'value' => $address2 } } ) - if defined dbdef->table('cust_main')->column('ship_last'); - - \@cust_main; -} - -sub phonesearch { - my @cust_main; - - my $phone = $cgi->param('phone_text'); - - #(no longer really) false laziness with Record::ut_phonen - #only works with US/CA numbers... - $phone =~ s/\D//g; - if ( $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ ) { - $phone = "$1-$2-$3"; - $phone .= " x$4" if $4; - } elsif ( $phone =~ /^(\d{3})(\d{4})$/ ) { - $phone = "$1-$2"; - } elsif ( $phone =~ /^(\d{3,4})$/ ) { - $phone = $1; - } else { - eidiot gettext('illegal_phone'). ": $phone"; - } - - my @fields = qw(daytime night fax); - push @fields, qw(ship_daytime ship_night ship_fax) - if defined dbdef->table('cust_main')->column('ship_last'); - - for my $field ( @fields ) { - push @cust_main, qsearch ( 'cust_main', - { $field => { 'op' => 'LIKE', - 'value' => "%$phone%" } } ); - } - - \@cust_main; -} + </TABLE><% $pager %> + + <% include('/elements/footer.html') %> +% } +% +%#undef $cache; #does this help? +% +%# +% +%sub last_sort { +% lc($a->getfield('last')) cmp lc($b->getfield('last')) +% || lc($a->first) cmp lc($b->first); +%} +% +%sub company_sort { +% return -1 if $a->company && ! $b->company; +% return 1 if ! $a->company && $b->company; +% lc($a->company) cmp lc($b->company) +% || lc($a->getfield('last')) cmp lc($b->getfield('last')) +% || lc($a->first) cmp lc($b->first);; +%} +% +%sub custnum_sort { +% $a->getfield('custnum') <=> $b->getfield('custnum'); +%} +% +%sub tickets_sort { +% $b->getfield('tickets') <=> $a->getfield('tickets'); +%} +% +%sub custnumsearch { +% +% my $custnum = $cgi->param('custnum_text'); +% $custnum =~ s/\D//g; +% $custnum =~ /^(\d{1,23})$/ or eidiot "Illegal customer number\n"; +% $custnum = $1; +% +% [ qsearchs('cust_main', { 'custnum' => $custnum } ) ]; +%} +% +%sub cardsearch { +% +% my($card)=$cgi->param('card'); +% $card =~ s/\D//g; +% $card =~ /^(\d{13,16})$/ or eidiot "Illegal card number\n"; +% my($payinfo)=$1; +% +% [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}), +% qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'}) +% ]; +%} +% +%sub referralsearch { +% $cgi->param('referral_custnum') =~ /^(\d+)$/ +% or eidiot "Illegal referral_custnum"; +% my $cust_main = qsearchs('cust_main', { 'custnum' => $1 } ) +% or eidiot "Customer $1 not found"; +% my $depth; +% if ( $cgi->param('referral_depth') ) { +% $cgi->param('referral_depth') =~ /^(\d+)$/ +% or eidiot "Illegal referral_depth"; +% $depth = $1; +% } else { +% $depth = 1; +% } +% [ $cust_main->referral_cust_main($depth) ]; +%} +% +%sub lastsearch { +% my(%last_type); +% my @cust_main; +% foreach ( $cgi->param('last_type') ) { +% $last_type{$_}++; +% } +% +% $cgi->param('last_text') =~ /^([\w \,\.\-\']*)$/ +% or eidiot "Illegal last name"; +% my($last)=$1; +% +% if ( $last_type{'Exact'} || $last_type{'Fuzzy'} ) { +% push @cust_main, qsearch( 'cust_main', +% { 'last' => { 'op' => 'ILIKE', +% 'value' => $last } } ); +% +% push @cust_main, qsearch( 'cust_main', +% { 'ship_last' => { 'op' => 'ILIKE', +% 'value' => $last } } ) +% if defined dbdef->table('cust_main')->column('ship_last'); +% } +% +% if ( $last_type{'Substring'} || $last_type{'All'} ) { +% +% push @cust_main, qsearch( 'cust_main', +% { 'last' => { 'op' => 'ILIKE', +% 'value' => "%$last%" } } ); +% +% push @cust_main, qsearch( 'cust_main', +% { 'ship_last' => { 'op' => 'ILIKE', +% 'value' => "%$last%" } } ) +% if defined dbdef->table('cust_main')->column('ship_last'); +% +% } +% +% if ( $last_type{'Fuzzy'} || $last_type{'All'} ) { +% push @cust_main, FS::cust_main->fuzzy_search( { 'last' => $last } ); +% } +% +% #if ($last_type{'Sound-alike'}) { +% #} +% +% \@cust_main; +%} +% +%sub companysearch { +% +% my(%company_type); +% my @cust_main; +% foreach ( $cgi->param('company_type') ) { +% $company_type{$_}++ +% }; +% +% $cgi->param('company_text') =~ +% /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/ +% or eidiot "Illegal company"; +% my $company = $1; +% +% if ( $company_type{'Exact'} || $company_type{'Fuzzy'} ) { +% push @cust_main, qsearch( 'cust_main', +% { 'company' => { 'op' => 'ILIKE', +% 'value' => $company } } ); +% +% push @cust_main, qsearch( 'cust_main', +% { 'ship_company' => { 'op' => 'ILIKE', +% 'value' => $company } } ) +% if defined dbdef->table('cust_main')->column('ship_last'); +% } +% +% if ( $company_type{'Substring'} || $company_type{'All'} ) { +% +% push @cust_main, qsearch( 'cust_main', +% { 'company' => { 'op' => 'ILIKE', +% 'value' => "%$company%" } } ); +% +% push @cust_main, qsearch( 'cust_main', +% { 'ship_company' => { 'op' => 'ILIKE', +% 'value' => "%$company%" } }) +% if defined dbdef->table('cust_main')->column('ship_last'); +% +% } +% +% if ( $company_type{'Fuzzy'} || $company_type{'All'} ) { +% push @cust_main, FS::cust_main->fuzzy_search( { 'company' => $company } ); +% } +% +% if ($company_type{'Sound-alike'}) { +% } +% +% \@cust_main; +%} +% +%sub address2search { +% my @cust_main; +% +% $cgi->param('address2_text') =~ +% /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/ +% or eidiot "Illegal address2"; +% my $address2 = $1; +% +% push @cust_main, qsearch( 'cust_main', +% { 'address2' => { 'op' => 'ILIKE', +% 'value' => $address2 } } ); +% push @cust_main, qsearch( 'cust_main', +% { 'address2' => { 'op' => 'ILIKE', +% 'value' => $address2 } } ) +% if defined dbdef->table('cust_main')->column('ship_last'); +% +% \@cust_main; +%} +% +%sub phonesearch { +% my @cust_main; +% +% my $phone = $cgi->param('phone_text'); +% +% #(no longer really) false laziness with Record::ut_phonen +% #only works with US/CA numbers... +% $phone =~ s/\D//g; +% if ( $phone =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/ ) { +% $phone = "$1-$2-$3"; +% $phone .= " x$4" if $4; +% } elsif ( $phone =~ /^(\d{3})(\d{4})$/ ) { +% $phone = "$1-$2"; +% } elsif ( $phone =~ /^(\d{3,4})$/ ) { +% $phone = $1; +% } else { +% eidiot gettext('illegal_phone'). ": $phone"; +% } +% +% my @fields = qw(daytime night fax); +% push @fields, qw(ship_daytime ship_night ship_fax) +% if defined dbdef->table('cust_main')->column('ship_last'); +% +% for my $field ( @fields ) { +% push @cust_main, qsearch ( 'cust_main', +% { $field => { 'op' => 'LIKE', +% 'value' => "%$phone%" } } ); +% } +% +% \@cust_main; +%} +% +% -%> diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 0247b0b0d..0664bf796 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -1,152 +1,153 @@ -<% - my $title = 'Payment Search Results'; - my( $count_query, $sql_query ); - if ( $cgi->param('magic') ) { - - my @search = (); - my $orderby; - if ( $cgi->param('magic') eq '_date' ) { - - - if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { - push @search, "agentnum = $1"; # $search{'agentnum'} = $1; - my $agent = qsearchs('agent', { 'agentnum' => $1 } ); - die "unknown agentnum $1" unless $agent; - $title = $agent->agent. " $title"; - } - - if ( $cgi->param('payby') ) { - $cgi->param('payby') =~ - /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/ - or die "illegal payby ". $cgi->param('payby'); - push @search, "cust_pay.payby = '$1'"; - if ( $3 ) { - if ( $3 eq 'VisaMC' ) { - #avoid posix regexes for portability - push @search, - " ( ( substring(cust_pay.payinfo from 1 for 1) = '4' ". - " AND substring(cust_pay.payinfo from 1 for 4) != '4936' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49030[2-9]' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49033[5-9]' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49110[1-2]' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49117[4-9]' ". - " AND substring(cust_pay.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49118[1-2]' ". - " )". - " OR substring(cust_pay.payinfo from 1 for 2) = '51' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '52' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '53' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". - " OR substring(cust_pay.payinfo from 1 for 2) = '55' ". - " ) "; - } elsif ( $3 eq 'Amex' ) { - push @search, - " ( substring(cust_pay.payinfo from 1 for 2 ) = '34' ". - " OR substring(cust_pay.payinfo from 1 for 2 ) = '37' ". - " ) "; - } elsif ( $3 eq 'Discover' ) { - push @search, - " ( substring(cust_pay.payinfo from 1 for 4 ) = '6011' ". - " OR substring(cust_pay.payinfo from 1 for 3 ) = '650' ". - " ) "; - } elsif ( $3 eq 'Maestro' ) { - push @search, - " ( substring(cust_pay.payinfo from 1 for 2 ) = '63' ". - " OR substring(cust_pay.payinfo from 1 for 2 ) = '67' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ". - " OR substring(cust_pay.payinfo from 1 for 4 ) = '4936' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49030[2-9]' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49033[5-9]' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49110[1-2]' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49117[4-9]' ". - " OR substring(cust_pay.payinfo from 1 for 6 ) ". - " SIMILAR TO '49118[1-2]' ". - " ) "; - } else { - die "unknown card type $3"; - } - } - } - - my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - push @search, "_date >= $beginning ", - "_date <= $ending"; - - $orderby = '_date'; - - } elsif ( $cgi->param('magic') eq 'paybatch' ) { - - $cgi->param('paybatch') =~ /^([\w\/\:\-\.]+)$/ - or die "illegal paybatch: ". $cgi->param('paybatch'); - - push @search, "paybatch = '$1'"; - - $orderby = "LOWER(company || ' ' || last || ' ' || first )"; - - } else { - die "unknown search magic: ". $cgi->param('magic'); - } - - #here is the agent virtualization - push @search, $FS::CurrentUser::CurrentUser->agentnums_sql; - - my $search = ' WHERE '. join(' AND ', @search); - - $count_query = "SELECT COUNT(*), SUM(paid) ". - "FROM cust_pay LEFT JOIN cust_main USING ( custnum )". - $search; - - $sql_query = { - 'table' => 'cust_pay', - 'select' => join(', ', - 'cust_pay.*', - 'cust_main.custnum as cust_main_custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'hashref' => {}, - 'extra_sql' => "$search ORDER BY $orderby", - 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', - }; - - } else { - - $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; - my $payinfo = $1; - - $cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby"; - my $payby = $1; - - $count_query = "SELECT COUNT(*), SUM(paid) FROM cust_pay". - " WHERE payinfo = '$payinfo' AND payby = '$payby'". - " AND ". $FS::CurrentUser::CurrentUser->agentnums_sql; - - $sql_query = { - 'table' => 'cust_pay', - 'hashref' => { 'payinfo' => $payinfo, - 'payby' => $payby }, - 'extra_sql' => $FS::CurrentUser::CurrentUser->agentnums_sql. - " ORDER BY _date", - }; - - } - - my $link = sub { - my $cust_pay = shift; - $cust_pay->cust_main_custnum - ? [ "${p}view/cust_main.cgi?", 'custnum' ] - : ''; - }; - -%><%= include( 'elements/search.html', +% +% my $title = 'Payment Search Results'; +% my( $count_query, $sql_query ); +% if ( $cgi->param('magic') ) { +% +% my @search = (); +% my $orderby; +% if ( $cgi->param('magic') eq '_date' ) { +% +% +% if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% push @search, "agentnum = $1"; # $search{'agentnum'} = $1; +% my $agent = qsearchs('agent', { 'agentnum' => $1 } ); +% die "unknown agentnum $1" unless $agent; +% $title = $agent->agent. " $title"; +% } +% +% if ( $cgi->param('payby') ) { +% $cgi->param('payby') =~ +% /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/ +% or die "illegal payby ". $cgi->param('payby'); +% push @search, "cust_pay.payby = '$1'"; +% if ( $3 ) { +% if ( $3 eq 'VisaMC' ) { +% #avoid posix regexes for portability +% push @search, +% " ( ( substring(cust_pay.payinfo from 1 for 1) = '4' ". +% " AND substring(cust_pay.payinfo from 1 for 4) != '4936' ". +% " AND substring(cust_pay.payinfo from 1 for 6) ". +% " NOT SIMILAR TO '49030[2-9]' ". +% " AND substring(cust_pay.payinfo from 1 for 6) ". +% " NOT SIMILAR TO '49033[5-9]' ". +% " AND substring(cust_pay.payinfo from 1 for 6) ". +% " NOT SIMILAR TO '49110[1-2]' ". +% " AND substring(cust_pay.payinfo from 1 for 6) ". +% " NOT SIMILAR TO '49117[4-9]' ". +% " AND substring(cust_pay.payinfo from 1 for 6) ". +% " NOT SIMILAR TO '49118[1-2]' ". +% " )". +% " OR substring(cust_pay.payinfo from 1 for 2) = '51' ". +% " OR substring(cust_pay.payinfo from 1 for 2) = '52' ". +% " OR substring(cust_pay.payinfo from 1 for 2) = '53' ". +% " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". +% " OR substring(cust_pay.payinfo from 1 for 2) = '54' ". +% " OR substring(cust_pay.payinfo from 1 for 2) = '55' ". +% " ) "; +% } elsif ( $3 eq 'Amex' ) { +% push @search, +% " ( substring(cust_pay.payinfo from 1 for 2 ) = '34' ". +% " OR substring(cust_pay.payinfo from 1 for 2 ) = '37' ". +% " ) "; +% } elsif ( $3 eq 'Discover' ) { +% push @search, +% " ( substring(cust_pay.payinfo from 1 for 4 ) = '6011' ". +% " OR substring(cust_pay.payinfo from 1 for 3 ) = '650' ". +% " ) "; +% } elsif ( $3 eq 'Maestro' ) { +% push @search, +% " ( substring(cust_pay.payinfo from 1 for 2 ) = '63' ". +% " OR substring(cust_pay.payinfo from 1 for 2 ) = '67' ". +% " OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ". +% " OR substring(cust_pay.payinfo from 1 for 4 ) = '4936' ". +% " OR substring(cust_pay.payinfo from 1 for 6 ) ". +% " SIMILAR TO '49030[2-9]' ". +% " OR substring(cust_pay.payinfo from 1 for 6 ) ". +% " SIMILAR TO '49033[5-9]' ". +% " OR substring(cust_pay.payinfo from 1 for 6 ) ". +% " SIMILAR TO '49110[1-2]' ". +% " OR substring(cust_pay.payinfo from 1 for 6 ) ". +% " SIMILAR TO '49117[4-9]' ". +% " OR substring(cust_pay.payinfo from 1 for 6 ) ". +% " SIMILAR TO '49118[1-2]' ". +% " ) "; +% } else { +% die "unknown card type $3"; +% } +% } +% } +% +% my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +% push @search, "_date >= $beginning ", +% "_date <= $ending"; +% +% $orderby = '_date'; +% +% } elsif ( $cgi->param('magic') eq 'paybatch' ) { +% +% $cgi->param('paybatch') =~ /^([\w\/\:\-\.]+)$/ +% or die "illegal paybatch: ". $cgi->param('paybatch'); +% +% push @search, "paybatch = '$1'"; +% +% $orderby = "LOWER(company || ' ' || last || ' ' || first )"; +% +% } else { +% die "unknown search magic: ". $cgi->param('magic'); +% } +% +% #here is the agent virtualization +% push @search, $FS::CurrentUser::CurrentUser->agentnums_sql; +% +% my $search = ' WHERE '. join(' AND ', @search); +% +% $count_query = "SELECT COUNT(*), SUM(paid) ". +% "FROM cust_pay LEFT JOIN cust_main USING ( custnum )". +% $search; +% +% $sql_query = { +% 'table' => 'cust_pay', +% 'select' => join(', ', +% 'cust_pay.*', +% 'cust_main.custnum as cust_main_custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'hashref' => {}, +% 'extra_sql' => "$search ORDER BY $orderby", +% 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', +% }; +% +% } else { +% +% $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo"; +% my $payinfo = $1; +% +% $cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby"; +% my $payby = $1; +% +% $count_query = "SELECT COUNT(*), SUM(paid) FROM cust_pay". +% " WHERE payinfo = '$payinfo' AND payby = '$payby'". +% " AND ". $FS::CurrentUser::CurrentUser->agentnums_sql; +% +% $sql_query = { +% 'table' => 'cust_pay', +% 'hashref' => { 'payinfo' => $payinfo, +% 'payby' => $payby }, +% 'extra_sql' => $FS::CurrentUser::CurrentUser->agentnums_sql. +% " ORDER BY _date", +% }; +% +% } +% +% my $link = sub { +% my $cust_pay = shift; +% $cust_pay->cust_main_custnum +% ? [ "${p}view/cust_main.cgi?", 'custnum' ] +% : ''; +% }; +% +% +<% include( 'elements/search.html', 'title' => $title, 'name' => 'payments', 'query' => $sql_query, diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 614e9b509..8dbc600e9 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,209 +1,210 @@ -<% - -# my %part_pkg = map { $_->pkgpart => $_ } qsearch('part_pkg', {}); - -my($query) = $cgi->keywords; - -my @where = (); - -## -# parse agent -## - -if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { - push @where, - "agentnum = $1"; -} - -## -# parse status -## - -if ( $cgi->param('magic') eq 'active' - || $cgi->param('status') eq 'active' ) { - - push @where, FS::cust_pkg->active_sql(); - -} elsif ( $cgi->param('magic') eq 'inactive' - || $cgi->param('status') eq 'inactive' ) { - - push @where, FS::cust_pkg->inactive_sql(); - - -} elsif ( $cgi->param('magic') eq 'suspended' - || $cgi->param('status') eq 'suspended' ) { - - push @where, FS::cust_pkg->suspended_sql(); - -} elsif ( $cgi->param('magic') =~ /^cancell?ed$/ - || $cgi->param('status') =~ /^cancell?ed$/ ) { - - push @where, FS::cust_pkg->cancelled_sql(); - -} elsif ( $cgi->param('status') =~ /^(one-time charge|inactive)$/ ) { - - push @where, FS::cust_pkg->inactive_sql(); - -} - -### -# parse package class -### - -#false lazinessish w/graph/cust_bill_pkg.cgi -my $classnum = 0; -my @pkg_class = (); -if ( exists($cgi->Vars->{'classnum'}) - && $cgi->param('classnum') =~ /^(\d*)$/ - ) -{ - $classnum = $1; - if ( $classnum ) { #a specific class - push @where, "classnum = $classnum"; - - #@pkg_class = ( qsearchs('pkg_class', { 'classnum' => $classnum } ) ); - #die "classnum $classnum not found!" unless $pkg_class[0]; - #$title .= $pkg_class[0]->classname.' '; - - } elsif ( $classnum eq '' ) { #the empty class - - push @where, "classnum IS NULL"; - #$title .= 'Empty class '; - #@pkg_class = ( '(empty class)' ); - } elsif ( $classnum eq '0' ) { - #@pkg_class = qsearch('pkg_class', {} ); # { 'disabled' => '' } ); - #push @pkg_class, '(empty class)'; - } else { - die "illegal classnum"; - } -} -#eslaf - -### -# parse magic, legacy, etc. -### - -my $orderby; -if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { - $orderby = 'ORDER BY bill'; - - my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - push @where, - #"bill >= $beginning ", - #"bill <= $ending", - "CASE WHEN bill IS NULL THEN 0 ELSE bill END >= $beginning ", - "CASE WHEN bill IS NULL THEN 0 ELSE bill END <= $ending", - #'( cancel IS NULL OR cancel = 0 )' - ; - -} else { - - if ( $cgi->param('magic') && - $cgi->param('magic') =~ /^(active|inactive|suspended|cancell?ed)$/ - ) { - - $orderby = 'ORDER BY pkgnum'; - - if ( $cgi->param('pkgpart') =~ /^(\d+)$/ ) { - push @where, "pkgpart = $1"; - } - - } elsif ( $query eq 'pkgnum' ) { - - $orderby = 'ORDER BY pkgnum'; - - } elsif ( $query eq 'APKG_pkgnum' ) { - - $orderby = 'ORDER BY pkgnum'; - - push @where, '0 < ( - SELECT count(*) FROM pkg_svc - WHERE pkg_svc.pkgpart = cust_pkg.pkgpart - AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc - WHERE cust_svc.pkgnum = cust_pkg.pkgnum - AND cust_svc.svcpart = pkg_svc.svcpart - ) - )'; - - } else { - die "Empty or unknown QUERY_STRING!"; - } - -} - -## -# setup queries, links, subs, etc. for the search -## - -# here is the agent virtualization -push @where, $FS::CurrentUser::CurrentUser->agentnums_sql; - -my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : ''; - -my $addl_from = 'LEFT JOIN cust_main USING ( custnum ) '. - 'LEFT JOIN part_pkg USING ( pkgpart ) '. - 'LEFT JOIN pkg_class USING ( classnum ) '; - -my $count_query = "SELECT COUNT(*) FROM cust_pkg $addl_from $extra_sql"; - -my $sql_query = { - 'table' => 'cust_pkg', - 'hashref' => {}, - 'select' => join(', ', - 'cust_pkg.*', - ( map "part_pkg.$_", qw( pkg freq ) ), - 'pkg_class.classname', - 'cust_main.custnum as cust_main_custnum', - FS::UI::Web::cust_sql_fields( - $cgi->param('cust_fields') - ), - ), - 'extra_sql' => "$extra_sql $orderby", - 'addl_from' => $addl_from, -}; - -my $link = sub { - [ "${p}view/cust_main.cgi?".shift->custnum.'#cust_pkg', 'pkgnum' ]; -}; - -my $clink = sub { - my $cust_pkg = shift; - $cust_pkg->cust_main_custnum - ? [ "${p}view/cust_main.cgi?", 'custnum' ] - : ''; -}; - -#if ( scalar(@cust_pkg) == 1 ) { -# print $cgi->redirect("${p}view/cust_main.cgi?". $cust_pkg[0]->custnum. -# "#cust_pkg". $cust_pkg[0]->pkgnum ); - -# my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); -# my $rowspan = scalar(@cust_svc) || 1; - -# my $n2 = ''; -# foreach my $cust_svc ( @cust_svc ) { -# my($label, $value, $svcdb) = $cust_svc->label; -# my $svcnum = $cust_svc->svcnum; -# my $sview = $p. "view"; -# print $n2,qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!, -# qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!; -# $n2="</TR><TR>"; -# } - -sub time_or_blank { - my $column = shift; - return sub { - my $record = shift; - my $value = $record->get($column); #mmm closures - $value ? time2str('%b %d %Y', $value ) : ''; - }; -} - -### -# and finally, include the search template -### - -%><%= include( 'elements/search.html', +% +% +%# my %part_pkg = map { $_->pkgpart => $_ } qsearch('part_pkg', {}); +% +%my($query) = $cgi->keywords; +% +%my @where = (); +% +%## +%# parse agent +%## +% +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { +% push @where, +% "agentnum = $1"; +%} +% +%## +%# parse status +%## +% +%if ( $cgi->param('magic') eq 'active' +% || $cgi->param('status') eq 'active' ) { +% +% push @where, FS::cust_pkg->active_sql(); +% +%} elsif ( $cgi->param('magic') eq 'inactive' +% || $cgi->param('status') eq 'inactive' ) { +% +% push @where, FS::cust_pkg->inactive_sql(); +% +% +%} elsif ( $cgi->param('magic') eq 'suspended' +% || $cgi->param('status') eq 'suspended' ) { +% +% push @where, FS::cust_pkg->suspended_sql(); +% +%} elsif ( $cgi->param('magic') =~ /^cancell?ed$/ +% || $cgi->param('status') =~ /^cancell?ed$/ ) { +% +% push @where, FS::cust_pkg->cancelled_sql(); +% +%} elsif ( $cgi->param('status') =~ /^(one-time charge|inactive)$/ ) { +% +% push @where, FS::cust_pkg->inactive_sql(); +% +%} +% +%### +%# parse package class +%### +% +%#false lazinessish w/graph/cust_bill_pkg.cgi +%my $classnum = 0; +%my @pkg_class = (); +%if ( exists($cgi->Vars->{'classnum'}) +% && $cgi->param('classnum') =~ /^(\d*)$/ +% ) +%{ +% $classnum = $1; +% if ( $classnum ) { #a specific class +% push @where, "classnum = $classnum"; +% +% #@pkg_class = ( qsearchs('pkg_class', { 'classnum' => $classnum } ) ); +% #die "classnum $classnum not found!" unless $pkg_class[0]; +% #$title .= $pkg_class[0]->classname.' '; +% +% } elsif ( $classnum eq '' ) { #the empty class +% +% push @where, "classnum IS NULL"; +% #$title .= 'Empty class '; +% #@pkg_class = ( '(empty class)' ); +% } elsif ( $classnum eq '0' ) { +% #@pkg_class = qsearch('pkg_class', {} ); # { 'disabled' => '' } ); +% #push @pkg_class, '(empty class)'; +% } else { +% die "illegal classnum"; +% } +%} +%#eslaf +% +%### +%# parse magic, legacy, etc. +%### +% +%my $orderby; +%if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { +% $orderby = 'ORDER BY bill'; +% +% my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +% push @where, +% #"bill >= $beginning ", +% #"bill <= $ending", +% "CASE WHEN bill IS NULL THEN 0 ELSE bill END >= $beginning ", +% "CASE WHEN bill IS NULL THEN 0 ELSE bill END <= $ending", +% #'( cancel IS NULL OR cancel = 0 )' +% ; +% +%} else { +% +% if ( $cgi->param('magic') && +% $cgi->param('magic') =~ /^(active|inactive|suspended|cancell?ed)$/ +% ) { +% +% $orderby = 'ORDER BY pkgnum'; +% +% if ( $cgi->param('pkgpart') =~ /^(\d+)$/ ) { +% push @where, "pkgpart = $1"; +% } +% +% } elsif ( $query eq 'pkgnum' ) { +% +% $orderby = 'ORDER BY pkgnum'; +% +% } elsif ( $query eq 'APKG_pkgnum' ) { +% +% $orderby = 'ORDER BY pkgnum'; +% +% push @where, '0 < ( +% SELECT count(*) FROM pkg_svc +% WHERE pkg_svc.pkgpart = cust_pkg.pkgpart +% AND pkg_svc.quantity > ( SELECT count(*) FROM cust_svc +% WHERE cust_svc.pkgnum = cust_pkg.pkgnum +% AND cust_svc.svcpart = pkg_svc.svcpart +% ) +% )'; +% +% } else { +% die "Empty or unknown QUERY_STRING!"; +% } +% +%} +% +%## +%# setup queries, links, subs, etc. for the search +%## +% +%# here is the agent virtualization +%push @where, $FS::CurrentUser::CurrentUser->agentnums_sql; +% +%my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : ''; +% +%my $addl_from = 'LEFT JOIN cust_main USING ( custnum ) '. +% 'LEFT JOIN part_pkg USING ( pkgpart ) '. +% 'LEFT JOIN pkg_class USING ( classnum ) '; +% +%my $count_query = "SELECT COUNT(*) FROM cust_pkg $addl_from $extra_sql"; +% +%my $sql_query = { +% 'table' => 'cust_pkg', +% 'hashref' => {}, +% 'select' => join(', ', +% 'cust_pkg.*', +% ( map "part_pkg.$_", qw( pkg freq ) ), +% 'pkg_class.classname', +% 'cust_main.custnum as cust_main_custnum', +% FS::UI::Web::cust_sql_fields( +% $cgi->param('cust_fields') +% ), +% ), +% 'extra_sql' => "$extra_sql $orderby", +% 'addl_from' => $addl_from, +%}; +% +%my $link = sub { +% [ "${p}view/cust_main.cgi?".shift->custnum.'#cust_pkg', 'pkgnum' ]; +%}; +% +%my $clink = sub { +% my $cust_pkg = shift; +% $cust_pkg->cust_main_custnum +% ? [ "${p}view/cust_main.cgi?", 'custnum' ] +% : ''; +%}; +% +%#if ( scalar(@cust_pkg) == 1 ) { +%# print $cgi->redirect("${p}view/cust_main.cgi?". $cust_pkg[0]->custnum. +%# "#cust_pkg". $cust_pkg[0]->pkgnum ); +% +%# my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); +%# my $rowspan = scalar(@cust_svc) || 1; +% +%# my $n2 = ''; +%# foreach my $cust_svc ( @cust_svc ) { +%# my($label, $value, $svcdb) = $cust_svc->label; +%# my $svcnum = $cust_svc->svcnum; +%# my $sview = $p. "view"; +%# print $n2,qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!, +%# qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!; +%# $n2="</TR><TR>"; +%# } +% +%sub time_or_blank { +% my $column = shift; +% return sub { +% my $record = shift; +% my $value = $record->get($column); #mmm closures +% $value ? time2str('%b %d %Y', $value ) : ''; +% }; +%} +% +%### +%# and finally, include the search template +%### +% +% +<% include( 'elements/search.html', 'title' => 'Package Search Results', 'name' => 'packages', 'query' => $sql_query, diff --git a/httemplate/search/cust_tax_exempt_pkg.cgi b/httemplate/search/cust_tax_exempt_pkg.cgi index e61947b7d..3cec04f92 100644 --- a/httemplate/search/cust_tax_exempt_pkg.cgi +++ b/httemplate/search/cust_tax_exempt_pkg.cgi @@ -1,92 +1,93 @@ -<% - -my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - -my $join_cust = " - JOIN cust_bill USING ( invnum ) - LEFT JOIN cust_main USING ( custnum ) -"; - -my $join_pkg = " - LEFT JOIN cust_pkg USING ( pkgnum ) - LEFT JOIN part_pkg USING ( pkgpart ) -"; - -my $join = " - JOIN cust_bill_pkg USING ( billpkgnum ) - $join_cust - $join_pkg -"; - -my $where = " - WHERE _date >= $beginning AND _date <= $ending -"; -# AND payby != 'COMP' - -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $where .= " AND agentnum = $1 "; -} - -if ( $cgi->param('out') ) { - - $where .= " - AND 0 = ( - SELECT COUNT(*) FROM cust_main_county AS county_out - WHERE ( county_out.county = cust_main.county - OR ( county_out.county IS NULL AND cust_main.county = '' ) - OR ( county_out.county = '' AND cust_main.county IS NULL) - OR ( county_out.county IS NULL AND cust_main.county IS NULL) - ) - AND ( county_out.state = cust_main.state - OR ( county_out.state IS NULL AND cust_main.state = '' ) - OR ( county_out.state = '' AND cust_main.state IS NULL ) - OR ( county_out.state IS NULL AND cust_main.state IS NULL ) - ) - AND county_out.country = cust_main.country - AND county_out.tax > 0 - ) - "; - -} elsif ( $cgi->param('country' ) ) { - - my $county = dbh->quote( $cgi->param('county') ); - my $state = dbh->quote( $cgi->param('state') ); - my $country = dbh->quote( $cgi->param('country') ); - $where .= " - AND ( county = $county OR $county = '' ) - AND ( state = $state OR $state = '' ) - AND country = $country - "; - $where .= ' AND taxclass = '. dbh->quote( $cgi->param('taxclass') ) - if $cgi->param('taxclass'); - -} - -my $count_query = "SELECT COUNT(*), SUM(amount)". - " FROM cust_tax_exempt_pkg $join $where"; - -my $query = { - 'table' => 'cust_tax_exempt_pkg', - 'addl_from' => $join, - 'hashref' => {}, - 'select' => join(', ', - 'cust_tax_exempt_pkg.*', - 'cust_bill_pkg.*', - 'cust_bill.*', - 'part_pkg.pkg', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => $where, -}; - -my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ]; -my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; - -my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; - -%><%= include( 'elements/search.html', +% +% +%my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +% +%my $join_cust = " +% JOIN cust_bill USING ( invnum ) +% LEFT JOIN cust_main USING ( custnum ) +%"; +% +%my $join_pkg = " +% LEFT JOIN cust_pkg USING ( pkgnum ) +% LEFT JOIN part_pkg USING ( pkgpart ) +%"; +% +%my $join = " +% JOIN cust_bill_pkg USING ( billpkgnum ) +% $join_cust +% $join_pkg +%"; +% +%my $where = " +% WHERE _date >= $beginning AND _date <= $ending +%"; +%# AND payby != 'COMP' +% +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $where .= " AND agentnum = $1 "; +%} +% +%if ( $cgi->param('out') ) { +% +% $where .= " +% AND 0 = ( +% SELECT COUNT(*) FROM cust_main_county AS county_out +% WHERE ( county_out.county = cust_main.county +% OR ( county_out.county IS NULL AND cust_main.county = '' ) +% OR ( county_out.county = '' AND cust_main.county IS NULL) +% OR ( county_out.county IS NULL AND cust_main.county IS NULL) +% ) +% AND ( county_out.state = cust_main.state +% OR ( county_out.state IS NULL AND cust_main.state = '' ) +% OR ( county_out.state = '' AND cust_main.state IS NULL ) +% OR ( county_out.state IS NULL AND cust_main.state IS NULL ) +% ) +% AND county_out.country = cust_main.country +% AND county_out.tax > 0 +% ) +% "; +% +%} elsif ( $cgi->param('country' ) ) { +% +% my $county = dbh->quote( $cgi->param('county') ); +% my $state = dbh->quote( $cgi->param('state') ); +% my $country = dbh->quote( $cgi->param('country') ); +% $where .= " +% AND ( county = $county OR $county = '' ) +% AND ( state = $state OR $state = '' ) +% AND country = $country +% "; +% $where .= ' AND taxclass = '. dbh->quote( $cgi->param('taxclass') ) +% if $cgi->param('taxclass'); +% +%} +% +%my $count_query = "SELECT COUNT(*), SUM(amount)". +% " FROM cust_tax_exempt_pkg $join $where"; +% +%my $query = { +% 'table' => 'cust_tax_exempt_pkg', +% 'addl_from' => $join, +% 'hashref' => {}, +% 'select' => join(', ', +% 'cust_tax_exempt_pkg.*', +% 'cust_bill_pkg.*', +% 'cust_bill.*', +% 'part_pkg.pkg', +% 'cust_main.custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'extra_sql' => $where, +%}; +% +%my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ]; +%my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; +% +%my $conf = new FS::Conf; +%my $money_char = $conf->config('money_char') || '$'; +% +% +<% include( 'elements/search.html', 'title' => 'Tax exemptions', 'name' => 'tax exemptions', 'query' => $query, diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 3e689eba1..cbf0887a6 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -1,324 +1,333 @@ -<% - - # options example... - # (everything not commented required is optional) - # - # # basic options, required - # 'title' => 'Page title', - # 'name' => 'items', #name for the records returned - # - # # some HTML callbacks... - # 'menubar' => '', #menubar arrayref - # 'html_init' => '', #after the header/menubar and before the pager - # 'html_foot' => '', #at the bottom - # 'html_posttotal' => '', #at the bottom - # # (these three can be strings or coderefs) - # - # - # #literal SQL query string or qsearch hashref, required - # 'query' => { - # 'table' => 'tablename', - # #everything else is optional... - # 'hashref' => { 'field' => 'value', - # 'field' => { 'op' => '<', - # 'value' => '54', - # }, - # }, - # 'select' => '*', - # 'addl_from' => '', #'LEFT JOIN othertable USING ( key )', - # 'extra_sql' => '', #'AND otherstuff', #'WHERE onlystuff', - # - # - # }, - # # "select * from tablename"; - # - # #required unless 'query' is an SQL query string (shouldn't be...) - # 'count_query' => 'SELECT COUNT(*) FROM tablename', - # - # 'count_addl' => [], #additional count fields listref of sprintf strings - # # [ $money_char.'%.2f total paid', ], - # - # #listref of column labels, <TH> - # #required unless 'query' is an SQL query string - # # (if not specified the database column names will be used) - # 'header' => [ '#', 'Item' ], - # - # 'disable_download' => '', # set true to hide the CSV/Excel download links - # 'disable_nonefound' => '', # set true to disable the "No matching Xs found" - # # message - # - # #listref - each item is a literal column name (or method) or coderef - # #if not specified all columns will be shown - # 'fields' => [ - # 'column', - # sub { my $row = shift; $row->column; }, - # ], - # - # #listref of column footers - # 'footer' => [], - # - # #listref - each item is the empty string, or a listref of ... - # 'links' => - # - # - # 'align' => 'lrc.', #one letter for each column, left/right/center/none - # # can also pass a listref with full values: - # # [ 'left', 'right', 'center', '' ] - # - # #listrefs... - # #currently only HTML, maybe eventually Excel too - # 'color' => [], - # 'size' => [], - # 'style' => [], - # - # #redirect if there's only one item... - # # listref of URL base and column name (or method) - # # or a coderef that returns the same - # 'redirect' => - - my $DEBUG = 0; - - my(%opt) = @_; - #warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n"; - - my %align = ( - 'l' => 'left', - 'r' => 'right', - 'c' => 'center', - ' ' => '', - '.' => '', - ); - $opt{align} = [ map $align{$_}, split(//, $opt{align}) ], - unless !$opt{align} || ref($opt{align}); - - my $type = ''; - my $limit = ''; - my($maxrecords, $total, $offset, $count_arrayref); - - if ( $cgi->param('_type') =~ /^(csv|\w*\.xls)$/ ) { - - $type = $1; - - } else { #setup some pagination things if we're in html mode - - unless (exists($opt{'count_query'}) && length($opt{'count_query'})) { - ( $opt{'count_query'} = $opt{'query'} ) =~ - s/^\s*SELECT\s*(.*?)\s+FROM\s/SELECT COUNT(*) FROM /i; - } - - my $conf = new FS::Conf; - $maxrecords = $conf->config('maxsearchrecordsperpage'); - - $limit = $maxrecords ? "LIMIT $maxrecords" : ''; - - $offset = $cgi->param('offset') || 0; - $limit .= " OFFSET $offset" if $offset; - - my $count_sth = dbh->prepare($opt{'count_query'}) - or die "Error preparing $opt{'count_query'}: ". dbh->errstr; - $count_sth->execute - or die "Error executing $opt{'count_query'}: ". $count_sth->errstr; - $count_arrayref = $count_sth->fetchrow_arrayref; - $total = $count_arrayref->[0]; - - } - - # run the query - - my $header = $opt{'header'}; - my $rows; - if ( ref($opt{'query'}) ) { - - #eval "use FS::$opt{'query'};"; - $rows = [ qsearch( - $opt{'query'}->{'table'}, - $opt{'query'}->{'hashref'} || {}, - $opt{'query'}->{'select'}, - $opt{'query'}->{'extra_sql'}. " $limit", - '', - (exists($opt{'query'}->{'addl_from'}) ? $opt{'query'}->{'addl_from'} : '') - ) ]; - - } else { - - my $sth = dbh->prepare("$opt{'query'} $limit") - or die "Error preparing $opt{'query'}: ". dbh->errstr; - $sth->execute - or die "Error executing $opt{'query'}: ". $sth->errstr; - - #can get # of rows without fetching them all? - $rows = $sth->fetchall_arrayref; - - $header ||= $sth->{NAME}; - - } - - warn scalar(@$rows). ' rows returned from '. - ( ref($opt{'query'}) ? 'qsearch query' : 'literal SQL query' ) - if $DEBUG || $opt{'debug'}; - - # display the results - csv, xls or html - - if ( $type eq 'csv' ) { - - #http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes - http_header('Content-Type' => 'text/plain' ); - - my $csv = new Text::CSV_XS { 'always_quote' => 1, - 'eol' => "\n", #"\015\012", #"\012" - }; - - $csv->combine(@$header); #or die $csv->status; - %><%= $csv->string %><% - - foreach my $row ( @$rows ) { - - if ( $opt{'fields'} ) { - - my @line = (); - - foreach my $field ( @{$opt{'fields'}} ) { - if ( ref($field) eq 'CODE' ) { - push @line, map { - ref($_) eq 'ARRAY' - ? '(N/A)' #unimplemented - : $_; - } - &{$field}($row); - } else { - push @line, $row->$field(); - } - } - - $csv->combine(@line); #or die $csv->status; - - } else { - $csv->combine(@$row); #or die $csv->status; - } - - %><%= $csv->string %><% - - } - - #} elsif ( $type eq 'excel' ) { - } elsif ( $type =~ /\.xls$/ ) { - - #http_header('Content-Type' => 'application/excel' ); #eww - http_header('Content-Type' => 'application/vnd.ms-excel' ); - #http_header('Content-Type' => 'application/msexcel' ); #alas - - my $data = ''; - my $XLS = new IO::Scalar \$data; - my $workbook = Spreadsheet::WriteExcel->new($XLS) - or die "Error opening .xls file: $!"; - - my $worksheet = $workbook->add_worksheet(substr($opt{'title'},0,31)); - - my($r,$c) = (0,0); - - $worksheet->write($r, $c++, $_) foreach @$header; - - foreach my $row ( @$rows ) { - $r++; - $c = 0; - - if ( $opt{'fields'} ) { - - #my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; - #my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; - - foreach my $field ( @{$opt{'fields'}} ) { - #my $align = $aligns ? shift @$aligns : ''; - #$align = " ALIGN=$align" if $align; - #my $a = ''; - #if ( $links ) { - # my $link = shift @$links; - # $link = &{$link}($row) if ref($link) eq 'CODE'; - # if ( $link ) { - # my( $url, $method ) = @{$link}; - # if ( ref($method) eq 'CODE' ) { - # $a = $url. &{$method}($row); - # } else { - # $a = $url. $row->$method(); - # } - # $a = qq(<A HREF="$a">); - # } - #} - if ( ref($field) eq 'CODE' ) { - foreach my $value ( &{$field}($row) ) { - if ( ref($value) eq 'ARRAY' ) { - $worksheet->write($r, $c++, '(N/A)' ); #unimplemented - } else { - $worksheet->write($r, $c++, $value ); - } - } - } else { - $worksheet->write($r, $c++, $row->$field() ); - } - } - - } else { - $worksheet->write($r, $c++, $_) foreach @$row; - } - - } - - $workbook->close();# or die "Error creating .xls file: $!"; - - http_header('Content-Length' => length($data) ); - %><%= $data %><% - - } else { # regular HTML - - if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 && $total == 1 ) { - my $redirect = $opt{'redirect'}; - $redirect = &{$redirect}($rows->[0]) if ref($redirect) eq 'CODE'; - my( $url, $method ) = @$redirect; - redirect( $url. $rows->[0]->$method() ); - } else { - ( my $xlsname = $opt{'name'} ) =~ s/\W//g; - #$opt{'name'} =~ s/s$// if $total == 1; - $opt{'name'} =~ s/((s)e)?s$/$2/ if $total == 1; #should use Lingua::bs - # to "depluralize" - - my @menubar = (); - if ( $opt{'menubar'} ) { - @menubar = @{ $opt{'menubar'} }; - } else { - @menubar = ( 'Main menu' => $p ); - } - - - %> - <%= include( '/elements/header.html', $opt{'title'}, +% +% +% # options example... +% # (everything not commented required is optional) +% # +% # # basic options, required +% # 'title' => 'Page title', +% # 'name' => 'items', #name for the records returned +% # +% # # some HTML callbacks... +% # 'menubar' => '', #menubar arrayref +% # 'html_init' => '', #after the header/menubar and before the pager +% # 'html_foot' => '', #at the bottom +% # 'html_posttotal' => '', #at the bottom +% # # (these three can be strings or coderefs) +% # +% # +% # #literal SQL query string or qsearch hashref, required +% # 'query' => { +% # 'table' => 'tablename', +% # #everything else is optional... +% # 'hashref' => { 'field' => 'value', +% # 'field' => { 'op' => '<', +% # 'value' => '54', +% # }, +% # }, +% # 'select' => '*', +% # 'addl_from' => '', #'LEFT JOIN othertable USING ( key )', +% # 'extra_sql' => '', #'AND otherstuff', #'WHERE onlystuff', +% # +% # +% # }, +% # # "select * from tablename"; +% # +% # #required unless 'query' is an SQL query string (shouldn't be...) +% # 'count_query' => 'SELECT COUNT(*) FROM tablename', +% # +% # 'count_addl' => [], #additional count fields listref of sprintf strings +% # # [ $money_char.'%.2f total paid', ], +% # +% # #listref of column labels, <TH> +% # #required unless 'query' is an SQL query string +% # # (if not specified the database column names will be used) +% # 'header' => [ '#', 'Item' ], +% # +% # 'disable_download' => '', # set true to hide the CSV/Excel download links +% # 'disable_nonefound' => '', # set true to disable the "No matching Xs found" +% # # message +% # +% # #listref - each item is a literal column name (or method) or coderef +% # #if not specified all columns will be shown +% # 'fields' => [ +% # 'column', +% # sub { my $row = shift; $row->column; }, +% # ], +% # +% # #listref of column footers +% # 'footer' => [], +% # +% # #listref - each item is the empty string, or a listref of ... +% # 'links' => +% # +% # +% # 'align' => 'lrc.', #one letter for each column, left/right/center/none +% # # can also pass a listref with full values: +% # # [ 'left', 'right', 'center', '' ] +% # +% # #listrefs... +% # #currently only HTML, maybe eventually Excel too +% # 'color' => [], +% # 'size' => [], +% # 'style' => [], +% # +% # #redirect if there's only one item... +% # # listref of URL base and column name (or method) +% # # or a coderef that returns the same +% # 'redirect' => +% +% my $DEBUG = 0; +% +% my(%opt) = @_; +% #warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n"; +% +% my %align = ( +% 'l' => 'left', +% 'r' => 'right', +% 'c' => 'center', +% ' ' => '', +% '.' => '', +% ); +% $opt{align} = [ map $align{$_}, split(//, $opt{align}) ], +% unless !$opt{align} || ref($opt{align}); +% +% my $type = ''; +% my $limit = ''; +% my($maxrecords, $total, $offset, $count_arrayref); +% +% if ( $cgi->param('_type') =~ /^(csv|\w*\.xls)$/ ) { +% +% $type = $1; +% +% } else { #setup some pagination things if we're in html mode +% +% unless (exists($opt{'count_query'}) && length($opt{'count_query'})) { +% ( $opt{'count_query'} = $opt{'query'} ) =~ +% s/^\s*SELECT\s*(.*?)\s+FROM\s/SELECT COUNT(*) FROM /i; +% } +% +% my $conf = new FS::Conf; +% $maxrecords = $conf->config('maxsearchrecordsperpage'); +% +% $limit = $maxrecords ? "LIMIT $maxrecords" : ''; +% +% $offset = $cgi->param('offset') || 0; +% $limit .= " OFFSET $offset" if $offset; +% +% my $count_sth = dbh->prepare($opt{'count_query'}) +% or die "Error preparing $opt{'count_query'}: ". dbh->errstr; +% $count_sth->execute +% or die "Error executing $opt{'count_query'}: ". $count_sth->errstr; +% $count_arrayref = $count_sth->fetchrow_arrayref; +% $total = $count_arrayref->[0]; +% +% } +% +% # run the query +% +% my $header = $opt{'header'}; +% my $rows; +% if ( ref($opt{'query'}) ) { +% +% #eval "use FS::$opt{'query'};"; +% $rows = [ qsearch( +% $opt{'query'}->{'table'}, +% $opt{'query'}->{'hashref'} || {}, +% $opt{'query'}->{'select'}, +% $opt{'query'}->{'extra_sql'}. " $limit", +% '', +% (exists($opt{'query'}->{'addl_from'}) ? $opt{'query'}->{'addl_from'} : '') +% ) ]; +% +% } else { +% +% my $sth = dbh->prepare("$opt{'query'} $limit") +% or die "Error preparing $opt{'query'}: ". dbh->errstr; +% $sth->execute +% or die "Error executing $opt{'query'}: ". $sth->errstr; +% +% #can get # of rows without fetching them all? +% $rows = $sth->fetchall_arrayref; +% +% $header ||= $sth->{NAME}; +% +% } +% +% warn scalar(@$rows). ' rows returned from '. +% ( ref($opt{'query'}) ? 'qsearch query' : 'literal SQL query' ) +% if $DEBUG || $opt{'debug'}; +% +% # display the results - csv, xls or html +% +% if ( $type eq 'csv' ) { +% +% #http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes +% http_header('Content-Type' => 'text/plain' ); +% +% my $csv = new Text::CSV_XS { 'always_quote' => 1, +% 'eol' => "\n", #"\015\012", #"\012" +% }; +% +% $csv->combine(@$header); #or die $csv->status; +% +<% $csv->string %> +% +% +% foreach my $row ( @$rows ) { +% +% if ( $opt{'fields'} ) { +% +% my @line = (); +% +% foreach my $field ( @{$opt{'fields'}} ) { +% if ( ref($field) eq 'CODE' ) { +% push @line, map { +% ref($_) eq 'ARRAY' +% ? '(N/A)' #unimplemented +% : $_; +% } +% &{$field}($row); +% } else { +% push @line, $row->$field(); +% } +% } +% +% $csv->combine(@line); #or die $csv->status; +% +% } else { +% $csv->combine(@$row); #or die $csv->status; +% } +% +% +<% $csv->string %> +% +% +% } +% +% #} elsif ( $type eq 'excel' ) { +% } elsif ( $type =~ /\.xls$/ ) { +% +% #http_header('Content-Type' => 'application/excel' ); #eww +% http_header('Content-Type' => 'application/vnd.ms-excel' ); +% #http_header('Content-Type' => 'application/msexcel' ); #alas +% +% my $data = ''; +% my $XLS = new IO::Scalar \$data; +% my $workbook = Spreadsheet::WriteExcel->new($XLS) +% or die "Error opening .xls file: $!"; +% +% my $worksheet = $workbook->add_worksheet(substr($opt{'title'},0,31)); +% +% my($r,$c) = (0,0); +% +% $worksheet->write($r, $c++, $_) foreach @$header; +% +% foreach my $row ( @$rows ) { +% $r++; +% $c = 0; +% +% if ( $opt{'fields'} ) { +% +% #my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; +% #my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; +% +% foreach my $field ( @{$opt{'fields'}} ) { +% #my $align = $aligns ? shift @$aligns : ''; +% #$align = " ALIGN=$align" if $align; +% #my $a = ''; +% #if ( $links ) { +% # my $link = shift @$links; +% # $link = &{$link}($row) if ref($link) eq 'CODE'; +% # if ( $link ) { +% # my( $url, $method ) = @{$link}; +% # if ( ref($method) eq 'CODE' ) { +% # $a = $url. &{$method}($row); +% # } else { +% # $a = $url. $row->$method(); +% # } +% # $a = qq(<A HREF="$a">); +% # } +% #} +% if ( ref($field) eq 'CODE' ) { +% foreach my $value ( &{$field}($row) ) { +% if ( ref($value) eq 'ARRAY' ) { +% $worksheet->write($r, $c++, '(N/A)' ); #unimplemented +% } else { +% $worksheet->write($r, $c++, $value ); +% } +% } +% } else { +% $worksheet->write($r, $c++, $row->$field() ); +% } +% } +% +% } else { +% $worksheet->write($r, $c++, $_) foreach @$row; +% } +% +% } +% +% $workbook->close();# or die "Error creating .xls file: $!"; +% +% http_header('Content-Length' => length($data) ); +% +<% $data %> +% +% +% } else { # regular HTML +% +% if ( exists($opt{'redirect'}) && scalar(@$rows) == 1 && $total == 1 ) { +% my $redirect = $opt{'redirect'}; +% $redirect = &{$redirect}($rows->[0]) if ref($redirect) eq 'CODE'; +% my( $url, $method ) = @$redirect; +% redirect( $url. $rows->[0]->$method() ); +% } else { +% ( my $xlsname = $opt{'name'} ) =~ s/\W//g; +% #$opt{'name'} =~ s/s$// if $total == 1; +% $opt{'name'} =~ s/((s)e)?s$/$2/ if $total == 1; #should use Lingua::bs +% # to "depluralize" +% +% my @menubar = (); +% if ( $opt{'menubar'} ) { +% @menubar = @{ $opt{'menubar'} }; +% } else { +% @menubar = ( 'Main menu' => $p ); +% } +% +% +% + + <% include( '/elements/header.html', $opt{'title'}, include( '/elements/menubar.html', @menubar ) ) %> - <%= defined($opt{'html_init'}) + <% defined($opt{'html_init'}) ? ( ref($opt{'html_init'}) ? &{$opt{'html_init'}}() : $opt{'html_init'} ) : '' %> - <% my $pager = include ( '/elements/pager.html', - 'offset' => $offset, - 'num_rows' => scalar(@$rows), - 'total' => $total, - 'maxrecords' => $maxrecords, - ); - %> - <% unless ( $total ) { %> - <% unless ( $opt{'disable_nonefound'} ) { %> - No matching <%= $opt{'name'} %> found.<BR> - <% } %> - <% } else { %> +% my $pager = include ( '/elements/pager.html', +% 'offset' => $offset, +% 'num_rows' => scalar(@$rows), +% 'total' => $total, +% 'maxrecords' => $maxrecords, +% ); +% +% unless ( $total ) { +% unless ( $opt{'disable_nonefound'} ) { + + No matching <% $opt{'name'} %> found.<BR> +% } +% } else { + <TABLE> <TR> <TD VALIGN="bottom"> - <%= $total %> total <%= $opt{'name'} %> - <%= defined($opt{'html_posttotal'}) + <% $total %> total <% $opt{'name'} %> + <% defined($opt{'html_posttotal'}) ? ( ref($opt{'html_posttotal'}) ? &{$opt{'html_posttotal'}}() : $opt{'html_posttotal'} @@ -326,185 +335,201 @@ : '' %> <BR> - <% if ( $opt{'count_addl'} ) { %> - <% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %> - <%= sprintf( $count, $count_arrayref->[++$n] ) %><BR> - <% } %> - <% } %> +% if ( $opt{'count_addl'} ) { +% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { + + <% sprintf( $count, $count_arrayref->[++$n] ) %><BR> +% } +% } + </TD> - <% unless ( $opt{'disable_download'} ) { %> +% unless ( $opt{'disable_download'} ) { + <TD ALIGN="right"> - <% $cgi->param('_type', "$xlsname.xls" ); %> +% $cgi->param('_type', "$xlsname.xls" ); + Download full results<BR> - as <A HREF="<%= $cgi->self_url %>">Excel spreadsheet</A><BR> - <% $cgi->param('_type', 'csv'); %> - as <A HREF="<%= $cgi->self_url %>">CSV file</A> + as <A HREF="<% $cgi->self_url %>">Excel spreadsheet</A><BR> +% $cgi->param('_type', 'csv'); + + as <A HREF="<% $cgi->self_url %>">CSV file</A> </TD> - <% } %> +% } + </TR> <TR> <TD COLSPAN=2> - <%= $pager %> + <% $pager %> - <%= include('/elements/table-grid.html') %> + <% include('/elements/table-grid.html') %> <TR> - <% - foreach my $header ( @$header ) { %> - <TH CLASS="grid" BGCOLOR="#cccccc"><%= $header %></TH> - <% } %> - </TR> - <% my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor; - foreach my $row ( @$rows ) { - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - %> - <TR> - <% if ( $opt{'fields'} ) { - - my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; - my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; - my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : []; - my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : []; - my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : []; - - foreach my $field ( - - map { - if ( ref($_) eq 'ARRAY' ) { - - my $tableref = $_; +% +% foreach my $header ( @$header ) { - '<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>'. + <TH CLASS="grid" BGCOLOR="#cccccc"><% $header %></TH> +% } - join('', map { - - my $rowref = $_; - - '<tr>'. - - join('', map { - - my $element = $_; - - '<TD'. - ( $element->{'align'} - ? ' ALIGN="'. $element->{'align'}. '"' - : '' - ). '>'. - ( $element->{'link'} - ? '<A HREF="'. $element->{'link'}.'">' - : '' - ). - $element->{'data'}. - ( $element->{'link'} - ? '</A>' - : '' - ). - '</td>'; - - } @$rowref ). - - '</tr>'; - } @$tableref ). - - '</table>'; - - } else { - $_; - } - } - - map { - if ( ref($_) eq 'CODE' ) { - &{$_}($row); - } else { - $row->$_(); - } - } - @{$opt{'fields'}} - - ) { - - my $class = ( $field =~ /^<TABLE/i ) ? 'inv' : 'grid'; - - my $align = $aligns ? shift @$aligns : ''; - $align = " ALIGN=$align" if $align; - - my $a = ''; - if ( $links ) { - my $link = shift @$links; - $link = &{$link}($row) if ref($link) eq 'CODE'; - if ( $link ) { - my( $url, $method ) = @{$link}; - if ( ref($method) eq 'CODE' ) { - $a = $url. &{$method}($row); - } else { - $a = $url. $row->$method(); - } - $a = qq(<A HREF="$a">); - } - } - - my $font = ''; - my $color = shift @$colors; - $color = &{$color}($row) if ref($color) eq 'CODE'; - my $size = shift @$sizes; - $size = &{$size}($row) if ref($size) eq 'CODE'; - if ( $color || $size ) { - $font = '<FONT '. - ( $color ? "COLOR=#$color " : '' ). - ( $size ? qq(SIZE="$size" ) : '' ). - '>'; - } + </TR> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor; +% foreach my $row ( @$rows ) { +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% - my($s, $es) = ( '', '' ); - my $style = shift @$styles; - $style = &{$style}($row) if ref($style) eq 'CODE'; - if ( $style ) { - $s = join( '', map "<$_>", split('', $style) ); - $es = join( '', map "</$_>", split('', $style) ); - } + <TR> +% if ( $opt{'fields'} ) { +% +% my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : ''; +% my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : ''; +% my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : []; +% my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : []; +% my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : []; +% +% foreach my $field ( +% +% map { +% if ( ref($_) eq 'ARRAY' ) { +% +% my $tableref = $_; +% +% '<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>'. +% +% join('', map { +% +% my $rowref = $_; +% +% '<tr>'. +% +% join('', map { +% +% my $element = $_; +% +% '<TD'. +% ( $element->{'align'} +% ? ' ALIGN="'. $element->{'align'}. '"' +% : '' +% ). '>'. +% ( $element->{'link'} +% ? '<A HREF="'. $element->{'link'}.'">' +% : '' +% ). +% $element->{'data'}. +% ( $element->{'link'} +% ? '</A>' +% : '' +% ). +% '</td>'; +% +% } @$rowref ). +% +% '</tr>'; +% } @$tableref ). +% +% '</table>'; +% +% } else { +% $_; +% } +% } +% +% map { +% if ( ref($_) eq 'CODE' ) { +% &{$_}($row); +% } else { +% $row->$_(); +% } +% } +% @{$opt{'fields'}} +% +% ) { +% +% my $class = ( $field =~ /^<TABLE/i ) ? 'inv' : 'grid'; +% +% my $align = $aligns ? shift @$aligns : ''; +% $align = " ALIGN=$align" if $align; +% +% my $a = ''; +% if ( $links ) { +% my $link = shift @$links; +% $link = &{$link}($row) if ref($link) eq 'CODE'; +% if ( $link ) { +% my( $url, $method ) = @{$link}; +% if ( ref($method) eq 'CODE' ) { +% $a = $url. &{$method}($row); +% } else { +% $a = $url. $row->$method(); +% } +% $a = qq(<A HREF="$a">); +% } +% } +% +% my $font = ''; +% my $color = shift @$colors; +% $color = &{$color}($row) if ref($color) eq 'CODE'; +% my $size = shift @$sizes; +% $size = &{$size}($row) if ref($size) eq 'CODE'; +% if ( $color || $size ) { +% $font = '<FONT '. +% ( $color ? "COLOR=#$color " : '' ). +% ( $size ? qq(SIZE="$size" ) : '' ). +% '>'; +% } +% +% my($s, $es) = ( '', '' ); +% my $style = shift @$styles; +% $style = &{$style}($row) if ref($style) eq 'CODE'; +% if ( $style ) { +% $s = join( '', map "<$_>", split('', $style) ); +% $es = join( '', map "</$_>", split('', $style) ); +% } +% +% + + <TD CLASS="<% $class %>" BGCOLOR="<% $bgcolor %>"<% $align %>><% $font %><% $a %><% $s %><% $field %><% $es %><% $a ? '</A>' : '' %><% $font ? '</FONT>' : '' %></TD> +% } +% } else { +% foreach ( @$row ) { + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $_ %></TD> +% } +% } - %> - <TD CLASS="<%= $class %>" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $font %><%= $a %><%= $s %><%= $field %><%= $es %><%= $a ? '</A>' : '' %><%= $font ? '</FONT>' : '' %></TD> - <% } %> - <% } else { %> - <% foreach ( @$row ) { %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $_ %></TD> - <% } %> - <% } %> </TR> - <% } %> +% } +% if ( $opt{'footer'} ) { - <% if ( $opt{'footer'} ) { %> <TR> - <% foreach my $footer ( @{ $opt{'footer'} } ) { %> - <TD CLASS="grid" BGCOLOR="#dddddd" STYLE="border-top: dashed 1px black;"><i><%= $footer %></i></TH> - <% } %> +% foreach my $footer ( @{ $opt{'footer'} } ) { + + <TD CLASS="grid" BGCOLOR="#dddddd" STYLE="border-top: dashed 1px black;"><i><% $footer %></i></TH> +% } + </TR> - <% } %> +% } + </TABLE> - <%= $pager %> + <% $pager %> </TD> </TR> </TABLE> - - <% } %> - <%= defined($opt{'html_foot'}) +% } + + <% defined($opt{'html_foot'}) ? ( ref($opt{'html_foot'}) ? &{$opt{'html_foot'}}() : $opt{'html_foot'} ) : '' %> - <%= include( '/elements/footer.html' ) %> - <% } %> -<% } %> + <% include( '/elements/footer.html' ) %> +% } +% } + diff --git a/httemplate/search/inventory_item.html b/httemplate/search/inventory_item.html index 7049c8841..fc690b33b 100644 --- a/httemplate/search/inventory_item.html +++ b/httemplate/search/inventory_item.html @@ -1,52 +1,53 @@ -<% - -my $classnum = $cgi->param('classnum'); -$classnum =~ /^(\d+)$/ or eidiot "illegal classnum $classnum"; -$classnum = $1; - -my $inventory_class = qsearchs( { - 'table' => 'inventory_class', - 'hashref' => { 'classnum' => $classnum }, -} ); - -my $title = $inventory_class->classname. ' Inventory'; - -#little false laziness with SQL fragments in inventory_class.pm -my $extra_sql = ''; -if ( $cgi->param('avail') ) { - $extra_sql = 'AND ( svcnum IS NULL OR svcnum = 0 )'; - $title .= ' - Available'; -} elsif ( $cgi->param('used') ) { - $extra_sql = 'AND svcnum IS NOT NULL AND svcnum > 0'; - $title .= ' - In use'; -} - -my $count_query = - "SELECT COUNT(*) FROM inventory_item WHERE classnum = $classnum $extra_sql"; - -my $link = sub { - my $inventory_item = shift; - if ( $inventory_item->svcnum ) { - [ "${p}view/svc_acct.cgi?", 'svcnum' ]; - } else { - ''; - } -}; -my $link_cust = sub { - my $inventory_item = shift; - if ( $inventory_item->custnum ) { - [ "${p}view/cust_main.cgi?", 'custnum' ]; - } else { - ''; - } -}; - -my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. - ' LEFT JOIN part_svc USING ( svcpart ) '. - ' LEFT JOIN cust_pkg USING ( pkgnum ) '. - ' LEFT JOIN cust_main USING ( custnum ) '; - -%><%= include( 'elements/search.html', +% +% +%my $classnum = $cgi->param('classnum'); +%$classnum =~ /^(\d+)$/ or eidiot "illegal classnum $classnum"; +%$classnum = $1; +% +%my $inventory_class = qsearchs( { +% 'table' => 'inventory_class', +% 'hashref' => { 'classnum' => $classnum }, +%} ); +% +%my $title = $inventory_class->classname. ' Inventory'; +% +%#little false laziness with SQL fragments in inventory_class.pm +%my $extra_sql = ''; +%if ( $cgi->param('avail') ) { +% $extra_sql = 'AND ( svcnum IS NULL OR svcnum = 0 )'; +% $title .= ' - Available'; +%} elsif ( $cgi->param('used') ) { +% $extra_sql = 'AND svcnum IS NOT NULL AND svcnum > 0'; +% $title .= ' - In use'; +%} +% +%my $count_query = +% "SELECT COUNT(*) FROM inventory_item WHERE classnum = $classnum $extra_sql"; +% +%my $link = sub { +% my $inventory_item = shift; +% if ( $inventory_item->svcnum ) { +% [ "${p}view/svc_acct.cgi?", 'svcnum' ]; +% } else { +% ''; +% } +%}; +%my $link_cust = sub { +% my $inventory_item = shift; +% if ( $inventory_item->custnum ) { +% [ "${p}view/cust_main.cgi?", 'custnum' ]; +% } else { +% ''; +% } +%}; +% +%my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. +% ' LEFT JOIN part_svc USING ( svcpart ) '. +% ' LEFT JOIN cust_pkg USING ( pkgnum ) '. +% ' LEFT JOIN cust_main USING ( custnum ) '; +% +% +<% include( 'elements/search.html', 'title' => $title, diff --git a/httemplate/search/prepay_credit.html b/httemplate/search/prepay_credit.html index 8c8f57b5a..dff8a3d9a 100644 --- a/httemplate/search/prepay_credit.html +++ b/httemplate/search/prepay_credit.html @@ -1,15 +1,16 @@ -<% -my $agent = ''; -my $hashref = {}; -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $hashref->{agentnum} = $1; - $agent = qsearchs('agent', { 'agentnum' => $1 } ); -} - -my $count_query = 'SELECT COUNT(*) FROM prepay_credit'; -$count_query .= ' WHERE agentnum = '. $agent->agentnum if $agent; - -%><%= include( 'elements/search.html', +% +%my $agent = ''; +%my $hashref = {}; +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $hashref->{agentnum} = $1; +% $agent = qsearchs('agent', { 'agentnum' => $1 } ); +%} +% +%my $count_query = 'SELECT COUNT(*) FROM prepay_credit'; +%$count_query .= ' WHERE agentnum = '. $agent->agentnum if $agent; +% +% +<% include( 'elements/search.html', 'title' => 'Unused Prepaid Cards'. ($agent ? ' for '. $agent->agent : ''), 'menubar' => [ diff --git a/httemplate/search/queue.html b/httemplate/search/queue.html index 132c05129..fa6c1a1ca 100644 --- a/httemplate/search/queue.html +++ b/httemplate/search/queue.html @@ -1,17 +1,18 @@ -<% - -my $hashref = {}; - -my $conf = new FS::Conf; -my $dangerous = $conf->exists('queue_dangerous_controls'); - -my $noactions = 0; - -my $count_query = 'SELECT COUNT(*) FROM queue'; # + $hashref - -my $areboxes = 0; - -%><%= include( 'elements/search.html', +% +% +%my $hashref = {}; +% +%my $conf = new FS::Conf; +%my $dangerous = $conf->exists('queue_dangerous_controls'); +% +%my $noactions = 0; +% +%my $count_query = 'SELECT COUNT(*) FROM queue'; # + $hashref +% +%my $areboxes = 0; +% +% +<% include( 'elements/search.html', 'title' => 'Job Queue', 'menubar' => [ 'Main menu' => $p, ], 'name' => 'jobs', diff --git a/httemplate/search/reg_code.html b/httemplate/search/reg_code.html index 52a99ff66..dc388db2e 100644 --- a/httemplate/search/reg_code.html +++ b/httemplate/search/reg_code.html @@ -1,13 +1,14 @@ -<% - -my $agentnum = $cgi->param('agentnum'); -$agentnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum"; -$agentnum = $1; -my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); - -my $count_query = "SELECT COUNT(*) FROM reg_code WHERE agentnum = $agentnum"; - -%><%= include( 'elements/search.html', +% +% +%my $agentnum = $cgi->param('agentnum'); +%$agentnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum"; +%$agentnum = $1; +%my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); +% +%my $count_query = "SELECT COUNT(*) FROM reg_code WHERE agentnum = $agentnum"; +% +% +<% include( 'elements/search.html', 'title' => 'Unused Registration Codes for '. $agent->agent, 'name' => 'registration codes', diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html index 6febe6c4a..c480c05f1 100644 --- a/httemplate/search/report_cdr.html +++ b/httemplate/search/report_cdr.html @@ -1,4 +1,4 @@ -<%= include('/elements/header.html', 'Call Detail Record Search' ) %> +<% include('/elements/header.html', 'Call Detail Record Search' ) %> <FORM ACTION="cdr.html" METHOD="GET"> Status: <SELECT NAME="freesidestatus"> @@ -8,5 +8,5 @@ Status: <SELECT NAME="freesidestatus"> </SELECT><BR> <INPUT TYPE="submit" VALUE="Search Call Detail Records"> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/report_cust_bill.html b/httemplate/search/report_cust_bill.html index f1b7bfa14..ec57d2094 100644 --- a/httemplate/search/report_cust_bill.html +++ b/httemplate/search/report_cust_bill.html @@ -1,15 +1,15 @@ -<%= include('/elements/header.html', 'Invoice report criteria' ) %> +<% include('/elements/header.html', 'Invoice report criteria' ) %> <FORM ACTION="cust_bill.html" METHOD="GET"> <INPUT TYPE="hidden" NAME="magic" VALUE="_date"> <TABLE> - <%= include( '/elements/tr-select-agent.html', + <% include( '/elements/tr-select-agent.html', $cgi->param('agentnum'), 'label' => 'Invoices for agent: ', ) %> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <% include( '/elements/tr-input-beginning_ending.html' ) %> <TR> <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="open" VALUE="1" CHECKED></TD> <TD>Show only open invoices</TD> @@ -25,4 +25,4 @@ </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/report_cust_credit.html b/httemplate/search/report_cust_credit.html index 8ca52dc9a..96c0b5acb 100644 --- a/httemplate/search/report_cust_credit.html +++ b/httemplate/search/report_cust_credit.html @@ -1,4 +1,4 @@ -<%= include('/elements/header.html', 'Credit report' ) %> +<% include('/elements/header.html', 'Credit report' ) %> <FORM ACTION="cust_credit.html" METHOD="GET"> <INPUT TYPE="hidden" NAME="magic" VALUE="_date"> @@ -6,28 +6,30 @@ <TABLE> <TR> <TD ALIGN="right">Credits by employee: </TD> +% +% my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_credit") +% or die dbh->errstr; +% $sth->execute or die $sth->errstr; +% my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref}; +% -<% - my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_credit") - or die dbh->errstr; - $sth->execute or die $sth->errstr; - my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref}; -%> <TD><SELECT NAME="otaker"> <OPTION VALUE="">all</OPTION> - <% foreach my $otaker ( @otakers ) { %> - <OPTION VALUE="<%= $otaker %>"><%= $otaker %></OPTION> - <% } %> +% foreach my $otaker ( @otakers ) { + + <OPTION VALUE="<% $otaker %>"><% $otaker %></OPTION> +% } + </SELECT> </TD> </TR> - <%= include( '/elements/tr-select-agent.html', + <% include( '/elements/tr-select-agent.html', $cgi->param('agentnum'), 'label' => 'for agent: ', ) %> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <% include( '/elements/tr-input-beginning_ending.html' ) %> </TABLE> <BR> @@ -35,4 +37,4 @@ </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/report_cust_main-zip.html b/httemplate/search/report_cust_main-zip.html index 30020f3aa..db5e65c8f 100644 --- a/httemplate/search/report_cust_main-zip.html +++ b/httemplate/search/report_cust_main-zip.html @@ -1,4 +1,4 @@ -<%= include('/elements/header.html', 'Zip code report') %> +<% include('/elements/header.html', 'Zip code report') %> <FORM ACTION="cust_main-zip.html" METHOD="GET"> @@ -33,7 +33,7 @@ </TD> </TR> - <%= include( '/elements/tr-select-agent.html', + <% include( '/elements/tr-select-agent.html', $cgi->param('agentnum'), 'label' => 'for agent: ', ) diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 8adf7dc13..f9875e20c 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -1,4 +1,4 @@ -<%= include('/elements/header.html', 'Payment report' ) %> +<% include('/elements/header.html', 'Payment report' ) %> <FORM ACTION="cust_pay.cgi" METHOD="GET"> <INPUT TYPE="hidden" NAME="magic" VALUE="_date"> @@ -25,13 +25,13 @@ </TD> </TR> - <%= include( '/elements/tr-select-agent.html', + <% include( '/elements/tr-select-agent.html', $cgi->param('agentnum'), 'label' => 'for agent: ', ) %> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <% include( '/elements/tr-input-beginning_ending.html' ) %> </TABLE> @@ -40,4 +40,4 @@ </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/report_cust_pkg.html b/httemplate/search/report_cust_pkg.html index 98e91217f..8fabf107a 100755 --- a/httemplate/search/report_cust_pkg.html +++ b/httemplate/search/report_cust_pkg.html @@ -1,4 +1,4 @@ -<%= include('/elements/header.html', 'Package Report' ) %> +<% include('/elements/header.html', 'Package Report' ) %> <FORM ACTION="cust_pkg.cgi" METHOD="GET"> <INPUT TYPE="hidden" NAME="magic" VALUE="bill"> @@ -8,22 +8,23 @@ <TR> <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Search options</FONT></TH> </TR> - <%= include( '/elements/tr-select-agent.html', + <% include( '/elements/tr-select-agent.html', $cgi->param('agentnum'), ) %> - <%= include( '/elements/tr-select-cust_pkg-status.html' ) %> - <%= include( '/elements/tr-select-pkg_class.html', '', + <% include( '/elements/tr-select-cust_pkg-status.html' ) %> + <% include( '/elements/tr-select-pkg_class.html', '', 'pre_options' => [ '0' => 'all' ], 'empty_label' => '(empty class)', ) %> - <% #include( '/elements/tr-selectmultiple-part_pkg.html' ) %> +% #include( '/elements/tr-selectmultiple-part_pkg.html' ) + <TR> <TD ALIGN="right" VALIGN="center">Next bill date</TD> <TD> <TABLE> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <% include( '/elements/tr-input-beginning_ending.html' ) %> </TABLE> </TD> </TR> @@ -35,7 +36,7 @@ <TR> <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH> </TR> - <%= include( '/elements/tr-select-cust-fields.html' ) %> + <% include( '/elements/tr-select-cust-fields.html' ) %> </TABLE> @@ -44,4 +45,4 @@ </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/report_prepaid_income.cgi b/httemplate/search/report_prepaid_income.cgi index f18224fd1..241e8a008 100644 --- a/httemplate/search/report_prepaid_income.cgi +++ b/httemplate/search/report_prepaid_income.cgi @@ -1,75 +1,76 @@ <!-- mason kludge --> -<% - - #doesn't yet deal with daily/weekly packages - - #needs to be re-written in sql for efficiency - - my $time = time; - - my $now = $cgi->param('date') && str2time($cgi->param('date')) || $time; - $now =~ /^(\d+)$/ or die "unparsable date?"; - $now = $1; - - my( $total, $total_legacy ) = ( 0, 0 ); - - my @cust_bill_pkg = - grep { $_->cust_pkg && $_->cust_pkg->part_pkg->freq !~ /^([01]|\d+[dw])$/ } - qsearch( 'cust_bill_pkg', { - 'recur' => { op=>'!=', value=>0 }, - 'edate' => { op=>'>', value=>$now }, - }, ); - - my @cust_pkg = - grep { $_->part_pkg->recur != 0 - && $_->part_pkg->freq !~ /^([01]|\d+[dw])$/ - } - qsearch ( 'cust_pkg', { - 'bill' => { op=>'>', value=>$now } - } ); - - foreach my $cust_bill_pkg ( @cust_bill_pkg) { - my $period = $cust_bill_pkg->edate - $cust_bill_pkg->sdate; - - my $elapsed = $now - $cust_bill_pkg->sdate; - $elapsed = 0 if $elapsed < 0; - - my $remaining = 1 - $elapsed/$period; - - my $unearned = $remaining * $cust_bill_pkg->recur; - $total += $unearned; - - } - - foreach my $cust_pkg ( @cust_pkg ) { - my $period = $cust_pkg->bill - $cust_pkg->last_bill; - - my $elapsed = $now - $cust_pkg->last_bill; - $elapsed = 0 if $elapsed < 0; - - my $remaining = 1 - $elapsed/$period; - - my $unearned = $remaining * $cust_pkg->part_pkg->recur; #!! only works for flat/legacy - $total_legacy += $unearned; - - } - - $total = sprintf('%.2f', $total); - $total_legacy = sprintf('%.2f', $total_legacy); - -%> - -<%= include("/elements/header.html", 'Prepaid Income (Unearned Revenue) Report', +% +% +% #doesn't yet deal with daily/weekly packages +% +% #needs to be re-written in sql for efficiency +% +% my $time = time; +% +% my $now = $cgi->param('date') && str2time($cgi->param('date')) || $time; +% $now =~ /^(\d+)$/ or die "unparsable date?"; +% $now = $1; +% +% my( $total, $total_legacy ) = ( 0, 0 ); +% +% my @cust_bill_pkg = +% grep { $_->cust_pkg && $_->cust_pkg->part_pkg->freq !~ /^([01]|\d+[dw])$/ } +% qsearch( 'cust_bill_pkg', { +% 'recur' => { op=>'!=', value=>0 }, +% 'edate' => { op=>'>', value=>$now }, +% }, ); +% +% my @cust_pkg = +% grep { $_->part_pkg->recur != 0 +% && $_->part_pkg->freq !~ /^([01]|\d+[dw])$/ +% } +% qsearch ( 'cust_pkg', { +% 'bill' => { op=>'>', value=>$now } +% } ); +% +% foreach my $cust_bill_pkg ( @cust_bill_pkg) { +% my $period = $cust_bill_pkg->edate - $cust_bill_pkg->sdate; +% +% my $elapsed = $now - $cust_bill_pkg->sdate; +% $elapsed = 0 if $elapsed < 0; +% +% my $remaining = 1 - $elapsed/$period; +% +% my $unearned = $remaining * $cust_bill_pkg->recur; +% $total += $unearned; +% +% } +% +% foreach my $cust_pkg ( @cust_pkg ) { +% my $period = $cust_pkg->bill - $cust_pkg->last_bill; +% +% my $elapsed = $now - $cust_pkg->last_bill; +% $elapsed = 0 if $elapsed < 0; +% +% my $remaining = 1 - $elapsed/$period; +% +% my $unearned = $remaining * $cust_pkg->part_pkg->recur; #!! only works for flat/legacy +% $total_legacy += $unearned; +% +% } +% +% $total = sprintf('%.2f', $total); +% $total_legacy = sprintf('%.2f', $total_legacy); +% +% + + +<% include("/elements/header.html", 'Prepaid Income (Unearned Revenue) Report', menubar( 'Main Menu'=>$p, ) ) %> -<%= table() %> +<% table() %> <TR> <TH>Actual Unearned Revenue</TH> <TH>Legacy Unearned Revenue</TH> </TR> <TR> - <TD ALIGN="right">$<%= $total %> + <TD ALIGN="right">$<% $total %> <TD ALIGN="right"> - <%= $now == $time ? "\$$total_legacy" : '<i>N/A</i>'%> + <% $now == $time ? "\$$total_legacy" : '<i>N/A</i>'%> </TD> </TR> diff --git a/httemplate/search/report_prepaid_income.html b/httemplate/search/report_prepaid_income.html index 4359918f9..305441db7 100644 --- a/httemplate/search/report_prepaid_income.html +++ b/httemplate/search/report_prepaid_income.html @@ -1,4 +1,4 @@ -<%= include('/elements/header.html', 'Prepaid Income (Unearned Revenue) Report', +<% include('/elements/header.html', 'Prepaid Income (Unearned Revenue) Report', '', '', '<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2"> @@ -34,4 +34,4 @@ <INPUT TYPE="submit" VALUE="Generate report"> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 3052ea93c..4074f2680 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -1,139 +1,140 @@ -<% - - sub owed { - my($start, $end, %opt) = @_; - - my @where = (); - - #handle start and end ranges - - #24h * 60m * 60s - push @where, "cust_bill._date <= extract(epoch from now())-". - ($start * 86400) - if $start; - - push @where, "cust_bill._date > extract(epoch from now()) - ". - ($end * 86400) - if $end; - - #handle 'cust' option - - push @where, "cust_main.custnum = cust_bill.custnum" - if $opt{'cust'}; - - #handle 'agentnum' option - my $join = ''; - if ( $opt{'agentnum'} ) { - $join = 'LEFT JOIN cust_main USING ( custnum )'; - push @where, "agentnum = '$opt{'agentnum'}'"; - } - - my $where = scalar(@where) ? 'WHERE '.join(' AND ', @where) : ''; - - my $as = $opt{'noas'} ? '' : "as owed_${start}_$end"; - - my $charged = <<END; - sum( charged - - coalesce( - ( select sum(amount) from cust_bill_pay - where cust_bill.invnum = cust_bill_pay.invnum ) - ,0 - ) - - coalesce( - ( select sum(amount) from cust_credit_bill - where cust_bill.invnum = cust_credit_bill.invnum ) - ,0 - ) - - ) -END - - "coalesce( ( select $charged from cust_bill $join $where ) ,0 ) $as"; - - } - - my @ranges = ( - [ 0, 30 ], - [ 30, 60 ], - [ 60, 90 ], - [ 90, 0 ], - [ 0, 0 ], - ); - - my $owed_cols = join(',', map owed( @$_, 'cust'=>1 ), @ranges ); - - my $select_count_pkgs = FS::cust_main->select_count_pkgs_sql; - - my $active_sql = FS::cust_pkg->active_sql; - my $inactive_sql = FS::cust_pkg->inactive_sql; - my $suspended_sql = FS::cust_pkg->inactive_sql; - my $cancelled_sql = FS::cust_pkg->inactive_sql; - - my $packages_cols = <<END; - ( $select_count_pkgs ) AS num_pkgs_sql, - ( $select_count_pkgs AND $active_sql ) AS active_pkgs, - ( $select_count_pkgs AND $inactive_sql ) AS inactive_pkgs, - ( $select_count_pkgs AND $suspended_sql ) AS suspended_pkgs, - ( $select_count_pkgs AND $cancelled_sql ) AS cancelled_pkgs -END - - my $where = "where ". owed(0, 0, 'cust'=>1, 'noas'=>1). " > 0"; - - my $agentnum = ''; - if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - $agentnum = $1; - $where .= " AND agentnum = '$agentnum' "; - } - - #here is the agent virtualization - $where .= ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql; - - my $count_sql = "select count(*) from cust_main $where"; - - my $sql_query = { - 'table' => 'cust_main', - 'hashref' => {}, - 'select' => "*, $owed_cols, $packages_cols", - 'extra_sql' => "$where order by coalesce(lower(company), ''), lower(last)", - }; - - my $total_sql = "select ". - join(',', map owed( @$_, 'agentnum'=>$agentnum ), @ranges ); - - my $total_sth = dbh->prepare($total_sql) or die dbh->errstr; - $total_sth->execute or die "error executing $total_sql: ". $total_sth->errstr; - my $row = $total_sth->fetchrow_hashref(); - - my $conf = new FS::Conf; - my $money_char = $conf->config('money_char') || '$'; - - my $align = join('', map { /#/ ? 'r' : 'l' } FS::UI::Web::cust_header() ). - 'crrrrr'; - - my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; - - my $status_statuscol = sub { - #conceptual false laziness with cust_main::status... - my $row = shift; - - my $status = 'unknown'; - if ( $row->num_pkgs_sql == 0 ) { - $status = 'prospect'; - } elsif ( $row->active_pkgs > 0 ) { - $status = 'active'; - } elsif ( $row->inactive_pkgs > 0 ) { - $status = 'inactive'; - } elsif ( $row->suspended_pkgs > 0 ) { - $status = 'suspended'; - } elsif ( $row->cancelled_pkgs > 0 ) { - $status = 'cancelled' - } - - ( ucfirst($status), $FS::cust_main::statuscolor{$status} ); - }; - - -%><%= include( 'elements/search.html', +% +% +% sub owed { +% my($start, $end, %opt) = @_; +% +% my @where = (); +% +% #handle start and end ranges +% +% #24h * 60m * 60s +% push @where, "cust_bill._date <= extract(epoch from now())-". +% ($start * 86400) +% if $start; +% +% push @where, "cust_bill._date > extract(epoch from now()) - ". +% ($end * 86400) +% if $end; +% +% #handle 'cust' option +% +% push @where, "cust_main.custnum = cust_bill.custnum" +% if $opt{'cust'}; +% +% #handle 'agentnum' option +% my $join = ''; +% if ( $opt{'agentnum'} ) { +% $join = 'LEFT JOIN cust_main USING ( custnum )'; +% push @where, "agentnum = '$opt{'agentnum'}'"; +% } +% +% my $where = scalar(@where) ? 'WHERE '.join(' AND ', @where) : ''; +% +% my $as = $opt{'noas'} ? '' : "as owed_${start}_$end"; +% +% my $charged = <<END; +% sum( charged +% - coalesce( +% ( select sum(amount) from cust_bill_pay +% where cust_bill.invnum = cust_bill_pay.invnum ) +% ,0 +% ) +% - coalesce( +% ( select sum(amount) from cust_credit_bill +% where cust_bill.invnum = cust_credit_bill.invnum ) +% ,0 +% ) +% +% ) +%END +% +% "coalesce( ( select $charged from cust_bill $join $where ) ,0 ) $as"; +% +% } +% +% my @ranges = ( +% [ 0, 30 ], +% [ 30, 60 ], +% [ 60, 90 ], +% [ 90, 0 ], +% [ 0, 0 ], +% ); +% +% my $owed_cols = join(',', map owed( @$_, 'cust'=>1 ), @ranges ); +% +% my $select_count_pkgs = FS::cust_main->select_count_pkgs_sql; +% +% my $active_sql = FS::cust_pkg->active_sql; +% my $inactive_sql = FS::cust_pkg->inactive_sql; +% my $suspended_sql = FS::cust_pkg->inactive_sql; +% my $cancelled_sql = FS::cust_pkg->inactive_sql; +% +% my $packages_cols = <<END; +% ( $select_count_pkgs ) AS num_pkgs_sql, +% ( $select_count_pkgs AND $active_sql ) AS active_pkgs, +% ( $select_count_pkgs AND $inactive_sql ) AS inactive_pkgs, +% ( $select_count_pkgs AND $suspended_sql ) AS suspended_pkgs, +% ( $select_count_pkgs AND $cancelled_sql ) AS cancelled_pkgs +%END +% +% my $where = "where ". owed(0, 0, 'cust'=>1, 'noas'=>1). " > 0"; +% +% my $agentnum = ''; +% if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% $agentnum = $1; +% $where .= " AND agentnum = '$agentnum' "; +% } +% +% #here is the agent virtualization +% $where .= ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql; +% +% my $count_sql = "select count(*) from cust_main $where"; +% +% my $sql_query = { +% 'table' => 'cust_main', +% 'hashref' => {}, +% 'select' => "*, $owed_cols, $packages_cols", +% 'extra_sql' => "$where order by coalesce(lower(company), ''), lower(last)", +% }; +% +% my $total_sql = "select ". +% join(',', map owed( @$_, 'agentnum'=>$agentnum ), @ranges ); +% +% my $total_sth = dbh->prepare($total_sql) or die dbh->errstr; +% $total_sth->execute or die "error executing $total_sql: ". $total_sth->errstr; +% my $row = $total_sth->fetchrow_hashref(); +% +% my $conf = new FS::Conf; +% my $money_char = $conf->config('money_char') || '$'; +% +% my $align = join('', map { /#/ ? 'r' : 'l' } FS::UI::Web::cust_header() ). +% 'crrrrr'; +% +% my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; +% +% my $status_statuscol = sub { +% #conceptual false laziness with cust_main::status... +% my $row = shift; +% +% my $status = 'unknown'; +% if ( $row->num_pkgs_sql == 0 ) { +% $status = 'prospect'; +% } elsif ( $row->active_pkgs > 0 ) { +% $status = 'active'; +% } elsif ( $row->inactive_pkgs > 0 ) { +% $status = 'inactive'; +% } elsif ( $row->suspended_pkgs > 0 ) { +% $status = 'suspended'; +% } elsif ( $row->cancelled_pkgs > 0 ) { +% $status = 'cancelled' +% } +% +% ( ucfirst($status), $FS::cust_main::statuscolor{$status} ); +% }; +% +% +% +<% include( 'elements/search.html', 'title' => 'Accounts Receivable Aging Summary', 'name' => 'customers', 'query' => $sql_query, diff --git a/httemplate/search/report_receivables.html b/httemplate/search/report_receivables.html index fc5174116..1ae4b8e6f 100755 --- a/httemplate/search/report_receivables.html +++ b/httemplate/search/report_receivables.html @@ -1,10 +1,10 @@ -<%= include('/elements/header.html', 'Accounts Receivable Aging Summary' ) %> +<% include('/elements/header.html', 'Accounts Receivable Aging Summary' ) %> <FORM ACTION="report_receivables.cgi" METHOD="GET"> <TABLE> - <%= include( '/elements/tr-select-agent.html' ) %> + <% include( '/elements/tr-select-agent.html' ) %> </TABLE> diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 1b6f40b8a..569e6e79a 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -1,375 +1,375 @@ -<% - -my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; - -my $user = getotaker; - -my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); - -my $join_cust = " - JOIN cust_bill USING ( invnum ) - LEFT JOIN cust_main USING ( custnum ) -"; -my $from_join_cust = " - FROM cust_bill_pkg - $join_cust -"; -my $join_pkg = " - LEFT JOIN cust_pkg USING ( pkgnum ) - LEFT JOIN part_pkg USING ( pkgpart ) -"; - -my $where = "WHERE _date >= $beginning AND _date <= $ending "; -my @base_param = qw( county county state state country ); -if ( $conf->exists('tax-ship_address') ) { - - $where .= " - AND ( ( ( ship_last IS NULL OR ship_last = '' ) - AND ( county = ? OR ? = '' ) - AND ( state = ? OR ? = '' ) - AND country = ? - ) - OR ( ship_last IS NOT NULL AND ship_last != '' - AND ( ship_county = ? OR ? = '' ) - AND ( ship_state = ? OR ? = '' ) - AND ship_country = ? - ) - ) - "; - # AND payby != 'COMP' - - push @base_param, @base_param; - -} else { - - $where .= " - AND ( county = ? OR ? = '' ) - AND ( state = ? OR ? = '' ) - AND country = ? - "; - # AND payby != 'COMP' - -} - -my $agentname = ''; -if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { - my $agent = qsearchs('agent', { 'agentnum' => $1 } ); - die "agent not found" unless $agent; - $agentname = $agent->agent; - $where .= ' AND agentnum = '. $agent->agentnum; -} - -my $gotcust = " - WHERE 0 < ( SELECT COUNT(*) FROM cust_main -"; -if ( $conf->exists('tax-ship_address') ) { - - $gotcust .= " - WHERE - - ( cust_main_county.country = cust_main.country - OR cust_main_county.country = cust_main.ship_country - ) - - AND - - ( - - ( ( ship_last IS NULL OR ship_last = '' ) - AND ( cust_main_county.country = cust_main.country ) - AND ( cust_main_county.state = cust_main.state - OR cust_main_county.state = '' - OR cust_main_county.state IS NULL ) - AND ( cust_main_county.county = cust_main.county - OR cust_main_county.county = '' - OR cust_main_county.county IS NULL ) - ) - - OR - - ( ship_last IS NOT NULL AND ship_last != '' - AND ( cust_main_county.country = cust_main.ship_country ) - AND ( cust_main_county.state = cust_main.ship_state - OR cust_main_county.state = '' - OR cust_main_county.state IS NULL ) - AND ( cust_main_county.county = cust_main.ship_county - OR cust_main_county.county = '' - OR cust_main_county.county IS NULL ) - ) - - ) - - LIMIT 1 - ) - "; - -} else { - - $gotcust .= " - WHERE ( cust_main.county = cust_main_county.county - OR cust_main_county.county = '' - OR cust_main_county.county IS NULL ) - AND ( cust_main.state = cust_main_county.state - OR cust_main_county.state = '' - OR cust_main_county.state IS NULL ) - AND ( cust_main.country = cust_main_county.country ) - LIMIT 1 - ) - "; - -} - -my($total, $tot_taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); -my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0 ); -my $out = 'Out of taxable region(s)'; -my %regions = (); -foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { - #warn $r->county. ' '. $r->state. ' '. $r->country. "\n"; - - my $label = getlabel($r); - $regions{$label}->{'label'} = $label; - $regions{$label}->{'url_param'} = join(';', map "$_=".$r->$_(), qw( county state country ) ); - - my @param = @base_param; - my $mywhere = $where; - - if ( $r->taxclass ) { - $mywhere .= " AND taxclass = ? "; - push @param, 'taxclass'; - $regions{$label}->{'url_param'} .= ';taxclass='. $r->taxclass - if $cgi->param('show_taxclasses'); - } - - my $fromwhere = $from_join_cust. $join_pkg. $mywhere. " AND payby != 'COMP' "; - -# my $label = getlabel($r); -# $regions{$label}->{'label'} = $label; - - my $nottax = 'pkgnum != 0'; - - ## calculate total for this region - - my $t = scalar_sql($r, \@param, - "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere AND $nottax" - ); - $total += $t; - $regions{$label}->{'total'} += $t; - - ## calculate customer-exemption for this region - -## my $taxable = $t; - -# my($taxable, $x_cust) = (0, 0); -# foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } -# qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { -# $taxable += scalar_sql($r, \@param, -# "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" -# ); -# -# $x_cust += scalar_sql($r, \@param, -# "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" -# ); -# } - - my $x_cust = scalar_sql($r, \@param, - "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) - $fromwhere AND $nottax AND tax = 'Y' " - ); - - $exempt_cust += $x_cust; - $regions{$label}->{'exempt_cust'} += $x_cust; - - ## calculate package-exemption for this region - - my $x_pkg = scalar_sql($r, \@param, - "SELECT SUM( - ( CASE WHEN part_pkg.setuptax = 'Y' - THEN cust_bill_pkg.setup - ELSE 0 - END - ) - + - ( CASE WHEN part_pkg.recurtax = 'Y' - THEN cust_bill_pkg.recur - ELSE 0 - END - ) - ) - $fromwhere - AND $nottax - AND ( - ( part_pkg.setuptax = 'Y' AND cust_bill_pkg.setup > 0 ) - OR ( part_pkg.recurtax = 'Y' AND cust_bill_pkg.recur > 0 ) - ) - AND ( tax != 'Y' OR tax IS NULL ) - " - ); - $exempt_pkg += $x_pkg; - $regions{$label}->{'exempt_pkg'} += $x_pkg; - - ## calculate monthly exemption (texas tax) for this region - - # count up all the cust_tax_exempt_pkg records associated with - # the actual line items. - - my $x_monthly = scalar_sql($r, \@param, - "SELECT SUM(amount) - FROM cust_tax_exempt_pkg - JOIN cust_bill_pkg USING ( billpkgnum ) - $join_cust $join_pkg - $mywhere" - ); -# if ( $x_monthly ) { -# #warn $r->taxnum(). ": $x_monthly\n"; -# $taxable -= $x_monthly; -# } - - $exempt_monthly += $x_monthly; - $regions{$label}->{'exempt_monthly'} += $x_monthly; - - my $taxable = $t - $x_cust - $x_pkg - $x_monthly; - - $tot_taxable += $taxable; - $regions{$label}->{'taxable'} += $taxable; - - $owed += $taxable * ($r->tax/100); - $regions{$label}->{'owed'} += $taxable * ($r->tax/100); - - if ( defined($regions{$label}->{'rate'}) - && $regions{$label}->{'rate'} != $r->tax.'%' ) { - $regions{$label}->{'rate'} = 'variable'; - } else { - $regions{$label}->{'rate'} = $r->tax.'%'; - } - -} - -my $taxwhere = "$from_join_cust $where AND payby != 'COMP' "; -my @taxparam = @base_param; -my %base_regions = (); -#foreach my $label ( keys %regions ) { -foreach my $r ( - qsearch( 'cust_main_county', - {}, - 'DISTINCT ON (country, state, county, taxname) *', - $gotcust - ) -) { - - #warn join('-', map { $r->$_() } qw( country state county taxname ) )."\n"; - - my $label = getlabel($r); - - #my $fromwhere = $join_pkg. $where. " AND payby != 'COMP' "; - #my @param = @base_param; - - #match itemdesc if necessary! - my $named_tax = - $r->taxname - ? 'AND itemdesc = '. dbh->quote($r->taxname) - : "AND ( itemdesc IS NULL OR itemdesc = '' OR itemdesc = 'Tax' )"; - my $x = scalar_sql($r, \@taxparam, - "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $taxwhere ". - "AND pkgnum = 0 $named_tax", - ); - $tax += $x; - $regions{$label}->{'tax'} += $x; - - if ( $cgi->param('show_taxclasses') ) { - my $base_label = getlabel($r, 'no_taxclass'=>1 ); - $base_regions{$base_label}->{'label'} = $base_label; - $base_regions{$base_label}->{'url_param'} = - join(';', map "$_=".$r->$_(), qw( county state country ) ); - $base_regions{$base_label}->{'tax'} += $x; - } - -} - -#ordering -my @regions = - map $regions{$_}, - sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } - keys %regions; - -my @base_regions = - map $base_regions{$_}, - sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } - keys %base_regions; - -push @regions, { - 'label' => 'Total', - 'url_param' => '', - 'total' => $total, - 'exempt_cust' => $exempt_cust, - 'exempt_pkg' => $exempt_pkg, - 'exempt_monthly' => $exempt_monthly, - 'taxable' => $tot_taxable, - 'rate' => '', - 'owed' => $owed, - 'tax' => $tax, -}; - -#-- - -sub getlabel { - my $r = shift; - my %opt = @_; - - my $label; - if ( - $r->tax == 0 - && ! scalar( qsearch('cust_main_county', { 'state' => $r->state, - 'county' => $r->county, - 'country' => $r->country, - 'tax' => { op=>'>', value=>0 }, - } - ) - ) - - ) { - #kludge to avoid "will not stay shared" warning - my $out = 'Out of taxable region(s)'; - $label = $out; - } elsif ( $r->taxname ) { - $label = $r->taxname; -# $regions{$label}->{'taxname'} = $label; -# push @{$regions{$label}->{$_}}, $r->$_() foreach qw( county state country ); - } else { - $label = $r->country; - $label = $r->state.", $label" if $r->state; - $label = $r->county." county, $label" if $r->county; - $label = "$label (". $r->taxclass. ")" - if $r->taxclass - && $cgi->param('show_taxclasses') - && ! $opt{'no_taxclass'}; - #$label = $r->taxname. " ($label)" if $r->taxname; - } - return $label; -} - -#false laziness w/FS::Report::Table::Monthly (sub should probably be moved up -#to FS::Report or FS::Record or who the fuck knows where) -sub scalar_sql { - my( $r, $param, $sql ) = @_; - #warn "$sql\n"; - my $sth = dbh->prepare($sql) or die dbh->errstr; - $sth->execute( map $r->$_(), @$param ) - or die "Unexpected error executing statement $sql: ". $sth->errstr; - $sth->fetchrow_arrayref->[0] || 0; -} - -%> - -<% -my $dateagentlink = "begin=$beginning;end=$ending"; -$dateagentlink .= ';agentnum='. $cgi->param('agentnum') - if length($agentname); -my $baselink = $p. "search/cust_bill_pkg.cgi?$dateagentlink"; -my $exemptlink = $p. "search/cust_tax_exempt_pkg.cgi?$dateagentlink"; -%> - -<%= include("/elements/header.html", "$agentname Sales Tax Report - ". +% +% +%my $conf = new FS::Conf; +%my $money_char = $conf->config('money_char') || '$'; +% +%my $user = getotaker; +% +%my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +% +%my $join_cust = " +% JOIN cust_bill USING ( invnum ) +% LEFT JOIN cust_main USING ( custnum ) +%"; +%my $from_join_cust = " +% FROM cust_bill_pkg +% $join_cust +%"; +%my $join_pkg = " +% LEFT JOIN cust_pkg USING ( pkgnum ) +% LEFT JOIN part_pkg USING ( pkgpart ) +%"; +% +%my $where = "WHERE _date >= $beginning AND _date <= $ending "; +%my @base_param = qw( county county state state country ); +%if ( $conf->exists('tax-ship_address') ) { +% +% $where .= " +% AND ( ( ( ship_last IS NULL OR ship_last = '' ) +% AND ( county = ? OR ? = '' ) +% AND ( state = ? OR ? = '' ) +% AND country = ? +% ) +% OR ( ship_last IS NOT NULL AND ship_last != '' +% AND ( ship_county = ? OR ? = '' ) +% AND ( ship_state = ? OR ? = '' ) +% AND ship_country = ? +% ) +% ) +% "; +% # AND payby != 'COMP' +% +% push @base_param, @base_param; +% +%} else { +% +% $where .= " +% AND ( county = ? OR ? = '' ) +% AND ( state = ? OR ? = '' ) +% AND country = ? +% "; +% # AND payby != 'COMP' +% +%} +% +%my $agentname = ''; +%if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { +% my $agent = qsearchs('agent', { 'agentnum' => $1 } ); +% die "agent not found" unless $agent; +% $agentname = $agent->agent; +% $where .= ' AND agentnum = '. $agent->agentnum; +%} +% +%my $gotcust = " +% WHERE 0 < ( SELECT COUNT(*) FROM cust_main +%"; +%if ( $conf->exists('tax-ship_address') ) { +% +% $gotcust .= " +% WHERE +% +% ( cust_main_county.country = cust_main.country +% OR cust_main_county.country = cust_main.ship_country +% ) +% +% AND +% +% ( +% +% ( ( ship_last IS NULL OR ship_last = '' ) +% AND ( cust_main_county.country = cust_main.country ) +% AND ( cust_main_county.state = cust_main.state +% OR cust_main_county.state = '' +% OR cust_main_county.state IS NULL ) +% AND ( cust_main_county.county = cust_main.county +% OR cust_main_county.county = '' +% OR cust_main_county.county IS NULL ) +% ) +% +% OR +% +% ( ship_last IS NOT NULL AND ship_last != '' +% AND ( cust_main_county.country = cust_main.ship_country ) +% AND ( cust_main_county.state = cust_main.ship_state +% OR cust_main_county.state = '' +% OR cust_main_county.state IS NULL ) +% AND ( cust_main_county.county = cust_main.ship_county +% OR cust_main_county.county = '' +% OR cust_main_county.county IS NULL ) +% ) +% +% ) +% +% LIMIT 1 +% ) +% "; +% +%} else { +% +% $gotcust .= " +% WHERE ( cust_main.county = cust_main_county.county +% OR cust_main_county.county = '' +% OR cust_main_county.county IS NULL ) +% AND ( cust_main.state = cust_main_county.state +% OR cust_main_county.state = '' +% OR cust_main_county.state IS NULL ) +% AND ( cust_main.country = cust_main_county.country ) +% LIMIT 1 +% ) +% "; +% +%} +% +%my($total, $tot_taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); +%my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0 ); +%my $out = 'Out of taxable region(s)'; +%my %regions = (); +%foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { +% #warn $r->county. ' '. $r->state. ' '. $r->country. "\n"; +% +% my $label = getlabel($r); +% $regions{$label}->{'label'} = $label; +% $regions{$label}->{'url_param'} = join(';', map "$_=".$r->$_(), qw( county state country ) ); +% +% my @param = @base_param; +% my $mywhere = $where; +% +% if ( $r->taxclass ) { +% $mywhere .= " AND taxclass = ? "; +% push @param, 'taxclass'; +% $regions{$label}->{'url_param'} .= ';taxclass='. $r->taxclass +% if $cgi->param('show_taxclasses'); +% } +% +% my $fromwhere = $from_join_cust. $join_pkg. $mywhere. " AND payby != 'COMP' "; +% +%# my $label = getlabel($r); +%# $regions{$label}->{'label'} = $label; +% +% my $nottax = 'pkgnum != 0'; +% +% ## calculate total for this region +% +% my $t = scalar_sql($r, \@param, +% "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere AND $nottax" +% ); +% $total += $t; +% $regions{$label}->{'total'} += $t; +% +% ## calculate customer-exemption for this region +% +%## my $taxable = $t; +% +%# my($taxable, $x_cust) = (0, 0); +%# foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i } +%# qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) { +%# $taxable += scalar_sql($r, \@param, +%# "SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )" +%# ); +%# +%# $x_cust += scalar_sql($r, \@param, +%# "SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'" +%# ); +%# } +% +% my $x_cust = scalar_sql($r, \@param, +% "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) +% $fromwhere AND $nottax AND tax = 'Y' " +% ); +% +% $exempt_cust += $x_cust; +% $regions{$label}->{'exempt_cust'} += $x_cust; +% +% ## calculate package-exemption for this region +% +% my $x_pkg = scalar_sql($r, \@param, +% "SELECT SUM( +% ( CASE WHEN part_pkg.setuptax = 'Y' +% THEN cust_bill_pkg.setup +% ELSE 0 +% END +% ) +% + +% ( CASE WHEN part_pkg.recurtax = 'Y' +% THEN cust_bill_pkg.recur +% ELSE 0 +% END +% ) +% ) +% $fromwhere +% AND $nottax +% AND ( +% ( part_pkg.setuptax = 'Y' AND cust_bill_pkg.setup > 0 ) +% OR ( part_pkg.recurtax = 'Y' AND cust_bill_pkg.recur > 0 ) +% ) +% AND ( tax != 'Y' OR tax IS NULL ) +% " +% ); +% $exempt_pkg += $x_pkg; +% $regions{$label}->{'exempt_pkg'} += $x_pkg; +% +% ## calculate monthly exemption (texas tax) for this region +% +% # count up all the cust_tax_exempt_pkg records associated with +% # the actual line items. +% +% my $x_monthly = scalar_sql($r, \@param, +% "SELECT SUM(amount) +% FROM cust_tax_exempt_pkg +% JOIN cust_bill_pkg USING ( billpkgnum ) +% $join_cust $join_pkg +% $mywhere" +% ); +%# if ( $x_monthly ) { +%# #warn $r->taxnum(). ": $x_monthly\n"; +%# $taxable -= $x_monthly; +%# } +% +% $exempt_monthly += $x_monthly; +% $regions{$label}->{'exempt_monthly'} += $x_monthly; +% +% my $taxable = $t - $x_cust - $x_pkg - $x_monthly; +% +% $tot_taxable += $taxable; +% $regions{$label}->{'taxable'} += $taxable; +% +% $owed += $taxable * ($r->tax/100); +% $regions{$label}->{'owed'} += $taxable * ($r->tax/100); +% +% if ( defined($regions{$label}->{'rate'}) +% && $regions{$label}->{'rate'} != $r->tax.'%' ) { +% $regions{$label}->{'rate'} = 'variable'; +% } else { +% $regions{$label}->{'rate'} = $r->tax.'%'; +% } +% +%} +% +%my $taxwhere = "$from_join_cust $where AND payby != 'COMP' "; +%my @taxparam = @base_param; +%my %base_regions = (); +%#foreach my $label ( keys %regions ) { +%foreach my $r ( +% qsearch( 'cust_main_county', +% {}, +% 'DISTINCT ON (country, state, county, taxname) *', +% $gotcust +% ) +%) { +% +% #warn join('-', map { $r->$_() } qw( country state county taxname ) )."\n"; +% +% my $label = getlabel($r); +% +% #my $fromwhere = $join_pkg. $where. " AND payby != 'COMP' "; +% #my @param = @base_param; +% +% #match itemdesc if necessary! +% my $named_tax = +% $r->taxname +% ? 'AND itemdesc = '. dbh->quote($r->taxname) +% : "AND ( itemdesc IS NULL OR itemdesc = '' OR itemdesc = 'Tax' )"; +% my $x = scalar_sql($r, \@taxparam, +% "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $taxwhere ". +% "AND pkgnum = 0 $named_tax", +% ); +% $tax += $x; +% $regions{$label}->{'tax'} += $x; +% +% if ( $cgi->param('show_taxclasses') ) { +% my $base_label = getlabel($r, 'no_taxclass'=>1 ); +% $base_regions{$base_label}->{'label'} = $base_label; +% $base_regions{$base_label}->{'url_param'} = +% join(';', map "$_=".$r->$_(), qw( county state country ) ); +% $base_regions{$base_label}->{'tax'} += $x; +% } +% +%} +% +%#ordering +%my @regions = +% map $regions{$_}, +% sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } +% keys %regions; +% +%my @base_regions = +% map $base_regions{$_}, +% sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } +% keys %base_regions; +% +%push @regions, { +% 'label' => 'Total', +% 'url_param' => '', +% 'total' => $total, +% 'exempt_cust' => $exempt_cust, +% 'exempt_pkg' => $exempt_pkg, +% 'exempt_monthly' => $exempt_monthly, +% 'taxable' => $tot_taxable, +% 'rate' => '', +% 'owed' => $owed, +% 'tax' => $tax, +%}; +% +%#-- +% +%sub getlabel { +% my $r = shift; +% my %opt = @_; +% +% my $label; +% if ( +% $r->tax == 0 +% && ! scalar( qsearch('cust_main_county', { 'state' => $r->state, +% 'county' => $r->county, +% 'country' => $r->country, +% 'tax' => { op=>'>', value=>0 }, +% } +% ) +% ) +% +% ) { +% #kludge to avoid "will not stay shared" warning +% my $out = 'Out of taxable region(s)'; +% $label = $out; +% } elsif ( $r->taxname ) { +% $label = $r->taxname; +%# $regions{$label}->{'taxname'} = $label; +%# push @{$regions{$label}->{$_}}, $r->$_() foreach qw( county state country ); +% } else { +% $label = $r->country; +% $label = $r->state.", $label" if $r->state; +% $label = $r->county." county, $label" if $r->county; +% $label = "$label (". $r->taxclass. ")" +% if $r->taxclass +% && $cgi->param('show_taxclasses') +% && ! $opt{'no_taxclass'}; +% #$label = $r->taxname. " ($label)" if $r->taxname; +% } +% return $label; +%} +% +%#false laziness w/FS::Report::Table::Monthly (sub should probably be moved up +%#to FS::Report or FS::Record or who the fuck knows where) +%sub scalar_sql { +% my( $r, $param, $sql ) = @_; +% #warn "$sql\n"; +% my $sth = dbh->prepare($sql) or die dbh->errstr; +% $sth->execute( map $r->$_(), @$param ) +% or die "Unexpected error executing statement $sql: ". $sth->errstr; +% $sth->fetchrow_arrayref->[0] || 0; +%} +% +% +% +%my $dateagentlink = "begin=$beginning;end=$ending"; +%$dateagentlink .= ';agentnum='. $cgi->param('agentnum') +% if length($agentname); +%my $baselink = $p. "search/cust_bill_pkg.cgi?$dateagentlink"; +%my $exemptlink = $p. "search/cust_tax_exempt_pkg.cgi?$dateagentlink"; +% + + +<% include("/elements/header.html", "$agentname Sales Tax Report - ". ( $beginning ? time2str('%h %o %Y ', $beginning ) : '' @@ -383,7 +383,7 @@ my $exemptlink = $p. "search/cust_tax_exempt_pkg.cgi?$dateagentlink"; ) %> -<%= include('/elements/table-grid.html') %> +<% include('/elements/table-grid.html') %> <TR> <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2></TH> @@ -392,9 +392,11 @@ my $exemptlink = $p. "search/cust_tax_exempt_pkg.cgi?$dateagentlink"; <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Rate</TH> <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2></TH> <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Tax owed</TH> - <% unless ( $cgi->param('show_taxclasses') ) { %> +% unless ( $cgi->param('show_taxclasses') ) { + <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Tax invoiced</TH> - <% } %> +% } + </TR> <TR> <TH CLASS="grid" BGCOLOR="#cccccc">Total</TH> @@ -407,130 +409,129 @@ my $exemptlink = $p. "search/cust_tax_exempt_pkg.cgi?$dateagentlink"; <TH CLASS="grid" BGCOLOR="#cccccc"></TH> <TH CLASS="grid" BGCOLOR="#cccccc">Taxable</TH> </TR> - -<% my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor; -%> - - <% foreach my $region ( @regions ) { - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - - my $link = ''; - if ( $region->{'label'} ne 'Total' ) { - if ( $region->{'label'} eq $out ) { - $link = ';out=1'; - } else { - $link = ';'. $region->{'url_param'}; - } - } +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor; +% +% foreach my $region ( @regions ) { +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% my $link = ''; +% if ( $region->{'label'} ne 'Total' ) { +% if ( $region->{'label'} eq $out ) { +% $link = ';out=1'; +% } else { +% $link = ';'. $region->{'url_param'}; +% } +% } +% +% +% +% +% - - - %> - <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $region->{'label'} %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $baselink. $link %>;nottax=1"><%= $money_char %><%= sprintf('%.2f', $region->{'total'} ) %></A> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $region->{'label'} %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <A HREF="<% $baselink. $link %>;nottax=1"><% $money_char %><% sprintf('%.2f', $region->{'total'} ) %></A> </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $baselink. $link %>;nottax=1;cust_tax=Y"><%= $money_char %><%= sprintf('%.2f', $region->{'exempt_cust'} ) %></A> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <A HREF="<% $baselink. $link %>;nottax=1;cust_tax=Y"><% $money_char %><% sprintf('%.2f', $region->{'exempt_cust'} ) %></A> </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $baselink. $link %>;nottax=1;pkg_tax=Y"><%= $money_char %><%= sprintf('%.2f', $region->{'exempt_pkg'} ) %></A> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <A HREF="<% $baselink. $link %>;nottax=1;pkg_tax=Y"><% $money_char %><% sprintf('%.2f', $region->{'exempt_pkg'} ) %></A> </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $exemptlink. $link %>"><%= $money_char %><%= sprintf('%.2f', $region->{'exempt_monthly'} ) %></A> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><FONT SIZE="+1"><B> - </B></FONT></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <A HREF="<% $exemptlink. $link %>"><% $money_char %><% sprintf('%.2f', $region->{'exempt_monthly'} ) %></A> </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><FONT SIZE="+1"><B> = </B></FONT></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <%= $money_char %><%= sprintf('%.2f', $region->{'taxable'} ) %></A> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><FONT SIZE="+1"><B> = </B></FONT></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <% $money_char %><% sprintf('%.2f', $region->{'taxable'} ) %></A> </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $region->{'label'} eq 'Total' ? '' : '<FONT FACE="sans-serif" SIZE="+1"><B> X </B></FONT>' %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"><%= $region->{'rate'} %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $region->{'label'} eq 'Total' ? '' : '<FONT FACE="sans-serif" SIZE="+1"><B> = </B></FONT>' %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <%= $money_char %><%= sprintf('%.2f', $region->{'owed'} ) %> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $region->{'label'} eq 'Total' ? '' : '<FONT FACE="sans-serif" SIZE="+1"><B> X </B></FONT>' %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"><% $region->{'rate'} %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $region->{'label'} eq 'Total' ? '' : '<FONT FACE="sans-serif" SIZE="+1"><B> = </B></FONT>' %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <% $money_char %><% sprintf('%.2f', $region->{'owed'} ) %> </TD> - <% unless ( $cgi->param('show_taxclasses') ) { %> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $baselink. $link %>;istax=1"><%= $money_char %><%= sprintf('%.2f', $region->{'tax'} ) %></A> +% unless ( $cgi->param('show_taxclasses') ) { + + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <A HREF="<% $baselink. $link %>;istax=1"><% $money_char %><% sprintf('%.2f', $region->{'tax'} ) %></A> </TD> - <% } %> +% } + </TR> - - <% } %> +% } -</TABLE> +</TABLE> +% if ( $cgi->param('show_taxclasses') ) { -<% if ( $cgi->param('show_taxclasses') ) { %> <BR> - <%= include('/elements/table-grid.html') %> + <% include('/elements/table-grid.html') %> <TR> <TH CLASS="grid" BGCOLOR="#cccccc"></TH> <TH CLASS="grid" BGCOLOR="#cccccc">Tax invoiced</TH> </TR> +% #some false laziness w/above +% $bgcolor1 = '#eeeeee'; +% $bgcolor2 = '#ffffff'; +% foreach my $region ( @base_regions ) { +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% my $link = ''; +% #if ( $region->{'label'} ne 'Total' ) { +% if ( $region->{'label'} eq $out ) { +% $link = ';out=1'; +% } else { +% $link = ';'. $region->{'url_param'}; +% } +% #} +% - <% #some false laziness w/above - $bgcolor1 = '#eeeeee'; - $bgcolor2 = '#ffffff'; - foreach my $region ( @base_regions ) { - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - - my $link = ''; - #if ( $region->{'label'} ne 'Total' ) { - if ( $region->{'label'} eq $out ) { - $link = ';out=1'; - } else { - $link = ';'. $region->{'url_param'}; - } - #} - %> <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $region->{'label'} %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $baselink. $link %>;istax=1"><%= $money_char %><%= sprintf('%.2f', $region->{'tax'} ) %></A> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $region->{'label'} %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <A HREF="<% $baselink. $link %>;istax=1"><% $money_char %><% sprintf('%.2f', $region->{'tax'} ) %></A> </TD> </TR> +% } +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% - <% } %> - - <% - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - %> <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">Total</TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"> - <A HREF="<%= $baselink %>;istax=1"><%= $money_char %><%= sprintf('%.2f', $tax ) %></A> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">Total</TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"> + <A HREF="<% $baselink %>;istax=1"><% $money_char %><% sprintf('%.2f', $tax ) %></A> </TD> </TR> </TABLE> +% } -<% } %> </BODY> </HTML> diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html index bdeb8e237..6e78d354a 100755 --- a/httemplate/search/report_tax.html +++ b/httemplate/search/report_tax.html @@ -1,30 +1,31 @@ -<%= include('/elements/header.html', 'Tax Report' ) %> +<% include('/elements/header.html', 'Tax Report' ) %> <FORM ACTION="report_tax.cgi" METHOD="GET"> <TABLE> - <%= include( '/elements/tr-select-agent.html' ) %> + <% include( '/elements/tr-select-agent.html' ) %> - <%= include( '/elements/tr-input-beginning_ending.html' ) %> + <% include( '/elements/tr-input-beginning_ending.html' ) %> +% my $conf = new FS::Conf; +% if ( $conf->exists('enable_taxclasses') ) { +% - <% my $conf = new FS::Conf; - if ( $conf->exists('enable_taxclasses') ) { - %> <TR> <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="show_taxclasses" VALUE="1"></TD> <TD>Show tax classes</TD> </TR> - <% } %> +% } +% my @pkg_class = qsearch('pkg_class', {}); +% if ( @pkg_class ) { +% - <% my @pkg_class = qsearch('pkg_class', {}); - if ( @pkg_class ) { - %> <TR> <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="show_pkgclasses" VALUE="1"></TD> <TD>Show package classes</TD> </TR> - <% } %> +% } + </TABLE> @@ -32,4 +33,4 @@ </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/sql.html b/httemplate/search/sql.html index b28c045d1..681a95d60 100644 --- a/httemplate/search/sql.html +++ b/httemplate/search/sql.html @@ -1,4 +1,4 @@ -<%= include( 'elements/search.html', +<% include( 'elements/search.html', 'title' => 'Query Results', 'name' => 'rows', 'query' => 'SELECT '. ( $cgi->param('sql') diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index b84df1a03..caa2454e9 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -1,290 +1,296 @@ -<%= include( '/elements/header.html', 'RADIUS Sessions', +<% include( '/elements/header.html', 'RADIUS Sessions', include('/elements/menubar.html', 'Main menu' => $p, # popurl(2), ), ) %> +% +% ### +% # parse cgi params +% ### +% +% #sort of false laziness w/cust_pay.cgi +% my $beginning = ''; +% my $ending = ''; +% if ( $cgi->param('beginning') +% && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { +% $beginning = str2time($1); +% } +% if ( $cgi->param('ending') +% && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { +% $ending = str2time($1) + 86399; +% } +% if ( $cgi->param('begin') && $cgi->param('begin') =~ /^(\d+)$/ ) { +% $beginning = $1; +% } +% if ( $cgi->param('end') && $cgi->param('end') =~ /^(\d+)$/ ) { +% $ending = $1; +% } +% +% my $cgi_svc_acct = ''; +% if ( $cgi->param('svcnum') =~ /^(\d+)$/ ) { +% $cgi_svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $1 } ); +% } elsif ( $cgi->param('username') =~ /^([^@]+)\@([^@]+)$/ ) { +% my %search = { 'username' => $1 }; +% my $svc_domain = qsearchs('svc_domain', { 'domain' => $2 } ); +% if ( $svc_domain ) { +% $search{'domsvc'} = $svc_domain->svcnum; +% } else { +% delete $search{'username'}; +% } +% $cgi_svc_acct = qsearchs( 'svc_acct', \%search ) +% if keys %search; +% } elsif ( $cgi->param('username') =~ /^(.+)$/ ) { +% $cgi_svc_acct = qsearchs( 'svc_acct', { 'username' => $1 } ); +% } +% +% my $ip = ''; +% if ( $cgi->param('ip') =~ /^((\d+\.){3}\d+)$/ ) { +% $ip = $1; +% } +% +% my $prefix = $cgi->param('prefix'); +% $prefix =~ s/\D//g; +% if ( $prefix =~ /^(\d+)$/ ) { +% $prefix = $1; +% $prefix = "011$prefix" unless $prefix =~ /^1/; +% } else { +% $prefix = ''; +% } +% +% ### +% # field formatting subroutines +% ### +% +% my %user2svc_acct = (); +% my $user_format = sub { +% my ( $user, $session, $part_export ) = @_; +% +% my $svc_acct = ''; +% if ( exists $user2svc_acct{$user} ) { +% $svc_acct = $user2svc_acct{$user}; +% } else { +% my %search = (); +% if ( $part_export->exporttype eq 'sqlradius_withdomain' ) { +% my $domain; +% if ( $user =~ /^([^@]+)\@([^@]+)$/ ) { +% $search{'username'} = $1; +% $domain = $2; +% } else { +% $search{'username'} = $user; +% $domain = $session->{'realm'}; +% } +% my $svc_domain = qsearchs('svc_domain', { 'domain' => $domain } ); +% if ( $svc_domain ) { +% $search{'domsvc'} = $svc_domain->svcnum; +% } else { +% delete $search{'username'}; +% } +% } elsif ( $part_export->exporttype eq 'sqlradius' ) { +% $search{'username'} = $user; +% } else { +% die 'unknown export type '. $part_export->exporttype. +% " for $part_export\n"; +% } +% if ( keys %search ) { +% my @svc_acct = +% grep { qsearchs( 'export_svc', { +% 'exportnum' => $part_export->exportnum, +% 'svcpart' => $_->cust_svc->svcpart, +% } ) +% } qsearch( 'svc_acct', \%search ); +% if ( @svc_acct ) { +% warn 'multiple svc_acct records for user $user found; '. +% 'using first arbitrarily' +% if scalar(@svc_acct) > 1; +% $user2svc_acct{$user} = $svc_acct = shift @svc_acct; +% } +% } +% } +% +% if ( $svc_acct ) { +% my $svcnum = $svc_acct->svcnum; +% qq(<A HREF="${p}view/svc_acct.cgi?$svcnum"><B>$user</B></A>); +% } else { +% "<B>$user</B>"; +% } +% +% }; +% +% my $customer_format = sub { +% my( $unused, $session ) = @_; +% return ' ' unless exists $user2svc_acct{$session->{'username'}}; +% my $svc_acct = $user2svc_acct{$session->{'username'}}; +% my $cust_pkg = $svc_acct->cust_svc->cust_pkg; +% return ' ' unless $cust_pkg; +% my $cust_main = $cust_pkg->cust_main; +% +% qq!<A HREF="${p}view/cust_main.cgi?!. $cust_main->custnum. '">'. +% $cust_pkg->cust_main->name. '</A>'; +% }; +% +% my $time_format = sub { +% my $time = shift; +% return ' ' if $time == 0; +% my $pretty = time2str('%T%P %a %b %o %Y', $time ); +% $pretty =~ s/ (\d)(st|dn|rd|th)/$1$2/; +% $pretty; +% }; +% +% my $duration_format = sub { +% my $seconds = shift; +% my $hour = int($seconds/3600); +% my $min = int( ($seconds%3600) / 60 ); +% my $sec = $seconds%60; +% '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>'. +% '<TR><TD ALIGN="right">'. +% ( $hour ? "<B>$hour</B>h" : ' ' ). +% '</TD><TD ALIGN="right">'. +% ( ( $hour || $min ) ? "<B>$min</B>m" : ' ' ). +% '</TD><TD ALIGN="right">'. +% "<B>$sec</B>s". +% '</TD></TR></TABLE>'; +% }; +% +% my $octets_format = sub { +% my $octets = shift; +% my $megs = $octets / 1048576; +% sprintf('<B>%.3f</B> megs', $megs); +% #my $gigs = $octets / 1073741824 +% #sprintf('<B>%.3f</B> gigabytes', $gigs); +% }; +% +% ### +% # the fields +% ### +% +% tie my %fields, 'Tie::IxHash', +% 'username' => { +% name => 'User', +% attrib => 'UserName', +% fmt => $user_format, +% align => 'left', +% }, +% 'realm' => { +% name => 'Realm', +% attrib => 'Realm', +% align => 'left', +% }, +% 'dummy' => { +% name => 'Customer', +% attrib => '', +% fmt => $customer_format, +% align => 'left', +% }, +% 'framedipaddress' => { +% name => 'IP Address', +% attrib => 'Framed-IP-Address', +% fmt => sub { my $ip = shift; +% length($ip) ? $ip : ' '; +% }, +% align => 'right', +% }, +% 'acctstarttime' => { +% name => 'Start time', +% attrib => 'Acct-Start-Time', +% fmt => $time_format, +% align => 'left', +% }, +% 'acctstoptime' => { +% name => 'End time', +% attrib => 'Acct-Stop-Time', +% fmt => $time_format, +% align => 'left', +% }, +% 'acctsessiontime' => { +% name => 'Duration', +% attrib => 'Acct-Session-Time', +% fmt => $duration_format, +% align => 'right', +% }, +% 'acctinputoctets' => { +% name => 'Upload', # (from user)', +% attrib => 'Acct-Input-Octets', +% fmt => $octets_format, +% align => 'right', +% }, +% 'acctoutputoctets' => { +% name => 'Download', # (to user)', +% attrib => 'Acct-Output-Octets', +% fmt => $octets_format, +% align => 'right', +% }, +% ; +% $fields{$_}->{fmt} ||= sub { length($_[0]) ? shift : ' '; } +% foreach keys %fields; +% +% ### +% # and finally, display the thing +% ### +% +% foreach my $part_export ( +% #grep $_->can('usage_sessions'), qsearch( 'part_export' ) +% qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ), +% qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ) +% ) { +% %user2svc_acct = (); +% +% my $efields = tie my %efields, 'Tie::IxHash', %fields; +% delete $efields{'framedipaddress'} if $part_export->option('hide_ip'); +% if ( $part_export->option('hide_data') ) { +% delete $efields{$_} foreach qw(acctinputoctets acctoutputoctets); +% } +% if ( $part_export->option('show_called_station') ) { +% $efields->Splice(1, 0, +% 'calledstationid' => { +% 'name' => 'Destination', +% 'attrib' => 'Called-Station-ID', +% 'fmt' => +% sub { length($_[0]) ? shift : ' '; }, +% 'align' => 'left', +% }, +% ); +% } +% +% -<% - ### - # parse cgi params - ### - #sort of false laziness w/cust_pay.cgi - my $beginning = ''; - my $ending = ''; - if ( $cgi->param('beginning') - && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { - $beginning = str2time($1); - } - if ( $cgi->param('ending') - && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { - $ending = str2time($1) + 86399; - } - if ( $cgi->param('begin') && $cgi->param('begin') =~ /^(\d+)$/ ) { - $beginning = $1; - } - if ( $cgi->param('end') && $cgi->param('end') =~ /^(\d+)$/ ) { - $ending = $1; - } - - my $cgi_svc_acct = ''; - if ( $cgi->param('svcnum') =~ /^(\d+)$/ ) { - $cgi_svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $1 } ); - } elsif ( $cgi->param('username') =~ /^([^@]+)\@([^@]+)$/ ) { - my %search = { 'username' => $1 }; - my $svc_domain = qsearchs('svc_domain', { 'domain' => $2 } ); - if ( $svc_domain ) { - $search{'domsvc'} = $svc_domain->svcnum; - } else { - delete $search{'username'}; - } - $cgi_svc_acct = qsearchs( 'svc_acct', \%search ) - if keys %search; - } elsif ( $cgi->param('username') =~ /^(.+)$/ ) { - $cgi_svc_acct = qsearchs( 'svc_acct', { 'username' => $1 } ); - } - - my $ip = ''; - if ( $cgi->param('ip') =~ /^((\d+\.){3}\d+)$/ ) { - $ip = $1; - } - - my $prefix = $cgi->param('prefix'); - $prefix =~ s/\D//g; - if ( $prefix =~ /^(\d+)$/ ) { - $prefix = $1; - $prefix = "011$prefix" unless $prefix =~ /^1/; - } else { - $prefix = ''; - } - - ### - # field formatting subroutines - ### - - my %user2svc_acct = (); - my $user_format = sub { - my ( $user, $session, $part_export ) = @_; - - my $svc_acct = ''; - if ( exists $user2svc_acct{$user} ) { - $svc_acct = $user2svc_acct{$user}; - } else { - my %search = (); - if ( $part_export->exporttype eq 'sqlradius_withdomain' ) { - my $domain; - if ( $user =~ /^([^@]+)\@([^@]+)$/ ) { - $search{'username'} = $1; - $domain = $2; - } else { - $search{'username'} = $user; - $domain = $session->{'realm'}; - } - my $svc_domain = qsearchs('svc_domain', { 'domain' => $domain } ); - if ( $svc_domain ) { - $search{'domsvc'} = $svc_domain->svcnum; - } else { - delete $search{'username'}; - } - } elsif ( $part_export->exporttype eq 'sqlradius' ) { - $search{'username'} = $user; - } else { - die 'unknown export type '. $part_export->exporttype. - " for $part_export\n"; - } - if ( keys %search ) { - my @svc_acct = - grep { qsearchs( 'export_svc', { - 'exportnum' => $part_export->exportnum, - 'svcpart' => $_->cust_svc->svcpart, - } ) - } qsearch( 'svc_acct', \%search ); - if ( @svc_acct ) { - warn 'multiple svc_acct records for user $user found; '. - 'using first arbitrarily' - if scalar(@svc_acct) > 1; - $user2svc_acct{$user} = $svc_acct = shift @svc_acct; - } - } - } - - if ( $svc_acct ) { - my $svcnum = $svc_acct->svcnum; - qq(<A HREF="${p}view/svc_acct.cgi?$svcnum"><B>$user</B></A>); - } else { - "<B>$user</B>"; - } - - }; - - my $customer_format = sub { - my( $unused, $session ) = @_; - return ' ' unless exists $user2svc_acct{$session->{'username'}}; - my $svc_acct = $user2svc_acct{$session->{'username'}}; - my $cust_pkg = $svc_acct->cust_svc->cust_pkg; - return ' ' unless $cust_pkg; - my $cust_main = $cust_pkg->cust_main; - - qq!<A HREF="${p}view/cust_main.cgi?!. $cust_main->custnum. '">'. - $cust_pkg->cust_main->name. '</A>'; - }; - - my $time_format = sub { - my $time = shift; - return ' ' if $time == 0; - my $pretty = time2str('%T%P %a %b %o %Y', $time ); - $pretty =~ s/ (\d)(st|dn|rd|th)/$1$2/; - $pretty; - }; - - my $duration_format = sub { - my $seconds = shift; - my $hour = int($seconds/3600); - my $min = int( ($seconds%3600) / 60 ); - my $sec = $seconds%60; - '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>'. - '<TR><TD ALIGN="right">'. - ( $hour ? "<B>$hour</B>h" : ' ' ). - '</TD><TD ALIGN="right">'. - ( ( $hour || $min ) ? "<B>$min</B>m" : ' ' ). - '</TD><TD ALIGN="right">'. - "<B>$sec</B>s". - '</TD></TR></TABLE>'; - }; - - my $octets_format = sub { - my $octets = shift; - my $megs = $octets / 1048576; - sprintf('<B>%.3f</B> megs', $megs); - #my $gigs = $octets / 1073741824 - #sprintf('<B>%.3f</B> gigabytes', $gigs); - }; - - ### - # the fields - ### - - tie my %fields, 'Tie::IxHash', - 'username' => { - name => 'User', - attrib => 'UserName', - fmt => $user_format, - align => 'left', - }, - 'realm' => { - name => 'Realm', - attrib => 'Realm', - align => 'left', - }, - 'dummy' => { - name => 'Customer', - attrib => '', - fmt => $customer_format, - align => 'left', - }, - 'framedipaddress' => { - name => 'IP Address', - attrib => 'Framed-IP-Address', - fmt => sub { my $ip = shift; - length($ip) ? $ip : ' '; - }, - align => 'right', - }, - 'acctstarttime' => { - name => 'Start time', - attrib => 'Acct-Start-Time', - fmt => $time_format, - align => 'left', - }, - 'acctstoptime' => { - name => 'End time', - attrib => 'Acct-Stop-Time', - fmt => $time_format, - align => 'left', - }, - 'acctsessiontime' => { - name => 'Duration', - attrib => 'Acct-Session-Time', - fmt => $duration_format, - align => 'right', - }, - 'acctinputoctets' => { - name => 'Upload', # (from user)', - attrib => 'Acct-Input-Octets', - fmt => $octets_format, - align => 'right', - }, - 'acctoutputoctets' => { - name => 'Download', # (to user)', - attrib => 'Acct-Output-Octets', - fmt => $octets_format, - align => 'right', - }, - ; - $fields{$_}->{fmt} ||= sub { length($_[0]) ? shift : ' '; } - foreach keys %fields; - - ### - # and finally, display the thing - ### - - foreach my $part_export ( - #grep $_->can('usage_sessions'), qsearch( 'part_export' ) - qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ), - qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ) - ) { - %user2svc_acct = (); - - my $efields = tie my %efields, 'Tie::IxHash', %fields; - delete $efields{'framedipaddress'} if $part_export->option('hide_ip'); - if ( $part_export->option('hide_data') ) { - delete $efields{$_} foreach qw(acctinputoctets acctoutputoctets); - } - if ( $part_export->option('show_called_station') ) { - $efields->Splice(1, 0, - 'calledstationid' => { - 'name' => 'Destination', - 'attrib' => 'Called-Station-ID', - 'fmt' => - sub { length($_[0]) ? shift : ' '; }, - 'align' => 'left', - }, - ); - } - -%> - -<%= $part_export->exporttype %> to <%= $part_export->machine %><BR> -<%= include( '/elements/table.html' ) %> +<% $part_export->exporttype %> to <% $part_export->machine %><BR> +<% include( '/elements/table.html' ) %> <TR> - <% foreach my $field ( keys %efields ) { %> +% foreach my $field ( keys %efields ) { + <TH> - <%= $efields{$field}->{name} %><BR> - <FONT SIZE=-2><%= $efields{$field}->{attrib} %></FONT> + <% $efields{$field}->{name} %><BR> + <FONT SIZE=-2><% $efields{$field}->{attrib} %></FONT> </TH> - <% } %> +% } + </TR> -<% foreach my $session ( - @{ $part_export->usage_sessions( - $beginning, $ending, $cgi_svc_acct, $ip, $prefix, ) } - ) { -%> +% foreach my $session ( +% @{ $part_export->usage_sessions( +% $beginning, $ending, $cgi_svc_acct, $ip, $prefix, ) } +% ) { +% + <TR> - <% foreach my $field ( keys %efields ) { %> - <TD ALIGN="<%= $efields{$field}->{align} %>"> - <%= &{ $efields{$field}->{fmt} }( $session->{$field}, +% foreach my $field ( keys %efields ) { + + <TD ALIGN="<% $efields{$field}->{align} %>"> + <% &{ $efields{$field}->{fmt} }( $session->{$field}, $session, $part_export, ) %> </TD> - <% } %> +% } + </TR> -<% } %> +% } + </TABLE> <BR><BR> +% } -<% } %> diff --git a/httemplate/search/sqlradius.html b/httemplate/search/sqlradius.html index 645505101..c0791f1ed 100644 --- a/httemplate/search/sqlradius.html +++ b/httemplate/search/sqlradius.html @@ -1,8 +1,9 @@ -<%= include( '/elements/header.html', 'Search RADIUS sessions' ) %> +<% include( '/elements/header.html', 'Search RADIUS sessions' ) %> <FORM NAME="OneTrueForm" ACTION="sqlradius.cgi" METHOD="GET"> -<% #include( '/elements/table.html' ) %> -<%= ntable('#cccccc') %> +% #include( '/elements/table.html' ) + +<% ntable('#cccccc') %> <TR> <TD ALIGN="right">Username: </TD> <TD><INPUT TYPE="text" NAME="username"></TD> @@ -11,13 +12,12 @@ <TD></TD> <TD><FONT SIZE="-1"><I>(leave blank to show all users)</I></FONT></TD> </TR> +% my @part_export = qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ); +% push @part_export, +% qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ); +% +% if ( grep { ! $_->option('hide_ip') } @part_export ) { -<% my @part_export = qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ); - push @part_export, - qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ); -%> - -<% if ( grep { ! $_->option('hide_ip') } @part_export ) { %> <TR> <TD ALIGN="right">IP address: </TD> <TD><INPUT TYPE="text" NAME="ip"></TD> @@ -26,9 +26,9 @@ <TD></TD> <TD><FONT SIZE="-1"><I>(leave blank to show all IPs)</I></FONT></TD> </TR> -<% } %> +% } +% if ( grep { $_->option('show_called_station') } @part_export ) { -<% if ( grep { $_->option('show_called_station') } @part_export ) { %> <TR> <TD ALIGN="right">Destination prefix:</TD> <TD><INPUT TYPE="text" NAME="prefix"></TD> @@ -41,12 +41,13 @@ <TD></TD> <TD><FONT SIZE="-1"><I>(leave blank to show all destinations)</I></FONT></TD> </TR> -<% } %> +% } + -<%= include( '/elements/tr-input-beginning_ending.html' ) %> +<% include( '/elements/tr-input-beginning_ending.html' ) %> </TABLE> <BR><INPUT TYPE="submit" VALUE="View sessions"> </FORM> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/search/svc_Smart.html b/httemplate/search/svc_Smart.html index 93dbbeadd..4d8f3e20e 100644 --- a/httemplate/search/svc_Smart.html +++ b/httemplate/search/svc_Smart.html @@ -1,22 +1,29 @@ -<% +% +% +%if ( $cgi->param('search_svc') =~ /\.[a-z]{2,8}$/i ) { +% +% # looks (enough) like a domain +% +% +<% $cgi->redirect('svc_domain.cgi?domain='. uri_escape( $cgi->param('search_svc') ) ) %> +% +% +%} elsif ( $cgi->param('search_svc') =~ /\w/ ) { +% +% #looks (enough) like a username +% +% +<% $cgi->redirect('svc_acct.cgi?username_type=Exact;username='. uri_escape( $cgi->param('search_svc') ) ) %> +% +% +%} else { +% +% +<% include('/elements/header.html', 'Unrecognized service string') %> + <% include('/elements/footer.html') %> +% +% +%} +% +% -if ( $cgi->param('search_svc') =~ /\.[a-z]{2,8}$/i ) { - - # looks (enough) like a domain - - %><%= $cgi->redirect('svc_domain.cgi?domain='. uri_escape( $cgi->param('search_svc') ) ) %><% - -} elsif ( $cgi->param('search_svc') =~ /\w/ ) { - - #looks (enough) like a username - - %><%= $cgi->redirect('svc_acct.cgi?username_type=Exact;username='. uri_escape( $cgi->param('search_svc') ) ) %><% - -} else { - -%><%= include('/elements/header.html', 'Unrecognized service string') %> - <%= include('/elements/footer.html') %><% - -} - -%> diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 0f2f3ef45..d293e2455 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,119 +1,120 @@ -<% - -my $orderby = 'ORDER BY svcnum'; - -my($query)=$cgi->keywords; -$query ||= ''; #to avoid use of unitialized value errors - -my @extra_sql = (); -if ( $query =~ /^UN_(.*)$/ ) { - $query = $1; - push @extra_sql, 'pkgnum IS NULL'; -} - -if ( $query eq 'svcnum' ) { - #$orderby = "ORDER BY svcnum"; -} elsif ( $query eq 'username' ) { - $orderby = "ORDER BY LOWER(username)"; -} elsif ( $query eq 'uid' ) { - $orderby = "ORDER BY uid"; - push @extra_sql, "uid IS NOT NULL"; -} elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) { - push @extra_sql, "popnum = $1"; - $orderby = "ORDER BY LOWER(username)"; -} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { - push @extra_sql, "svcpart = $1"; - $orderby = "ORDER BY uid"; - #$orderby = "ORDER BY svcnum"; -} else { - $orderby = "ORDER BY uid"; - - my @username_sql; - - my %username_type; - foreach ( $cgi->param('username_type') ) { - $username_type{$_}++; - } - - $cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text - my $username = $1; - - push @username_sql, "username ILIKE '$username'" - if $username_type{'Exact'} - || $username_type{'Fuzzy'}; - - push @username_sql, "username ILIKE '\%$username\%'" - if $username_type{'Substring'} - || $username_type{'All'}; - - if ( $username_type{'Fuzzy'} || $username_type{'All'} ) { - &FS::svc_acct::check_and_rebuild_fuzzyfiles; - my $all_username = &FS::svc_acct::all_username; - - my %username; - if ( $username_type{'Fuzzy'} || $username_type{'All'} ) { - foreach ( amatch($username, [ qw(i) ], @$all_username) ) { - $username{$_}++; - } - } - - #if ($username_type{'Sound-alike'}) { - #} - - push @username_sql, "username = '$_'" - foreach (keys %username); - - } - - push @extra_sql, '( '. join( ' OR ', @username_sql). ' )'; - -} - -my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. - ' LEFT JOIN part_svc USING ( svcpart ) '. - ' LEFT JOIN cust_pkg USING ( pkgnum ) '. - ' LEFT JOIN cust_main USING ( custnum ) '; - -#here is the agent virtualization -push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; - -my $extra_sql = - scalar(@extra_sql) - ? ' WHERE '. join(' AND ', @extra_sql ) - : ''; - -my $count_query = "SELECT COUNT(*) FROM svc_acct $addl_from $extra_sql"; -#if ( keys %svc_acct ) { -# $count_query .= ' WHERE '. -# join(' AND ', map "$_ = ". dbh->quote($svc_acct{$_}), -# keys %svc_acct -# ); -#} - -my $sql_query = { - 'table' => 'svc_acct', - 'hashref' => {}, # \%svc_acct, - 'select' => join(', ', - 'svc_acct.*', - 'part_svc.svc', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => "$extra_sql $orderby", - 'addl_from' => $addl_from, -}; - -my $link = [ "${p}view/svc_acct.cgi?", 'svcnum' ]; -my $link_cust = sub { - my $svc_acct = shift; - if ( $svc_acct->custnum ) { - [ "${p}view/cust_main.cgi?", 'custnum' ]; - } else { - ''; - } -}; - -%><%= include( 'elements/search.html', +% +% +%my $orderby = 'ORDER BY svcnum'; +% +%my($query)=$cgi->keywords; +%$query ||= ''; #to avoid use of unitialized value errors +% +%my @extra_sql = (); +%if ( $query =~ /^UN_(.*)$/ ) { +% $query = $1; +% push @extra_sql, 'pkgnum IS NULL'; +%} +% +%if ( $query eq 'svcnum' ) { +% #$orderby = "ORDER BY svcnum"; +%} elsif ( $query eq 'username' ) { +% $orderby = "ORDER BY LOWER(username)"; +%} elsif ( $query eq 'uid' ) { +% $orderby = "ORDER BY uid"; +% push @extra_sql, "uid IS NOT NULL"; +%} elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) { +% push @extra_sql, "popnum = $1"; +% $orderby = "ORDER BY LOWER(username)"; +%} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { +% push @extra_sql, "svcpart = $1"; +% $orderby = "ORDER BY uid"; +% #$orderby = "ORDER BY svcnum"; +%} else { +% $orderby = "ORDER BY uid"; +% +% my @username_sql; +% +% my %username_type; +% foreach ( $cgi->param('username_type') ) { +% $username_type{$_}++; +% } +% +% $cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text +% my $username = $1; +% +% push @username_sql, "username ILIKE '$username'" +% if $username_type{'Exact'} +% || $username_type{'Fuzzy'}; +% +% push @username_sql, "username ILIKE '\%$username\%'" +% if $username_type{'Substring'} +% || $username_type{'All'}; +% +% if ( $username_type{'Fuzzy'} || $username_type{'All'} ) { +% &FS::svc_acct::check_and_rebuild_fuzzyfiles; +% my $all_username = &FS::svc_acct::all_username; +% +% my %username; +% if ( $username_type{'Fuzzy'} || $username_type{'All'} ) { +% foreach ( amatch($username, [ qw(i) ], @$all_username) ) { +% $username{$_}++; +% } +% } +% +% #if ($username_type{'Sound-alike'}) { +% #} +% +% push @username_sql, "username = '$_'" +% foreach (keys %username); +% +% } +% +% push @extra_sql, '( '. join( ' OR ', @username_sql). ' )'; +% +%} +% +%my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. +% ' LEFT JOIN part_svc USING ( svcpart ) '. +% ' LEFT JOIN cust_pkg USING ( pkgnum ) '. +% ' LEFT JOIN cust_main USING ( custnum ) '; +% +%#here is the agent virtualization +%push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; +% +%my $extra_sql = +% scalar(@extra_sql) +% ? ' WHERE '. join(' AND ', @extra_sql ) +% : ''; +% +%my $count_query = "SELECT COUNT(*) FROM svc_acct $addl_from $extra_sql"; +%#if ( keys %svc_acct ) { +%# $count_query .= ' WHERE '. +%# join(' AND ', map "$_ = ". dbh->quote($svc_acct{$_}), +%# keys %svc_acct +%# ); +%#} +% +%my $sql_query = { +% 'table' => 'svc_acct', +% 'hashref' => {}, # \%svc_acct, +% 'select' => join(', ', +% 'svc_acct.*', +% 'part_svc.svc', +% 'cust_main.custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'extra_sql' => "$extra_sql $orderby", +% 'addl_from' => $addl_from, +%}; +% +%my $link = [ "${p}view/svc_acct.cgi?", 'svcnum' ]; +%my $link_cust = sub { +% my $svc_acct = shift; +% if ( $svc_acct->custnum ) { +% [ "${p}view/cust_main.cgi?", 'custnum' ]; +% } else { +% ''; +% } +%}; +% +% +<% include( 'elements/search.html', 'title' => 'Account Search Results', 'name' => 'accounts', 'query' => $sql_query, diff --git a/httemplate/search/svc_broadband.cgi b/httemplate/search/svc_broadband.cgi index efadce600..ae32ccd7e 100755 --- a/httemplate/search/svc_broadband.cgi +++ b/httemplate/search/svc_broadband.cgi @@ -1,96 +1,99 @@ -<% +% +% +%my $conf = new FS::Conf; +% +%my($query)=$cgi->keywords; +%$query ||= ''; #to avoid use of unitialized value errors +%my(@svc_broadband,$sortby); +%if ( $query eq 'svcnum' ) { +% $sortby=\*svcnum_sort; +% @svc_broadband=qsearch('svc_broadband',{}); +%} elsif ( $query eq 'blocknum' ) { +% $sortby=\*blocknum_sort; +% @svc_broadband=qsearch('svc_broadband',{}); +%} else { +% $cgi->param('ip_addr') =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; +% my($ip_addr)=$1; +% @svc_broadband = qsearchs('svc_broadband',{'ip_addr'=>$ip_addr}); +%} +% +%my %routerbyblock = (); +%foreach my $router (qsearch('router', {})) { +% foreach ($router->addr_block) { +% $routerbyblock{$_->blocknum} = $router; +% } +%} +% +%if ( scalar(@svc_broadband) == 1 ) { +% print $cgi->redirect(popurl(2). "view/svc_broadband.cgi?". $svc_broadband[0]->svcnum); +% #exit; +%} elsif ( scalar(@svc_broadband) == 0 ) { +% -my $conf = new FS::Conf; - -my($query)=$cgi->keywords; -$query ||= ''; #to avoid use of unitialized value errors -my(@svc_broadband,$sortby); -if ( $query eq 'svcnum' ) { - $sortby=\*svcnum_sort; - @svc_broadband=qsearch('svc_broadband',{}); -} elsif ( $query eq 'blocknum' ) { - $sortby=\*blocknum_sort; - @svc_broadband=qsearch('svc_broadband',{}); -} else { - $cgi->param('ip_addr') =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; - my($ip_addr)=$1; - @svc_broadband = qsearchs('svc_broadband',{'ip_addr'=>$ip_addr}); -} - -my %routerbyblock = (); -foreach my $router (qsearch('router', {})) { - foreach ($router->addr_block) { - $routerbyblock{$_->blocknum} = $router; - } -} - -if ( scalar(@svc_broadband) == 1 ) { - print $cgi->redirect(popurl(2). "view/svc_broadband.cgi?". $svc_broadband[0]->svcnum); - #exit; -} elsif ( scalar(@svc_broadband) == 0 ) { -%> -<!-- mason kludge --> -<% - eidiot "No matching ip address found!\n"; -} else { -%> <!-- mason kludge --> -<% - my($total)=scalar(@svc_broadband); - print header("IP Address Search Results",''), <<END; - - $total matching broadband services found - <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0> - <TR> - <TH>Service #</TH> - <TH>Router</TH> - <TH>IP Address</TH> - </TR> -END - - foreach my $svc_broadband ( - sort $sortby (@svc_broadband) - ) { - my($svcnum,$ip_addr,$routername,$routernum)=( - $svc_broadband->svcnum, - $svc_broadband->ip_addr, - $routerbyblock{$svc_broadband->blocknum}->routername, - $routerbyblock{$svc_broadband->blocknum}->routernum, - ); - - my $rowspan = 1; - - print <<END; - <TR> - <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_broadband.cgi?$svcnum">$svcnum</A></TD> - <TD ROWSPAN=$rowspan><A HREF="${p}view/router.cgi?$routernum">$routername</A></TD> - <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_broadband.cgi?$svcnum">$ip_addr</A></TD> -END - - #print @rows; - print "</TR>"; - - } - - print <<END; - </TABLE> - </BODY> -</HTML> -END - -} - -sub svcnum_sort { - $a->getfield('svcnum') <=> $b->getfield('svcnum'); -} - -sub blocknum_sort { - if ($a->getfield('blocknum') == $b->getfield('blocknum')) { - $a->getfield('ip_addr') cmp $b->getfield('ip_addr'); - } else { - $a->getfield('blocknum') cmp $b->getfield('blocknum'); - } -} +% +% eidiot "No matching ip address found!\n"; +%} else { +% +<!-- mason kludge --> +% +% my($total)=scalar(@svc_broadband); +% print header("IP Address Search Results",''), <<END; +% +% $total matching broadband services found +% <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0> +% <TR> +% <TH>Service #</TH> +% <TH>Router</TH> +% <TH>IP Address</TH> +% </TR> +%END +% +% foreach my $svc_broadband ( +% sort $sortby (@svc_broadband) +% ) { +% my($svcnum,$ip_addr,$routername,$routernum)=( +% $svc_broadband->svcnum, +% $svc_broadband->ip_addr, +% $routerbyblock{$svc_broadband->blocknum}->routername, +% $routerbyblock{$svc_broadband->blocknum}->routernum, +% ); +% +% my $rowspan = 1; +% +% print <<END; +% <TR> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_broadband.cgi?$svcnum">$svcnum</A></TD> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/router.cgi?$routernum">$routername</A></TD> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_broadband.cgi?$svcnum">$ip_addr</A></TD> +%END +% +% #print @rows; +% print "</TR>"; +% +% } +% +% print <<END; +% </TABLE> +% </BODY> +%</HTML> +%END +% +%} +% +%sub svcnum_sort { +% $a->getfield('svcnum') <=> $b->getfield('svcnum'); +%} +% +%sub blocknum_sort { +% if ($a->getfield('blocknum') == $b->getfield('blocknum')) { +% $a->getfield('ip_addr') cmp $b->getfield('ip_addr'); +% } else { +% $a->getfield('blocknum') cmp $b->getfield('blocknum'); +% } +%} +% +% +% -%> diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index ecb77792f..85ae94a80 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,78 +1,79 @@ -<% - -my $conf = new FS::Conf; - -my($query)=$cgi->keywords; -$query ||= ''; #to avoid use of unitialized value errors - -my $orderby = 'ORDER BY svcnum'; -my %svc_domain = (); -my @extra_sql = (); -if ( $query eq 'svcnum' ) { - #$orderby = 'ORDER BY svcnum'; -} elsif ( $query eq 'domain' ) { - $orderby = 'ORDER BY domain'; -} elsif ( $query eq 'UN_svcnum' ) { #UN searches need to be acl'ed (and need to - #fix $agentnums_sql - #$orderby = 'ORDER BY svcnum'; - push @extra_sql, 'pkgnum IS NULL'; -} elsif ( $query eq 'UN_domain' ) { #UN searches need to be acl'ed (and need to - #fix $agentnums_sql - $orderby = 'ORDER BY domain'; - push @extra_sql, 'pkgnum IS NULL'; -} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { - #$orderby = 'ORDER BY svcnum'; - push @extra_sql, "svcpart = $1"; -} else { - $cgi->param('domain') =~ /^([\w\-\.]+)$/; - $svc_domain{'domain'} = $1; -} - -my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. - ' LEFT JOIN part_svc USING ( svcpart ) '. - ' LEFT JOIN cust_pkg USING ( pkgnum ) '. - ' LEFT JOIN cust_main USING ( custnum ) '; - -#here is the agent virtualization -push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; - -my $extra_sql = ''; -if ( @extra_sql ) { - $extra_sql = ( keys(%svc_domain) ? ' AND ' : ' WHERE ' ). - join(' AND ', @extra_sql ); -} - -my $count_query = "SELECT COUNT(*) FROM svc_domain $addl_from "; -if ( keys %svc_domain ) { - $count_query .= ' WHERE '. - join(' AND ', map "$_ = ". dbh->quote($svc_domain{$_}), - keys %svc_domain - ); -} -$count_query .= $extra_sql; - -my $sql_query = { - 'table' => 'svc_domain', - 'hashref' => \%svc_domain, - 'select' => join(', ', - 'svc_domain.*', - 'part_svc.svc', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => "$extra_sql $orderby", - 'addl_from' => $addl_from, -}; - -my $link = [ "${p}view/svc_domain.cgi?", 'svcnum' ]; - -#smaller false laziness w/svc_*.cgi here -my $link_cust = sub { - my $svc_x = shift; - $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; -}; - -%><%= include( 'elements/search.html', +% +% +%my $conf = new FS::Conf; +% +%my($query)=$cgi->keywords; +%$query ||= ''; #to avoid use of unitialized value errors +% +%my $orderby = 'ORDER BY svcnum'; +%my %svc_domain = (); +%my @extra_sql = (); +%if ( $query eq 'svcnum' ) { +% #$orderby = 'ORDER BY svcnum'; +%} elsif ( $query eq 'domain' ) { +% $orderby = 'ORDER BY domain'; +%} elsif ( $query eq 'UN_svcnum' ) { #UN searches need to be acl'ed (and need to +% #fix $agentnums_sql +% #$orderby = 'ORDER BY svcnum'; +% push @extra_sql, 'pkgnum IS NULL'; +%} elsif ( $query eq 'UN_domain' ) { #UN searches need to be acl'ed (and need to +% #fix $agentnums_sql +% $orderby = 'ORDER BY domain'; +% push @extra_sql, 'pkgnum IS NULL'; +%} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { +% #$orderby = 'ORDER BY svcnum'; +% push @extra_sql, "svcpart = $1"; +%} else { +% $cgi->param('domain') =~ /^([\w\-\.]+)$/; +% $svc_domain{'domain'} = $1; +%} +% +%my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. +% ' LEFT JOIN part_svc USING ( svcpart ) '. +% ' LEFT JOIN cust_pkg USING ( pkgnum ) '. +% ' LEFT JOIN cust_main USING ( custnum ) '; +% +%#here is the agent virtualization +%push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; +% +%my $extra_sql = ''; +%if ( @extra_sql ) { +% $extra_sql = ( keys(%svc_domain) ? ' AND ' : ' WHERE ' ). +% join(' AND ', @extra_sql ); +%} +% +%my $count_query = "SELECT COUNT(*) FROM svc_domain $addl_from "; +%if ( keys %svc_domain ) { +% $count_query .= ' WHERE '. +% join(' AND ', map "$_ = ". dbh->quote($svc_domain{$_}), +% keys %svc_domain +% ); +%} +%$count_query .= $extra_sql; +% +%my $sql_query = { +% 'table' => 'svc_domain', +% 'hashref' => \%svc_domain, +% 'select' => join(', ', +% 'svc_domain.*', +% 'part_svc.svc', +% 'cust_main.custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'extra_sql' => "$extra_sql $orderby", +% 'addl_from' => $addl_from, +%}; +% +%my $link = [ "${p}view/svc_domain.cgi?", 'svcnum' ]; +% +%#smaller false laziness w/svc_*.cgi here +%my $link_cust = sub { +% my $svc_x = shift; +% $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; +%}; +% +% +<% include( 'elements/search.html', 'title' => "Domain Search Results", 'name' => 'domains', 'query' => $sql_query, diff --git a/httemplate/search/svc_external.cgi b/httemplate/search/svc_external.cgi index 7968f3c43..e85d6d7b3 100755 --- a/httemplate/search/svc_external.cgi +++ b/httemplate/search/svc_external.cgi @@ -1,102 +1,105 @@ -<% - -my $conf = new FS::Conf; - -my($query)=$cgi->keywords; -$query ||= ''; #to avoid use of unitialized value errors -my(@svc_external,$sortby); -if ( $query eq 'svcnum' ) { - $sortby=\*svcnum_sort; - @svc_external=qsearch('svc_external',{}); -} elsif ( $query eq 'id' ) { - $sortby=\*id_sort; - @svc_external=qsearch('svc_external',{}); -} elsif ( $query eq 'UN_svcnum' ) { - $sortby=\*svcnum_sort; - @svc_external = grep qsearchs('cust_svc',{ - 'svcnum' => $_->svcnum, - 'pkgnum' => '', - }), qsearch('svc_external',{}); -} elsif ( $query eq 'UN_id' ) { - $sortby=\*id_sort; - @svc_external = grep qsearchs('cust_svc',{ - 'svcnum' => $_->svcnum, - 'pkgnum' => '', - }), qsearch('svc_external',{}); -} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { - @svc_external = - qsearch( 'svc_external', {}, '', - " WHERE $1 = ( SELECT svcpart FROM cust_svc ". - " WHERE cust_svc.svcnum = svc_external.svcnum ) " - ); - $sortby=\*svcnum_sort; -} else { - $cgi->param('id') =~ /^([\w\-\.]+)$/; - my($id)=$1; - #push @svc_domain, qsearchs('svc_domain',{'domain'=>$domain}); - @svc_external = qsearchs('svc_external',{'id'=>$id}); -} - -if ( scalar(@svc_external) == 1 ) { - - %><%= $cgi->redirect(popurl(2). "view/svc_external.cgi?". $svc_external[0]->svcnum) %><% - -} elsif ( scalar(@svc_external) == 0 ) { - - %><%= include('/elements/header.html', 'External Search Results' ) %> +% +% +%my $conf = new FS::Conf; +% +%my($query)=$cgi->keywords; +%$query ||= ''; #to avoid use of unitialized value errors +%my(@svc_external,$sortby); +%if ( $query eq 'svcnum' ) { +% $sortby=\*svcnum_sort; +% @svc_external=qsearch('svc_external',{}); +%} elsif ( $query eq 'id' ) { +% $sortby=\*id_sort; +% @svc_external=qsearch('svc_external',{}); +%} elsif ( $query eq 'UN_svcnum' ) { +% $sortby=\*svcnum_sort; +% @svc_external = grep qsearchs('cust_svc',{ +% 'svcnum' => $_->svcnum, +% 'pkgnum' => '', +% }), qsearch('svc_external',{}); +%} elsif ( $query eq 'UN_id' ) { +% $sortby=\*id_sort; +% @svc_external = grep qsearchs('cust_svc',{ +% 'svcnum' => $_->svcnum, +% 'pkgnum' => '', +% }), qsearch('svc_external',{}); +%} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { +% @svc_external = +% qsearch( 'svc_external', {}, '', +% " WHERE $1 = ( SELECT svcpart FROM cust_svc ". +% " WHERE cust_svc.svcnum = svc_external.svcnum ) " +% ); +% $sortby=\*svcnum_sort; +%} else { +% $cgi->param('id') =~ /^([\w\-\.]+)$/; +% my($id)=$1; +% #push @svc_domain, qsearchs('svc_domain',{'domain'=>$domain}); +% @svc_external = qsearchs('svc_external',{'id'=>$id}); +%} +% +%if ( scalar(@svc_external) == 1 ) { +% +% +<% $cgi->redirect(popurl(2). "view/svc_external.cgi?". $svc_external[0]->svcnum) %> +% +% +%} elsif ( scalar(@svc_external) == 0 ) { +% +% +<% include('/elements/header.html', 'External Search Results' ) %> No matching external services found +% } else { +% +% +<% include('/elements/header.html', 'External Search Results', '') %> -<% } else { - - %><%= include('/elements/header.html', 'External Search Results', '') %> - - <%= scalar(@svc_external) %> matching external services found + <% scalar(@svc_external) %> matching external services found <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0> <TR> <TH>Service #</TH> - <TH><%= FS::Msgcat::_gettext('svc_external-id') || 'External ID' %></TH> - <TH><%= FS::Msgcat::_gettext('svc_external-title') || 'Title' %></TH> + <TH><% FS::Msgcat::_gettext('svc_external-id') || 'External ID' %></TH> + <TH><% FS::Msgcat::_gettext('svc_external-title') || 'Title' %></TH> </TR> +% +% foreach my $svc_external ( +% sort $sortby (@svc_external) +% ) { +% my($svcnum, $id, $title)=( +% $svc_external->svcnum, +% $svc_external->id, +% $svc_external->title, +% ); +% +% my $rowspan = 1; +% +% print <<END; +% <TR> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$svcnum</A></TD> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$id</A></TD> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$title</A></TD> +%END +% +% #print @rows; +% print "</TR>"; +% +% } +% +% print <<END; +% </TABLE> +% </BODY> +%</HTML> +%END +% +%} +% +%sub svcnum_sort { +% $a->getfield('svcnum') <=> $b->getfield('svcnum'); +%} +% +%sub id_sort { +% $a->getfield('id') <=> $b->getfield('id'); +%} +% +% -<% - foreach my $svc_external ( - sort $sortby (@svc_external) - ) { - my($svcnum, $id, $title)=( - $svc_external->svcnum, - $svc_external->id, - $svc_external->title, - ); - - my $rowspan = 1; - - print <<END; - <TR> - <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$svcnum</A></TD> - <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$id</A></TD> - <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$title</A></TD> -END - - #print @rows; - print "</TR>"; - - } - - print <<END; - </TABLE> - </BODY> -</HTML> -END - -} - -sub svcnum_sort { - $a->getfield('svcnum') <=> $b->getfield('svcnum'); -} - -sub id_sort { - $a->getfield('id') <=> $b->getfield('id'); -} - -%> diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index d391a1834..dc002d96a 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -1,103 +1,104 @@ -<% - -my $conf = new FS::Conf; - -my($query)=$cgi->keywords; -$query ||= ''; #to avoid use of unitialized value errors - -my $orderby; - -my @extra_sql = (); -if ( $query =~ /^UN_(.*)$/ ) { #UN searches need to be acl'ed (and need to - #fix $agentnums_sql - $query = $1; - push @extra_sql, 'pkgnum IS NULL'; -} - -if ( $query eq 'svcnum' ) { - $orderby = 'ORDER BY svcnum'; -} else { - eidiot('unimplemented'); -} - -my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. - ' LEFT JOIN part_svc USING ( svcpart ) '. - ' LEFT JOIN cust_pkg USING ( pkgnum ) '. - ' LEFT JOIN cust_main USING ( custnum ) '; - -#here is the agent virtualization -push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; - -my $extra_sql = - scalar(@extra_sql) - ? ' WHERE '. join(' AND ', @extra_sql ) - : ''; - -my $count_query = "SELECT COUNT(*) FROM svc_forward $addl_from $extra_sql"; -my $sql_query = { - 'table' => 'svc_forward', - 'hashref' => {}, - 'select' => join(', ', - 'svc_forward.*', - 'part_svc.svc', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => "$extra_sql $orderby", - 'addl_from' => $addl_from, -}; - -# <TH>Service #<BR><FONT SIZE=-1>(click to view forward)</FONT></TH> -# <TH>Mail to<BR><FONT SIZE=-1>(click to view account)</FONT></TH> -# <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH> - -my $link = [ "${p}view/svc_forward.cgi?", 'svcnum' ]; - -my $format_src = sub { - my $svc_forward = shift; - if ( $svc_forward->srcsvc_acct ) { - $svc_forward->srcsvc_acct->email; - } else { - my $src = $svc_forward->src; - $src = "<I>(anything)</I>$src" if $src =~ /^@/; - $src; - } -}; - -my $link_src = sub { - my $svc_forward = shift; - if ( $svc_forward->srcsvc_acct ) { - [ "${p}view/svc_acct.cgi?", 'srcsvc' ]; - } else { - ''; - } -}; - -my $format_dst = sub { - my $svc_forward = shift; - if ( $svc_forward->dstsvc_acct ) { - $svc_forward->dstsvc_acct->email; - } else { - $svc_forward->dst; - } -}; - -my $link_dst = sub { - my $svc_forward = shift; - if ( $svc_forward->dstsvc_acct ) { - [ "${p}view/svc_acct.cgi?", 'dstsvc' ]; - } else { - ''; - } -}; - -#smaller false laziness w/svc_*.cgi here -my $link_cust = sub { - my $svc_x = shift; - $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; -}; - -%><%= include( 'elements/search.html', +% +% +%my $conf = new FS::Conf; +% +%my($query)=$cgi->keywords; +%$query ||= ''; #to avoid use of unitialized value errors +% +%my $orderby; +% +%my @extra_sql = (); +%if ( $query =~ /^UN_(.*)$/ ) { #UN searches need to be acl'ed (and need to +% #fix $agentnums_sql +% $query = $1; +% push @extra_sql, 'pkgnum IS NULL'; +%} +% +%if ( $query eq 'svcnum' ) { +% $orderby = 'ORDER BY svcnum'; +%} else { +% eidiot('unimplemented'); +%} +% +%my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. +% ' LEFT JOIN part_svc USING ( svcpart ) '. +% ' LEFT JOIN cust_pkg USING ( pkgnum ) '. +% ' LEFT JOIN cust_main USING ( custnum ) '; +% +%#here is the agent virtualization +%push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; +% +%my $extra_sql = +% scalar(@extra_sql) +% ? ' WHERE '. join(' AND ', @extra_sql ) +% : ''; +% +%my $count_query = "SELECT COUNT(*) FROM svc_forward $addl_from $extra_sql"; +%my $sql_query = { +% 'table' => 'svc_forward', +% 'hashref' => {}, +% 'select' => join(', ', +% 'svc_forward.*', +% 'part_svc.svc', +% 'cust_main.custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'extra_sql' => "$extra_sql $orderby", +% 'addl_from' => $addl_from, +%}; +% +%# <TH>Service #<BR><FONT SIZE=-1>(click to view forward)</FONT></TH> +%# <TH>Mail to<BR><FONT SIZE=-1>(click to view account)</FONT></TH> +%# <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH> +% +%my $link = [ "${p}view/svc_forward.cgi?", 'svcnum' ]; +% +%my $format_src = sub { +% my $svc_forward = shift; +% if ( $svc_forward->srcsvc_acct ) { +% $svc_forward->srcsvc_acct->email; +% } else { +% my $src = $svc_forward->src; +% $src = "<I>(anything)</I>$src" if $src =~ /^@/; +% $src; +% } +%}; +% +%my $link_src = sub { +% my $svc_forward = shift; +% if ( $svc_forward->srcsvc_acct ) { +% [ "${p}view/svc_acct.cgi?", 'srcsvc' ]; +% } else { +% ''; +% } +%}; +% +%my $format_dst = sub { +% my $svc_forward = shift; +% if ( $svc_forward->dstsvc_acct ) { +% $svc_forward->dstsvc_acct->email; +% } else { +% $svc_forward->dst; +% } +%}; +% +%my $link_dst = sub { +% my $svc_forward = shift; +% if ( $svc_forward->dstsvc_acct ) { +% [ "${p}view/svc_acct.cgi?", 'dstsvc' ]; +% } else { +% ''; +% } +%}; +% +%#smaller false laziness w/svc_*.cgi here +%my $link_cust = sub { +% my $svc_x = shift; +% $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; +%}; +% +% +<% include( 'elements/search.html', 'title' => "Mail forward Search Results", 'name' => 'mail forwards', 'query' => $sql_query, diff --git a/httemplate/search/svc_phone.cgi b/httemplate/search/svc_phone.cgi index a68a13e39..26e2090e6 100644 --- a/httemplate/search/svc_phone.cgi +++ b/httemplate/search/svc_phone.cgi @@ -1,70 +1,71 @@ -<% - -my $conf = new FS::Conf; - -my($query)=$cgi->keywords; -$query ||= ''; #to avoid use of unitialized value errors - -my $orderby = 'ORDER BY svcnum'; -my %svc_phone = (); -my @extra_sql = (); -if ( $query eq 'svcnum' ) { - #$orderby = 'ORDER BY svcnum'; -} elsif ( $query eq 'phonenum' ) { - $orderby = 'ORDER BY phonenum'; -} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { - #$orderby = 'ORDER BY svcnum'; - push @extra_sql, "svcpart = $1"; -} else { - $cgi->param('phonenum') =~ /^([\d\- ]+)$/; - ( $svc_phone{'phonenum'} = $1 ) =~ s/\D//g; -} - -my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. - ' LEFT JOIN part_svc USING ( svcpart ) '. - ' LEFT JOIN cust_pkg USING ( pkgnum ) '. - ' LEFT JOIN cust_main USING ( custnum ) '; - -#here is the agent virtualization -push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; - -my $extra_sql = ''; -if ( @extra_sql ) { - $extra_sql = ( keys(%svc_phone) ? ' AND ' : ' WHERE ' ). - join(' AND ', @extra_sql ); -} - -my $count_query = "SELECT COUNT(*) FROM svc_phone $addl_from "; -if ( keys %svc_phone ) { - $count_query .= ' WHERE '. - join(' AND ', map "$_ = ". dbh->quote($svc_phone{$_}), - keys %svc_phone - ); -} -$count_query .= $extra_sql; - -my $sql_query = { - 'table' => 'svc_phone', - 'hashref' => \%svc_phone, - 'select' => join(', ', - 'svc_phone.*', - 'part_svc.svc', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => "$extra_sql $orderby", - 'addl_from' => $addl_from, -}; - -my $link = [ "${p}view/svc_phone.cgi?", 'svcnum' ]; - -#smaller false laziness w/svc_*.cgi here -my $link_cust = sub { - my $svc_x = shift; - $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; -}; - -%><%= include( 'elements/search.html', +% +% +%my $conf = new FS::Conf; +% +%my($query)=$cgi->keywords; +%$query ||= ''; #to avoid use of unitialized value errors +% +%my $orderby = 'ORDER BY svcnum'; +%my %svc_phone = (); +%my @extra_sql = (); +%if ( $query eq 'svcnum' ) { +% #$orderby = 'ORDER BY svcnum'; +%} elsif ( $query eq 'phonenum' ) { +% $orderby = 'ORDER BY phonenum'; +%} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { +% #$orderby = 'ORDER BY svcnum'; +% push @extra_sql, "svcpart = $1"; +%} else { +% $cgi->param('phonenum') =~ /^([\d\- ]+)$/; +% ( $svc_phone{'phonenum'} = $1 ) =~ s/\D//g; +%} +% +%my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. +% ' LEFT JOIN part_svc USING ( svcpart ) '. +% ' LEFT JOIN cust_pkg USING ( pkgnum ) '. +% ' LEFT JOIN cust_main USING ( custnum ) '; +% +%#here is the agent virtualization +%push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; +% +%my $extra_sql = ''; +%if ( @extra_sql ) { +% $extra_sql = ( keys(%svc_phone) ? ' AND ' : ' WHERE ' ). +% join(' AND ', @extra_sql ); +%} +% +%my $count_query = "SELECT COUNT(*) FROM svc_phone $addl_from "; +%if ( keys %svc_phone ) { +% $count_query .= ' WHERE '. +% join(' AND ', map "$_ = ". dbh->quote($svc_phone{$_}), +% keys %svc_phone +% ); +%} +%$count_query .= $extra_sql; +% +%my $sql_query = { +% 'table' => 'svc_phone', +% 'hashref' => \%svc_phone, +% 'select' => join(', ', +% 'svc_phone.*', +% 'part_svc.svc', +% 'cust_main.custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'extra_sql' => "$extra_sql $orderby", +% 'addl_from' => $addl_from, +%}; +% +%my $link = [ "${p}view/svc_phone.cgi?", 'svcnum' ]; +% +%#smaller false laziness w/svc_*.cgi here +%my $link_cust = sub { +% my $svc_x = shift; +% $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; +%}; +% +% +<% include( 'elements/search.html', 'title' => "Phone number search results", 'name' => 'phone numbers', 'query' => $sql_query, diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi index ef4045cf9..b0f1d5c80 100755 --- a/httemplate/search/svc_www.cgi +++ b/httemplate/search/svc_www.cgi @@ -1,43 +1,44 @@ -<% - -#my $conf = new FS::Conf; - -my($query)=$cgi->keywords; -$query ||= ''; #to avoid use of unitialized value errors -my $orderby; -if ( $query eq 'svcnum' ) { - $orderby = 'ORDER BY svcnum'; -} else { - eidiot('unimplemented'); -} - -my $count_query = 'SELECT COUNT(*) FROM svc_www'; -my $sql_query = { - 'table' => 'svc_www', - 'hashref' => {}, - 'select' => join(', ', - 'svc_www.*', - 'part_svc.svc', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => $orderby, - 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. - 'LEFT JOIN cust_pkg USING ( pkgnum )'. - 'LEFT JOIN cust_main USING ( custnum )', -}; - -my $link = [ "${p}view/svc_www.cgi?", 'svcnum', ]; -#my $dlink = [ "${p}view/svc_www.cgi?", 'svcnum', ]; -my $ulink = [ "${p}view/svc_acct.cgi?", 'usersvc', ]; - -#smaller false laziness w/svc_*.cgi here -my $link_cust = sub { - my $svc_x = shift; - $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; -}; - -%><%= include( 'elements/search.html', +% +% +%#my $conf = new FS::Conf; +% +%my($query)=$cgi->keywords; +%$query ||= ''; #to avoid use of unitialized value errors +%my $orderby; +%if ( $query eq 'svcnum' ) { +% $orderby = 'ORDER BY svcnum'; +%} else { +% eidiot('unimplemented'); +%} +% +%my $count_query = 'SELECT COUNT(*) FROM svc_www'; +%my $sql_query = { +% 'table' => 'svc_www', +% 'hashref' => {}, +% 'select' => join(', ', +% 'svc_www.*', +% 'part_svc.svc', +% 'cust_main.custnum', +% FS::UI::Web::cust_sql_fields(), +% ), +% 'extra_sql' => $orderby, +% 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. +% 'LEFT JOIN cust_pkg USING ( pkgnum )'. +% 'LEFT JOIN cust_main USING ( custnum )', +%}; +% +%my $link = [ "${p}view/svc_www.cgi?", 'svcnum', ]; +%#my $dlink = [ "${p}view/svc_www.cgi?", 'svcnum', ]; +%my $ulink = [ "${p}view/svc_acct.cgi?", 'usersvc', ]; +% +%#smaller false laziness w/svc_*.cgi here +%my $link_cust = sub { +% my $svc_x = shift; +% $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; +%}; +% +% +<% include( 'elements/search.html', 'title' => 'Virtual Host Search Results', 'name' => 'virtual hosts', 'query' => $sql_query, diff --git a/httemplate/view/cust_bill-logo.cgi b/httemplate/view/cust_bill-logo.cgi index 235485f6b..fd6a81a75 100755 --- a/httemplate/view/cust_bill-logo.cgi +++ b/httemplate/view/cust_bill-logo.cgi @@ -1,15 +1,16 @@ -<% - -my $conf = new FS::Conf; - -my($query) = $cgi->keywords; -$query =~ /^([^\.\/]*)$/; -my $templatename = $1; -if ( $templatename && $conf->exists("logo_$templatename.png") ) { - $templatename = "_$templatename"; -} else { - $templatename = ''; -} - -http_header('Content-Type' => 'image/png' ); -%><%= $conf->config_binary("logo$templatename.png") %> +% +% +%my $conf = new FS::Conf; +% +%my($query) = $cgi->keywords; +%$query =~ /^([^\.\/]*)$/; +%my $templatename = $1; +%if ( $templatename && $conf->exists("logo_$templatename.png") ) { +% $templatename = "_$templatename"; +%} else { +% $templatename = ''; +%} +% +%http_header('Content-Type' => 'image/png' ); +% +<% $conf->config_binary("logo$templatename.png") %> diff --git a/httemplate/view/cust_bill-pdf.cgi b/httemplate/view/cust_bill-pdf.cgi index ce7ab0c5c..06bb965eb 100755 --- a/httemplate/view/cust_bill-pdf.cgi +++ b/httemplate/view/cust_bill-pdf.cgi @@ -1,17 +1,18 @@ -<% - -#untaint invnum -my($query) = $cgi->keywords; -$query =~ /^((.+)-)?(\d+)(.pdf)?$/; -my $templatename = $2; -my $invnum = $3; - -my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); -die "Invoice #$invnum not found!" unless $cust_bill; - -my $pdf = $cust_bill->print_pdf( '', $templatename); - -http_header('Content-Type' => 'application/pdf' ); -http_header('Content-Length' => length($pdf) ); -http_header('Cache-control' => 'max-age=60' ); -%><%= $pdf %> +% +% +%#untaint invnum +%my($query) = $cgi->keywords; +%$query =~ /^((.+)-)?(\d+)(.pdf)?$/; +%my $templatename = $2; +%my $invnum = $3; +% +%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +%die "Invoice #$invnum not found!" unless $cust_bill; +% +%my $pdf = $cust_bill->print_pdf( '', $templatename); +% +%http_header('Content-Type' => 'application/pdf' ); +%http_header('Content-Length' => length($pdf) ); +%http_header('Cache-control' => 'max-age=60' ); +% +<% $pdf %> diff --git a/httemplate/view/cust_bill-ps.cgi b/httemplate/view/cust_bill-ps.cgi index e730a822a..f838e1b17 100755 --- a/httemplate/view/cust_bill-ps.cgi +++ b/httemplate/view/cust_bill-ps.cgi @@ -1,13 +1,14 @@ -<% - -#untaint invnum -my($query) = $cgi->keywords; -$query =~ /^((.+)-)?(\d+)$/; -my $templatename = $2; -my $invnum = $3; - -my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); -die "Invoice #$invnum not found!" unless $cust_bill; - -http_header('Content-Type' => 'application/postscript' ); -%><%= $cust_bill->print_ps( '', $templatename) %> +% +% +%#untaint invnum +%my($query) = $cgi->keywords; +%$query =~ /^((.+)-)?(\d+)$/; +%my $templatename = $2; +%my $invnum = $3; +% +%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +%die "Invoice #$invnum not found!" unless $cust_bill; +% +%http_header('Content-Type' => 'application/postscript' ); +% +<% $cust_bill->print_ps( '', $templatename) %> diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 45e19d436..3772e8dd0 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -1,151 +1,155 @@ -<% - -#untaint invnum -my($query) = $cgi->keywords; -$query =~ /^((.+)-)?(\d+)$/; -my $templatename = $2; -my $invnum = $3; - -my $conf = new FS::Conf; - -my @payby = grep /\w/, $conf->config('payby'); -#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) -@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) - unless @payby; -my %payby = map { $_=>1 } @payby; - -my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); -die "Invoice #$invnum not found!" unless $cust_bill; -my $custnum = $cust_bill->getfield('custnum'); - -#my $printed = $cust_bill->printed; - -my $link = $templatename ? "$templatename-$invnum" : $invnum; - -%> -<%= include("/elements/header.html",'Invoice View', menubar( +% +% +%#untaint invnum +%my($query) = $cgi->keywords; +%$query =~ /^((.+)-)?(\d+)$/; +%my $templatename = $2; +%my $invnum = $3; +% +%my $conf = new FS::Conf; +% +%my @payby = grep /\w/, $conf->config('payby'); +%#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) +%@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) +% unless @payby; +%my %payby = map { $_=>1 } @payby; +% +%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +%die "Invoice #$invnum not found!" unless $cust_bill; +%my $custnum = $cust_bill->getfield('custnum'); +% +%#my $printed = $cust_bill->printed; +% +%my $link = $templatename ? "$templatename-$invnum" : $invnum; +% +% + +<% include("/elements/header.html",'Invoice View', menubar( "Main Menu" => $p, "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", )) %> +% if ( $cust_bill->owed > 0 +% && ( $payby{'BILL'} || $payby{'CASH'} || $payby{'WEST'} || $payby{'MCRD'} ) +% ) +% { +% my $s = 0; +% -<% if ( $cust_bill->owed > 0 - && ( $payby{'BILL'} || $payby{'CASH'} || $payby{'WEST'} || $payby{'MCRD'} ) - ) - { - my $s = 0; -%> Post +% if ( $payby{'BILL'} ) { - <% if ( $payby{'BILL'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=BILL;invnum=<%= $invnum %>">check</A> - - <% } %> - - <% if ( $payby{'CASH'} ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=CASH;invnum=<%= $invnum %>">cash</A> - - <% } %> - - <% if ( $payby{'WEST'} ) { %> - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;invnum=<%= $invnum %>">Western Union</A> + <% $s++ ? ' | ' : '' %> + <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>">check</A> +% } +% if ( $payby{'CASH'} ) { + - <% } %> + <% $s++ ? ' | ' : '' %> + <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>">cash</A> +% } +% if ( $payby{'WEST'} ) { - <% if ( $payby{'MCRD'} ) { %> - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<%= $invnum %>">manual credit card</A> + <% $s++ ? ' | ' : '' %> + <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>">Western Union</A> +% } +% if ( $payby{'MCRD'} ) { + - <% } %> + <% $s++ ? ' | ' : '' %> + <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>">manual credit card</A> +% } + payment against this invoice<BR> +% } -<% } %> -<A HREF="<%= $p %>misc/print-invoice.cgi?<%= $link %>">Re-print this invoice</A> +<A HREF="<% $p %>misc/print-invoice.cgi?<% $link %>">Re-print this invoice</A> +% if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { -<% if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { %> - | <A HREF="<%= $p %>misc/email-invoice.cgi?<%= $link %>">Re-email + | <A HREF="<% $p %>misc/email-invoice.cgi?<% $link %>">Re-email this invoice</A> -<% } %> +% } +% if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { -<% if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { %> - | <A HREF="<%= $p %>misc/fax-invoice.cgi?<%= $link %>">Re-fax + | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $link %>">Re-fax this invoice</A> -<% } %> +% } + <BR><BR> +% if ( $conf->exists('invoice_latex') ) { -<% if ( $conf->exists('invoice_latex') ) { %> - <A HREF="<%= $p %>view/cust_bill-pdf.cgi?<%= $link %>.pdf">View typeset invoice</A> + <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>.pdf">View typeset invoice</A> <BR><BR> -<% } %> +% } +% #false laziness with search/cust_bill_event.cgi +% unless ( $templatename ) { -<% #false laziness with search/cust_bill_event.cgi - unless ( $templatename ) { %> - <%= table() %> + <% table() %> <TR> <TH>Event</TH> <TH>Date</TH> <TH>Status</TH> </TR> +% foreach my $cust_bill_event ( +% sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event +% ) { +% +% my $status = $cust_bill_event->status; +% $status .= ': '. encode_entities($cust_bill_event->statustext) +% if $cust_bill_event->statustext; +% my $part_bill_event = $cust_bill_event->part_bill_event; +% - <% foreach my $cust_bill_event ( - sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event - ) { - - my $status = $cust_bill_event->status; - $status .= ': '. encode_entities($cust_bill_event->statustext) - if $cust_bill_event->statustext; - my $part_bill_event = $cust_bill_event->part_bill_event; - %> <TR> - <TD><%= $part_bill_event->event %> - - <% if ( $part_bill_event->templatename ) { - my $alt_templatename = $part_bill_event->templatename; - my $alt_link = "$alt_templatename-$invnum"; - %> - ( <A HREF="<%= $p %>view/cust_bill.cgi?<%= $alt_link %>">view</A> - | <A HREF="<%= $p %>view/cust_bill-pdf.cgi?<%= $alt_link %>.pdf">view + <TD><% $part_bill_event->event %> +% if ( $part_bill_event->templatename ) { +% my $alt_templatename = $part_bill_event->templatename; +% my $alt_link = "$alt_templatename-$invnum"; +% + + ( <A HREF="<% $p %>view/cust_bill.cgi?<% $alt_link %>">view</A> + | <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $alt_link %>.pdf">view typeset</A> - | <A HREF="<%= $p %>misc/print-invoice.cgi?<%= $alt_link %>">re-print</A> - <% if ( grep { $_ ne 'POST' } - $cust_bill->cust_main->invoicing_list ) { %> - | <A HREF="<%= $p %>misc/email-invoice.cgi?<%= $alt_link %>">re-email</A> - <% } %> - - <% if ( $conf->exists('hylafax') - && length($cust_bill->cust_main->fax) ) { %> - | <A HREF="<%= $p %>misc/fax-invoice.cgi?<%= $alt_link %>">re-fax</A> - <% } %> + | <A HREF="<% $p %>misc/print-invoice.cgi?<% $alt_link %>">re-print</A> +% if ( grep { $_ ne 'POST' } +% $cust_bill->cust_main->invoicing_list ) { + + | <A HREF="<% $p %>misc/email-invoice.cgi?<% $alt_link %>">re-email</A> +% } +% if ( $conf->exists('hylafax') +% && length($cust_bill->cust_main->fax) ) { + + | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $alt_link %>">re-fax</A> +% } + ) - <% } %> +% } + </TD> - <TD><%= time2str("%a %b %e %T %Y", $cust_bill_event->_date) %></TD> - <TD><%= $status %></TD> + <TD><% time2str("%a %b %e %T %Y", $cust_bill_event->_date) %></TD> + <TD><% $status %></TD> </TR> - <% } %> +% } + </TABLE> <BR> +% } +% if ( $conf->exists('invoice_html') ) { + + <% join('', $cust_bill->print_html('', $templatename) ) %> +% } else { -<% } %> + <PRE><% join('', $cust_bill->print_text('', $templatename) ) %></PRE> +% } -<% if ( $conf->exists('invoice_html') ) { %> - <%= join('', $cust_bill->print_html('', $templatename) ) %> -<% } else { %> - <PRE><%= join('', $cust_bill->print_text('', $templatename) ) %></PRE> -<% } %> </BODY></HTML> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 8267fea51..e82a5196c 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -1,23 +1,25 @@ -<% +% +% +%my $conf = new FS::Conf; +% +%my $curuser = $FS::CurrentUser::CurrentUser; +% +%die "No customer specified (bad URL)!" unless $cgi->keywords; +%my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array +%$query =~ /^(\d+)$/; +%my $custnum = $1; +%my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); +%die "Customer not found!" unless $cust_main; +% +% -my $conf = new FS::Conf; -my $curuser = $FS::CurrentUser::CurrentUser; +<% include("/elements/header.html","Customer View: ". $cust_main->name ) %> +% if ( $curuser->access_right('Edit customer') ) { -die "No customer specified (bad URL)!" unless $cgi->keywords; -my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array -$query =~ /^(\d+)$/; -my $custnum = $1; -my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); -die "Customer not found!" unless $cust_main; + <A HREF="<% $p %>edit/cust_main.cgi?<% $custnum %>">Edit this customer</A> | +% } -%> - -<%= include("/elements/header.html","Customer View: ". $cust_main->name ) %> - -<% if ( $curuser->access_right('Edit customer') ) { %> - <A HREF="<%= $p %>edit/cust_main.cgi?<%= $custnum %>">Edit this customer</A> | -<% } %> <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT> @@ -33,96 +35,100 @@ function areyousure(href, message) { </SCRIPT> <SCRIPT TYPE="text/javascript"> - -<% -my $ban = ''; -if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) { - $ban = '<BR><P ALIGN="center">'. - '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\\\'s '; - if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { - $ban .= 'credit card'; - } elsif ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) { - $ban .= 'ACH account'; - } -} -%> - -var confirm_cancel = '<FORM METHOD="POST" ACTION="<%= $p %>misc/cust_main-cancel.cgi"> <INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>"> <BR><P ALIGN="center"><B>Permanently delete all services and cancel this customer?</B> <%= $ban%><BR><P ALIGN="CENTER"> <INPUT TYPE="submit" VALUE="Cancel customer"> <INPUT TYPE="BUTTON" VALUE="Don\'t cancel" onClick="cClick()"> </FORM> '; +% +%my $ban = ''; +%if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) { +% $ban = '<BR><P ALIGN="center">'. +% '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\\\'s '; +% if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { +% $ban .= 'credit card'; +% } elsif ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) { +% $ban .= 'ACH account'; +% } +%} +% + + +var confirm_cancel = '<FORM METHOD="POST" ACTION="<% $p %>misc/cust_main-cancel.cgi"> <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> <BR><P ALIGN="center"><B>Permanently delete all services and cancel this customer?</B> <% $ban%><BR><P ALIGN="CENTER"> <INPUT TYPE="submit" VALUE="Cancel customer"> <INPUT TYPE="BUTTON" VALUE="Don\'t cancel" onClick="cClick()"> </FORM> '; </SCRIPT> +% if ( $curuser->access_right('Cancel customer') +% && $cust_main->ncancelled_pkgs +% ) { +% -<% if ( $curuser->access_right('Cancel customer') - && $cust_main->ncancelled_pkgs - ) { -%> <A HREF="javascript:void(0);" onClick="overlib(confirm_cancel, CAPTION, 'Confirm cancellation', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH, 576, HEIGHT, 128, TEXTSIZE, 3, BGCOLOR, '#ff0000', CGCOLOR, '#ff0000' ); return false; ">Cancel this customer</A> | -<% } %> - +% } +% if ( $conf->exists('deletecustomers') +% && $curuser->access_right('Delete customer') +% ) { +% -<% if ( $conf->exists('deletecustomers') - && $curuser->access_right('Delete customer') - ) { -%> - <A HREF="<%= $p %>misc/delete-customer.cgi?<%= $custnum%>">Delete this customer</A> | -<% } %> + <A HREF="<% $p %>misc/delete-customer.cgi?<% $custnum%>">Delete this customer</A> | +% } +% unless ( $conf->exists('disable_customer_referrals') ) { + <A HREF="<% popurl(2) %>edit/cust_main.cgi?referral_custnum=<% $custnum %>">Refer a new customer</A> | + <A HREF="<% popurl(2) %>search/cust_main.cgi?referral_custnum=<% $custnum %>">View this customer's referrals</A> +% } -<% unless ( $conf->exists('disable_customer_referrals') ) { %> - <A HREF="<%= popurl(2) %>edit/cust_main.cgi?referral_custnum=<%= $custnum %>">Refer a new customer</A> | - <A HREF="<%= popurl(2) %>search/cust_main.cgi?referral_custnum=<%= $custnum %>">View this customer's referrals</A> -<% } %> <BR><BR> +% +%my $signupurl = $conf->config('signupurl'); +%if ( $signupurl ) { +% + + This customer's signup URL: <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A><BR><BR> +% } -<% -my $signupurl = $conf->config('signupurl'); -if ( $signupurl ) { -%> - This customer's signup URL: <A HREF="<%= $signupurl %>?ref=<%= $custnum %>"><%= $signupurl %>?ref=<%= $custnum %></A><BR><BR> -<% } %> <A NAME="cust_main"></A> <TABLE BORDER=0> <TR> <TD VALIGN="top"> - <%= include('cust_main/contacts.html', $cust_main ) %> + <% include('cust_main/contacts.html', $cust_main ) %> </TD> <TD VALIGN="top" STYLE="padding-left: 54px"> - <%= include('cust_main/misc.html', $cust_main ) %> - <% if ( $conf->config('payby-default') ne 'HIDE' ) { %> + <% include('cust_main/misc.html', $cust_main ) %> +% if ( $conf->config('payby-default') ne 'HIDE' ) { + <BR> - <%= include('cust_main/billing.html', $cust_main ) %> - <% } %> + <% include('cust_main/billing.html', $cust_main ) %> +% } + </TD> </TR> </TABLE> +% +%if ( defined $cust_main->dbdef_table->column('comments') +% && $cust_main->comments =~ /[^\s\n\r]/ ) { +% -<% -if ( defined $cust_main->dbdef_table->column('comments') - && $cust_main->comments =~ /[^\s\n\r]/ ) { -%> <BR> Comments -<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %> +<% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %> <TR> <TD BGCOLOR="#ffffff"> - <PRE><%= encode_entities($cust_main->comments) %></PRE> + <PRE><% encode_entities($cust_main->comments) %></PRE> </TD> </TR> </TABLE></TABLE> -<% } %> +% } +% if ( $conf->config('ticket_system') ) { -<% if ( $conf->config('ticket_system') ) { %> <BR> - <%= include('cust_main/tickets.html', $cust_main ) %> -<% } %> + <% include('cust_main/tickets.html', $cust_main ) %> +% } + <BR><BR> -<%= include('cust_main/packages.html', $cust_main ) %> +<% include('cust_main/packages.html', $cust_main ) %> +% if ( $conf->config('payby-default') ne 'HIDE' ) { + + <% include('cust_main/payment_history.html', $cust_main ) %> +% } -<% if ( $conf->config('payby-default') ne 'HIDE' ) { %> - <%= include('cust_main/payment_history.html', $cust_main ) %> -<% } %> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 191d3092f..d1be8936f 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -1,182 +1,188 @@ -<% - my( $cust_main ) = @_; - my @invoicing_list = $cust_main->invoicing_list; - my $conf = new FS::Conf; - my $money_char = $conf->config('money_char') || '$'; -%> +% +% my( $cust_main ) = @_; +% my @invoicing_list = $cust_main->invoicing_list; +% my $conf = new FS::Conf; +% my $money_char = $conf->config('money_char') || '$'; +% + Billing information -(<A HREF="<%= $p %>misc/bill.cgi?<%= $cust_main->custnum %>">Bill now</A>) -<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %> +(<A HREF="<% $p %>misc/bill.cgi?<% $cust_main->custnum %>">Bill now</A>) +<% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %> +% +%( my $balance = $cust_main->balance ) +% =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/; +% -<% -( my $balance = $cust_main->balance ) - =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/; -%> <TR> <TD ALIGN="right">Balance due</TD> - <TD BGCOLOR="#ffffff"><B><%= $balance %></B></TD> + <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD> </TR> <TR> <TD ALIGN="right">Billing type</TD> <TD BGCOLOR="#ffffff"> +% if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { -<% if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { %> - Credit card <%= $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' %> + Credit card <% $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' %> </TD> </TR> <TR> <TD ALIGN="right">Card number</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->payinfo_masked %></TD> -</TR> - -<% -#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html -my( $mon, $year ); -my $date = $cust_main->paydate || '12-2037'; -if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); -} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); -} else { - warn "unrecognized expiration date format: $date"; - ( $mon, $year ) = ( '', '' ); -} -%> + <TD BGCOLOR="#ffffff"><% $cust_main->payinfo_masked %></TD> +</TR> +% +%#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html +%my( $mon, $year ); +%my $date = $cust_main->paydate || '12-2037'; +%if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format +% ( $mon, $year ) = ( $2, $1 ); +%} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { +% ( $mon, $year ) = ( $1, $3 ); +%} else { +% warn "unrecognized expiration date format: $date"; +% ( $mon, $year ) = ( '', '' ); +%} +% + <TR> <TD ALIGN="right">Expiration</TD> - <TD BGCOLOR="#ffffff"><%= "$mon/$year" %></TD> + <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD> </TR> +% if ( $cust_main->paystart_month ) { -<% if ( $cust_main->paystart_month ) { %> <TR> <TD ALIGN="right">Start date</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->paystart_month. '/'. $cust_main->paystart_year %> + <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %> </TR> -<% } elsif ( $cust_main->payissue ) { %> +% } elsif ( $cust_main->payissue ) { + <TR> <TD ALIGN="right">Issue #</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->payissue %> + <TD BGCOLOR="#ffffff"><% $cust_main->payissue %> </TR> -<% } %> +% } + <TR> <TD ALIGN="right">Name on card</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->payname %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD> </TR> +% } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') { +% my( $account, $aba ) = split('@', $cust_main->payinfo ); +% -<% } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') { - my( $account, $aba ) = split('@', $cust_main->payinfo ); -%> - Electronic check <%= $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %> + Electronic check <% $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %> </TD> </TR> <TR> <TD ALIGN="right">ABA/Routing code</TD> - <TD BGCOLOR="#ffffff"><%= $aba %></TD> + <TD BGCOLOR="#ffffff"><% $aba %></TD> </TR> <TR> <TD ALIGN="right">Account number</TD> - <TD BGCOLOR="#ffffff"><%= 'x'x(length($account)-2). substr($account,(length($account)-2)) %></TD> + <TD BGCOLOR="#ffffff"><% 'x'x(length($account)-2). substr($account,(length($account)-2)) %></TD> </TR> <TR> <TD ALIGN="right">Bank name</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->payname %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD> </TR> +% } elsif ( $cust_main->payby eq 'LECB' ) { +% $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/; +% my $payinfo = "$1-$2-$3"; +% -<% } elsif ( $cust_main->payby eq 'LECB' ) { - $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/; - my $payinfo = "$1-$2-$3"; -%> Phone bill billing </TD> </TR> <TR> <TD ALIGN="right">Phone number</TD> - <TD BGCOLOR="#ffffff"><%= $payinfo %></TD> + <TD BGCOLOR="#ffffff"><% $payinfo %></TD> </TR> +% } elsif ( $cust_main->payby eq 'BILL' ) { -<% } elsif ( $cust_main->payby eq 'BILL' ) { %> Billing </TD> </TR> +% if ( $cust_main->payinfo ) { - <% if ( $cust_main->payinfo ) { %> <TR> <TD ALIGN="right">P.O. </TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->payinfo %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD> </TR> - <% } %> +% } + <TR> <TD ALIGN="right">Attention</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->payname %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD> </TR> +% } elsif ( $cust_main->payby eq 'COMP' ) { -<% } elsif ( $cust_main->payby eq 'COMP' ) { %> Complimentary </TD> </TR> <TR> <TD ALIGN="right">Authorized by</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->payinfo %></TD> -</TR> - -<% -#false laziness w/above etc. -my( $mon, $year ); -my $date = $cust_main->paydate || '12-2037'; -if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format - ( $mon, $year ) = ( $2, $1 ); -} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { - ( $mon, $year ) = ( $1, $3 ); -} else { - warn "unrecognized expiration date format: $date"; - ( $mon, $year ) = ( '', '' ); -} -%> + <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD> +</TR> +% +%#false laziness w/above etc. +%my( $mon, $year ); +%my $date = $cust_main->paydate || '12-2037'; +%if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format +% ( $mon, $year ) = ( $2, $1 ); +%} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { +% ( $mon, $year ) = ( $1, $3 ); +%} else { +% warn "unrecognized expiration date format: $date"; +% ( $mon, $year ) = ( '', '' ); +%} +% + <TR> <TD ALIGN="right">Expiration</TD> - <TD BGCOLOR="#ffffff"><%= "$mon/$year" %></TD> + <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD> </TR> +% } -<% } %> <TR> <TD ALIGN="right">Tax exempt</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->tax ? 'yes' : 'no' %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->tax ? 'yes' : 'no' %></TD> </TR> <TR> <TD ALIGN="right">Postal invoices</TD> <TD BGCOLOR="#ffffff"> - <%= ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %> + <% ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %> </TD> </TR> <TR> <TD ALIGN="right">FAX invoices</TD> <TD BGCOLOR="#ffffff"> - <%= ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %> + <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %> </TD> </TR> <TR> <TD ALIGN="right">Email invoices</TD> <TD BGCOLOR="#ffffff"> - <%= join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %> + <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %> </TD> </TR> -<% if ( $conf->exists('voip-cust_cdr_spools') ) { %> +% if ( $conf->exists('voip-cust_cdr_spools') ) { + <TR> <TD ALIGN="right">Spool CDRs</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->spool_cdr ? 'yes' : 'no' %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD> </TR> -<% } %> +% } + </TABLE></TD></TR></TABLE> diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html index 48371550b..9c2b38f9a 100644 --- a/httemplate/view/cust_main/contacts.html +++ b/httemplate/view/cust_main/contacts.html @@ -1,58 +1,64 @@ -<% - my( $cust_main ) = @_; - my $conf = new FS::Conf; -%> +% +% my( $cust_main ) = @_; +% my $conf = new FS::Conf; +% + Billing address -<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %> +<% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Contact name</TD> <TD COLSPAN=3 BGCOLOR="#ffffff"> - <%= $cust_main->last. ', '. $cust_main->first %> + <% $cust_main->last. ', '. $cust_main->first %> </TD> -<% if ( $conf->exists('show_ss') ) { %> +% if ( $conf->exists('show_ss') ) { + <TD ALIGN="right">SS#</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->ss || ' ' %></TD> -<% } %> + <TD BGCOLOR="#ffffff"><% $cust_main->ss || ' ' %></TD> +% } + </TR> <TR> <TD ALIGN="right">Company</TD> - <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->company %></TD> + <TD COLSPAN=5 BGCOLOR="#ffffff"><% $cust_main->company %></TD> </TR> <TR> <TD ALIGN="right">Address</TD> - <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->address1 %></TD> + <TD COLSPAN=5 BGCOLOR="#ffffff"><% $cust_main->address1 %></TD> </TR> -<% if ( $cust_main->address2 ) { %> +% if ( $cust_main->address2 ) { + <TR> <TD ALIGN="right"> </TD> - <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->address2 %></TD> + <TD COLSPAN=5 BGCOLOR="#ffffff"><% $cust_main->address2 %></TD> </TR> -<% } %> +% } + <TR> <TD ALIGN="right">City</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->city %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->city %></TD> <TD ALIGN="right">State</TD> - <TD BGCOLOR="#ffffff"><%= state_label($cust_main->state, $cust_main->country) %></TD> + <TD BGCOLOR="#ffffff"><% state_label($cust_main->state, $cust_main->country) %></TD> <TD ALIGN="right">Zip</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->zip %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->zip %></TD> </TR> <TR> <TD ALIGN="right">Country</TD> - <TD BGCOLOR="#ffffff"><%= code2country($cust_main->country) %></TD> -</TR> -<% - my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/ - ? 'Day Phone' - : FS::Msgcat::_gettext('daytime'); - my $night_label = FS::Msgcat::_gettext('night') =~ /^(night)?$/ - ? 'Night Phone' - : FS::Msgcat::_gettext('night'); -%> -<TR> - <TD ALIGN="right"><%= $daytime_label %></TD> + <TD BGCOLOR="#ffffff"><% code2country($cust_main->country) %></TD> +</TR> +% +% my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/ +% ? 'Day Phone' +% : FS::Msgcat::_gettext('daytime'); +% my $night_label = FS::Msgcat::_gettext('night') =~ /^(night)?$/ +% ? 'Night Phone' +% : FS::Msgcat::_gettext('night'); +% + +<TR> + <TD ALIGN="right"><% $daytime_label %></TD> <TD COLSPAN=6 BGCOLOR="#ffffff"> - <%= include('/elements/phonenumber.html', + <% include('/elements/phonenumber.html', $cust_main->daytime, 'callable'=>1 ) @@ -60,9 +66,9 @@ Billing address </TD> </TR> <TR> - <TD ALIGN="right"><%= $night_label %></TD> + <TD ALIGN="right"><% $night_label %></TD> <TD COLSPAN=6 BGCOLOR="#ffffff"> - <%= include('/elements/phonenumber.html', + <% include('/elements/phonenumber.html', $cust_main->night, 'callable'=>1 ) @@ -72,54 +78,56 @@ Billing address <TR> <TD ALIGN="right">Fax</TD> <TD COLSPAN=5 BGCOLOR="#ffffff"> - <%= $cust_main->fax || ' ' %> + <% $cust_main->fax || ' ' %> </TD> </TR> </TABLE></TD></TR></TABLE> +% if ( defined $cust_main->dbdef_table->column('ship_last') ) { +% my $pre = $cust_main->ship_last ? 'ship_' : ''; +% -<% if ( defined $cust_main->dbdef_table->column('ship_last') ) { - my $pre = $cust_main->ship_last ? 'ship_' : ''; -%> <BR> Service address -<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %> +<% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Contact name</TD> <TD COLSPAN=5 BGCOLOR="#ffffff"> - <%= $cust_main->get("${pre}last"). ', '. $cust_main->get("${pre}first") %> + <% $cust_main->get("${pre}last"). ', '. $cust_main->get("${pre}first") %> </TD> </TR> <TR> <TD ALIGN="right">Company</TD> - <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->get("${pre}company") %></TD> + <TD COLSPAN=5 BGCOLOR="#ffffff"><% $cust_main->get("${pre}company") %></TD> </TR> <TR> <TD ALIGN="right">Address</TD> - <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->get("${pre}address1") %></TD> + <TD COLSPAN=5 BGCOLOR="#ffffff"><% $cust_main->get("${pre}address1") %></TD> </TR> -<% if ( $cust_main->get("${pre}address2") ) { %> +% if ( $cust_main->get("${pre}address2") ) { + <TR> <TD ALIGN="right"> </TD> - <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->get("${pre}address2") %></TD> + <TD COLSPAN=5 BGCOLOR="#ffffff"><% $cust_main->get("${pre}address2") %></TD> </TR> -<% } %> +% } + <TR> <TD ALIGN="right">City</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->get("${pre}city") %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->get("${pre}city") %></TD> <TD ALIGN="right">State</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->get("${pre}state") %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->get("${pre}state") %></TD> <TD ALIGN="right">Zip</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->get("${pre}zip") %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->get("${pre}zip") %></TD> </TR> <TR> <TD ALIGN="right">Country</TD> - <TD BGCOLOR="#ffffff"><%= code2country( $cust_main->get("${pre}country") ) %></TD> + <TD BGCOLOR="#ffffff"><% code2country( $cust_main->get("${pre}country") ) %></TD> </TR> <TR> - <TD ALIGN="right"><%= $daytime_label %></TD> + <TD ALIGN="right"><% $daytime_label %></TD> <TD COLSPAN=5 BGCOLOR="#ffffff"> - <%= include('/elements/phonenumber.html', + <% include('/elements/phonenumber.html', $cust_main->get("${pre}daytime"), 'callable'=>1 ) @@ -127,9 +135,9 @@ Service address </TD> </TR> <TR> - <TD ALIGN="right"><%= $night_label %></TD> + <TD ALIGN="right"><% $night_label %></TD> <TD COLSPAN=5 BGCOLOR="#ffffff"> - <%= include('/elements/phonenumber.html', + <% include('/elements/phonenumber.html', $cust_main->get("${pre}night"), 'callable'=>1 ) @@ -139,9 +147,9 @@ Service address <TR> <TD ALIGN="right">Fax</TD> <TD COLSPAN=5 BGCOLOR="#ffffff"> - <%= $cust_main->get("${pre}fax") || ' ' %> + <% $cust_main->get("${pre}fax") || ' ' %> </TD> </TR> </TABLE></TD></TR></TABLE> +% } -<% } %> diff --git a/httemplate/view/cust_main/misc.html b/httemplate/view/cust_main/misc.html index f06a4fbd2..fc033b970 100644 --- a/httemplate/view/cust_main/misc.html +++ b/httemplate/view/cust_main/misc.html @@ -1,76 +1,77 @@ -<% - my( $cust_main ) = @_; - my $conf = new FS::Conf; -%> +% +% my( $cust_main ) = @_; +% my $conf = new FS::Conf; +% + -<%= ntable("#cccccc") %><TR><TD><%= &ntable("#cccccc",2) %> +<% ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Customer number</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->custnum %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->custnum %></TD> </TR> <TR> <TD ALIGN="right">Status</TD> - <TD BGCOLOR="#ffffff"><FONT COLOR="#<%= $cust_main->statuscolor %>"><B><%= ucfirst($cust_main->status) %></B></FONT></TD> + <TD BGCOLOR="#ffffff"><FONT COLOR="#<% $cust_main->statuscolor %>"><B><% ucfirst($cust_main->status) %></B></FONT></TD> </TR> +% +% my @agents = qsearch( 'agent', {} ); +% my $agent; +% unless ( scalar(@agents) == 1 ) { +% $agent = qsearchs('agent',{ 'agentnum' => $cust_main->agentnum } ); +% -<% - my @agents = qsearch( 'agent', {} ); - my $agent; - unless ( scalar(@agents) == 1 ) { - $agent = qsearchs('agent',{ 'agentnum' => $cust_main->agentnum } ); -%> <TR> <TD ALIGN="right">Agent</TD> - <TD BGCOLOR="#ffffff"><%= $agent->agentnum %>: <%= $agent->agent %></TD> + <TD BGCOLOR="#ffffff"><% $agent->agentnum %>: <% $agent->agent %></TD> </TR> +% +% } else { +% $agent = $agents[0]; +% } +% +% if ( $cust_main->agent_custid ) { +% -<% - } else { - $agent = $agents[0]; - } - - if ( $cust_main->agent_custid ) { -%> <TR> <TD ALIGN="right">Agent customer ref#</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->agent_custid %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->agent_custid %></TD> </TR> +% +% } +% +% unless ( FS::part_referral->num_part_referral == 1 ) { +% my $referral = qsearchs('part_referral', { +% 'refnum' => $cust_main->refnum +% } ); +% -<% - } - - unless ( FS::part_referral->num_part_referral == 1 ) { - my $referral = qsearchs('part_referral', { - 'refnum' => $cust_main->refnum - } ); -%> <TR> <TD ALIGN="right">Advertising source</TD> - <TD BGCOLOR="#ffffff"><%= $referral->refnum %>: <%= $referral->referral%></TD> + <TD BGCOLOR="#ffffff"><% $referral->refnum %>: <% $referral->referral%></TD> </TR> +% } -<% } %> <TR> <TD ALIGN="right">Referring Customer</TD> <TD BGCOLOR="#ffffff"> +% +% my $referring_cust_main = ''; +% if ( $cust_main->referral_custnum +% && ( $referring_cust_main = +% qsearchs('cust_main', { custnum => $cust_main->referral_custnum } ) +% ) +% ) { +% + +<A HREF="<% popurl(1) %>cust_main.cgi?<% $cust_main->referral_custnum %>"><%$cust_main->referral_custnum %>: <% - my $referring_cust_main = ''; - if ( $cust_main->referral_custnum - && ( $referring_cust_main = - qsearchs('cust_main', { custnum => $cust_main->referral_custnum } ) - ) - ) { -%> - -<A HREF="<%= popurl(1) %>cust_main.cgi?<%= $cust_main->referral_custnum %>"><%=$cust_main->referral_custnum %>: -<%= ( $referring_cust_main->company ? $referring_cust_main->company. ' ('. $referring_cust_main->last. ', '. $referring_cust_main->first. @@ -78,15 +79,15 @@ : $referring_cust_main->last. ', '. $referring_cust_main->first ) %></A> +% } -<% } %> </TD> </TR> <TR> <TD ALIGN="right">Order taker</TD> - <TD BGCOLOR="#ffffff"><%= $cust_main->otaker %></TD> + <TD BGCOLOR="#ffffff"><% $cust_main->otaker %></TD> </TR> </TABLE></TD></TR></TABLE> diff --git a/httemplate/view/cust_main/order_pkg.html b/httemplate/view/cust_main/order_pkg.html index ac2d05df2..6edd18c05 100644 --- a/httemplate/view/cust_main/order_pkg.html +++ b/httemplate/view/cust_main/order_pkg.html @@ -1,6 +1,7 @@ -<% - my( $cust_main ) = @_; -%> +% +% my( $cust_main ) = @_; +% + <SCRIPT TYPE="text/javascript"> function enable_order_pkg () { @@ -12,25 +13,25 @@ function enable_order_pkg () { } </SCRIPT> -<FORM NAME="OrderPkgForm" ACTION="<%= $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST"> +<FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST"> -<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $cust_main->custnum %>"> +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>"> <SELECT NAME="pkgpart" onChange="enable_order_pkg()"><OPTION>Order additional package +% +%foreach my $part_pkg ( +% qsearch( 'part_pkg', { 'disabled' => '' }, '', +% ' AND 0 < ( SELECT COUNT(*) FROM type_pkgs '. +% ' WHERE typenum = '. $cust_main->agent->typenum. +% ' AND type_pkgs.pkgpart = part_pkg.pkgpart )' +% ) +%) { +% -<% -foreach my $part_pkg ( - qsearch( 'part_pkg', { 'disabled' => '' }, '', - ' AND 0 < ( SELECT COUNT(*) FROM type_pkgs '. - ' WHERE typenum = '. $cust_main->agent->typenum. - ' AND type_pkgs.pkgpart = part_pkg.pkgpart )' - ) -) { -%> - <OPTION VALUE="<%= $part_pkg->pkgpart %>"><%= $part_pkg->pkg %> - <%= $part_pkg->comment %> + <OPTION VALUE="<% $part_pkg->pkgpart %>"><% $part_pkg->pkg %> - <% $part_pkg->comment %> +% } -<% } %> </SELECT> diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html index 9cd1e284f..0278f22e9 100755 --- a/httemplate/view/cust_main/packages.html +++ b/httemplate/view/cust_main/packages.html @@ -1,567 +1,575 @@ -<% - my( $cust_main ) = @_; - my $conf = new FS::Conf; +% +% my( $cust_main ) = @_; +% my $conf = new FS::Conf; +% +% my $curuser = $FS::CurrentUser::CurrentUser; +% +% my $packages = get_packages($cust_main, $conf); +% - my $curuser = $FS::CurrentUser::CurrentUser; - - my $packages = get_packages($cust_main, $conf); -%> <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A> +% if ( $curuser->access_right('Order customer package') ) { + + <% include('order_pkg.html', $cust_main ) %> +% } +% if ( $curuser->access_right('One-time charge') +% && $conf->config('payby-default') ne 'HIDE' +% ) { +% -<% if ( $curuser->access_right('Order customer package') ) { %> - <%= include('order_pkg.html', $cust_main ) %> -<% } %> + <% include('quick-charge.html', $cust_main ) %> +% } +% if ( $curuser->access_right('Bulk change customer packages') ) { -<% if ( $curuser->access_right('One-time charge') - && $conf->config('payby-default') ne 'HIDE' - ) { -%> - <%= include('quick-charge.html', $cust_main ) %> -<% } %> + <A HREF="<% $p %>edit/cust_pkg.cgi?<% $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services) +% } -<% if ( $curuser->access_right('Bulk change customer packages') ) { %> - <A HREF="<%= $p %>edit/cust_pkg.cgi?<%= $cust_main->custnum %>">Bulk order and cancel packages</A> (preserves services) -<% } %> <BR><BR> +% if ( @$packages ) { -<% if ( @$packages ) { %> Current packages -<% } %> - -<% if ( $cust_main->num_cancelled_pkgs ) { - if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me - || ( $conf->exists('hidecancelledpackages') - && ! $cgi->param('showcancelledpackages') - ) - ) - { - $cgi->param('showcancelledpackages', 1); -%> - ( <a href="<%= $cgi->self_url %>">show -<% } else { - $cgi->param('showcancelledpackages', 0); -%> - ( <a href="<%= $cgi->self_url %>">hide -<% } %> +% } +% if ( $cust_main->num_cancelled_pkgs ) { +% if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me +% || ( $conf->exists('hidecancelledpackages') +% && ! $cgi->param('showcancelledpackages') +% ) +% ) +% { +% $cgi->param('showcancelledpackages', 1); +% + + ( <a href="<% $cgi->self_url %>">show +% } else { +% $cgi->param('showcancelledpackages', 0); +% + + ( <a href="<% $cgi->self_url %>">hide +% } + cancelled packages</a> ) -<% } %> +% } +% if ( @$packages ) { -<% if ( @$packages ) { %> -<%= include('/elements/table-grid.html') %> +<% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; +% -<% my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor = ''; -%> <TR> <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH> <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH> <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH> </TR> +% +%foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% + + +<!--pkgnum: <%$pkg->{pkgnum}%>--> +<TR> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <A NAME="cust_pkg<%$pkg->{pkgnum}%>"><%$pkg->{pkgnum}%></A>: + <%$pkg->{pkg}%> - <%$pkg->{comment}%><BR> + <FONT SIZE=-1> +% unless ( $pkg->{cancel} ) { +% if ( $curuser->access_right('Change customer package') ) { -<% -foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { + ( <%pkg_change_link($pkg)%> ) +% } +% if ( $curuser->access_right('Edit customer package dates') ) { - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } + ( <%pkg_dates_link($pkg)%> ) +% } +% if ( $curuser->access_right('Customize customer package') ) { -%> + ( <%pkg_customize_link($pkg,$cust_main->custnum)%> ) +% } +% } -<!--pkgnum: <%=$pkg->{pkgnum}%>--> -<TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <A NAME="cust_pkg<%=$pkg->{pkgnum}%>"><%=$pkg->{pkgnum}%></A>: - <%=$pkg->{pkg}%> - <%=$pkg->{comment}%><BR> - <FONT SIZE=-1> - <% unless ( $pkg->{cancel} ) { %> - <% if ( $curuser->access_right('Change customer package') ) { %> - ( <%=pkg_change_link($pkg)%> ) - <% } %> - <% if ( $curuser->access_right('Edit customer package dates') ) { %> - ( <%=pkg_dates_link($pkg)%> ) - <% } %> - <% if ( $curuser->access_right('Customize customer package') ) { %> - ( <%=pkg_customize_link($pkg,$cust_main->custnum)%> ) - <% } %> - <% } %> </FONT> </TD> - <TD CLASS="inv" BGCOLOR="<%= $bgcolor %>"> + <TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> - -<% - sub myfreq { - my $part_pkg = shift; - my $freq = $part_pkg->freq_pretty; - $freq =~ s/ / /g; - $freq; - } - - #this should use cust_pkg->status and cust_pkg->statuscolor eventually - - my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4; - my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%'; - - #false laziness w/edit/REAL_cust_pkg.cgi - my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until ); - unless ( $pkg->{'part_pkg'}->is_prepaid ) { - $billed_or_prepaid = 'billed'; - $last_bill_or_renewed = 'Last bill'; - $next_bill_or_prepaid_until = 'Next bill'; - } else { - $billed_or_prepaid = 'prepaid'; - $last_bill_or_renewed = 'Renewed'; - $next_bill_or_prepaid_until = 'Prepaid until'; - } - -%> - -<% if ( $pkg->{cancel} ) { %> <!-- #status: cancelled --> +% +% sub myfreq { +% my $part_pkg = shift; +% my $freq = $part_pkg->freq_pretty; +% $freq =~ s/ / /g; +% $freq; +% } +% +% #this should use cust_pkg->status and cust_pkg->statuscolor eventually +% +% my $colspan = $conf->exists('cust_pkg-display_times') ? 8 : 4; +% my $width = $conf->exists('cust_pkg-display_times') ? '38%' : '56%'; +% +% #false laziness w/edit/REAL_cust_pkg.cgi +% my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until ); +% unless ( $pkg->{'part_pkg'}->is_prepaid ) { +% $billed_or_prepaid = 'billed'; +% $last_bill_or_renewed = 'Last bill'; +% $next_bill_or_prepaid_until = 'Next bill'; +% } else { +% $billed_or_prepaid = 'prepaid'; +% $last_bill_or_renewed = 'Renewed'; +% $next_bill_or_prepaid_until = 'Prepaid until'; +% } +% +% +% if ( $pkg->{cancel} ) { + <!-- #status: cancelled --> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD> - <%= pkg_datestr($pkg,'cancel',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD> + <% pkg_datestr($pkg,'cancel',$conf) %> </TR> +% unless ( $pkg->{setup} ) { - <% unless ( $pkg->{setup} ) { %> <TR> - <TD COLSPAN=<%=$colspan%>>Never billed</TD> + <TD COLSPAN=<%$colspan%>>Never billed</TD> </TR> +% } else { - <% } else { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Setup </TD> - <%= pkg_datestr($pkg, 'setup',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD> + <% pkg_datestr($pkg, 'setup',$conf) %> </TR> +% if ( $pkg->{'last_bill'} ) { - <% if ( $pkg->{'last_bill'} ) { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><%= $last_bill_or_renewed %> </TD> - <%= pkg_datestr($pkg, 'last_bill',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD> + <% pkg_datestr($pkg, 'last_bill',$conf) %> </TR> - <% } %> +% } +% if ( $pkg->{'susp'} ) { - <% if ( $pkg->{'susp'} ) { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Suspended </TD> - <%= pkg_datestr($pkg, 'susp',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right">Suspended </TD> + <% pkg_datestr($pkg, 'susp',$conf) %> </TR> - <% } %> - - <% } %> - -<% } else { %> - - <% if ( $pkg->{susp} ) { %> <!-- #status: suspended --> +% } +% } +% } else { +% if ( $pkg->{susp} ) { + <!-- #status: suspended --> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><FONT COLOR="#FF9900"><B>Suspended</B> </FONT></TD> - <%= pkg_datestr($pkg,'susp',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right"><FONT COLOR="#FF9900"><B>Suspended</B> </FONT></TD> + <% pkg_datestr($pkg,'susp',$conf) %> </TR> +% unless ( $pkg->{setup} ) { - <% unless ( $pkg->{setup} ) { %> <TR> - <TD COLSPAN=<%=$colspan%>>Never billed</TD> + <TD COLSPAN=<%$colspan%>>Never billed</TD> </TR> +% } else { - <% } else { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Setup </TD> - <%= pkg_datestr($pkg, 'setup',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD> + <% pkg_datestr($pkg, 'setup',$conf) %> </TR> - - <% } %> +% } +% if ( $pkg->{'last_bill'} ) { - <% if ( $pkg->{'last_bill'} ) { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><%= $last_bill_or_renewed %> </TD> - <%= pkg_datestr($pkg, 'last_bill',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD> + <% pkg_datestr($pkg, 'last_bill',$conf) %> </TR> - <% } %> +% } + <!-- # next bill ?? --> +% if ( $pkg->{'expire'} ) { - <% if ( $pkg->{'expire'} ) { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Expires </TD> - <%= pkg_datestr($pkg, 'expire',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD> + <% pkg_datestr($pkg, 'expire',$conf) %> </TR> - <% } %> +% } + <TR> - <TD COLSPAN=<%=$colspan%>> + <TD COLSPAN=<%$colspan%>> <FONT SIZE=-1> - <% if ( $curuser->access_right('Unsuspend customer package') ) { %> - ( <%= pkg_unsuspend_link($pkg) %> ) - <% } %> - <% if ( $curuser->access_right('Cancel customer package') ) { %> - ( <%= pkg_cancel_link($pkg) %> ) - <% } %> +% if ( $curuser->access_right('Unsuspend customer package') ) { + + ( <% pkg_unsuspend_link($pkg) %> ) +% } +% if ( $curuser->access_right('Cancel customer package') ) { + + ( <% pkg_cancel_link($pkg) %> ) +% } + </FONT> </TD> </TR> +% } else { + <!-- #status: active --> +% unless ( $pkg->{setup} ) { + <!-- #not setup --> +% unless ( $pkg->{'freq'} ) { - <% } else { %> <!-- #status: active --> - - <% unless ( $pkg->{setup} ) { %> <!-- #not setup --> - - <% unless ( $pkg->{'freq'} ) { %> <TR> - <TD COLSPAN=<%=$colspan%>>Not yet billed (one-time charge)</TD> + <TD COLSPAN=<%$colspan%>>Not yet billed (one-time charge)</TD> </TR> <TR> - <TD COLSPAN=<%=$colspan%>> + <TD COLSPAN=<%$colspan%>> <FONT SIZE=-1> - <% if ( $curuser->access_right('Cancel customer package immediately') ) { %> - ( <%= pkg_cancel_link($pkg) %> ) - <% } %> +% if ( $curuser->access_right('Cancel customer package immediately') ) { + + ( <% pkg_cancel_link($pkg) %> ) +% } + </FONT> </TD> </TR> +% } else { - <% } else { %> <TR> - <TD COLSPAN=<%=$colspan%>>Not yet billed (<%= $billed_or_prepaid %> <%= myfreq($pkg->{part_pkg}) %>)</TD> + <TD COLSPAN=<%$colspan%>>Not yet billed (<% $billed_or_prepaid %> <% myfreq($pkg->{part_pkg}) %>)</TD> </TR> +% } +% } else { + <!-- #setup --> +% unless ( $pkg->{freq} ) { - <% } %> - - <% } else { %> <!-- #setup --> - - <% unless ( $pkg->{freq} ) { %> <TR> - <TD COLSPAN=<%=$colspan%>>One-time charge</TD> + <TD COLSPAN=<%$colspan%>>One-time charge</TD> </TR> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Billed </TD> - <%= pkg_datestr($pkg,'setup',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right">Billed </TD> + <% pkg_datestr($pkg,'setup',$conf) %> </TR> +% } else { - <% } else { %> <TR> - <TD COLSPAN=<%=$colspan%>><FONT COLOR="#00CC00"><B>Active</B></FONT>, <%= $billed_or_prepaid %> <%= myfreq($pkg->{part_pkg}) %></TD> + <TD COLSPAN=<%$colspan%>><FONT COLOR="#00CC00"><B>Active</B></FONT>, <% $billed_or_prepaid %> <% myfreq($pkg->{part_pkg}) %></TD> </TR> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Setup </TD> - <%= pkg_datestr($pkg, 'setup',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right">Setup </TD> + <% pkg_datestr($pkg, 'setup',$conf) %> </TR> +% } +% } +% if ( $pkg->{'last_bill'} ) { - <% } %> - - <% } %> - - <% if ( $pkg->{'last_bill'} ) { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><%= $last_bill_or_renewed %> </TD> - <%= pkg_datestr($pkg, 'last_bill',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right"><% $last_bill_or_renewed %> </TD> + <% pkg_datestr($pkg, 'last_bill',$conf) %> </TR> - <% } %> +% } +% if ( $pkg->{'next_bill'} ) { - <% if ( $pkg->{'next_bill'} ) { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right"><%= $next_bill_or_prepaid_until %> </TD> - <%= pkg_datestr($pkg, 'next_bill',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right"><% $next_bill_or_prepaid_until %> </TD> + <% pkg_datestr($pkg, 'next_bill',$conf) %> </TR> - <% } %> +% } +% if ( $pkg->{'expire'} ) { - <% if ( $pkg->{'expire'} ) { %> <TR> - <TD WIDTH="<%=$width%>" ALIGN="right">Expires </TD> - <%= pkg_datestr($pkg, 'expire',$conf) %> + <TD WIDTH="<%$width%>" ALIGN="right">Expires </TD> + <% pkg_datestr($pkg, 'expire',$conf) %> </TR> - <% } %> +% } +% if ( $pkg->{freq} ) { - <% if ( $pkg->{freq} ) { %> <TR> - <TD COLSPAN=<%=$colspan%>> + <TD COLSPAN=<%$colspan%>> <FONT SIZE=-1> - <% if ( $curuser->access_right('Suspend customer package') ) { %> - ( <%= pkg_suspend_link($pkg) %> ) - <% } %> - <% if ( $curuser->access_right('Cancel customer package immediately') ) { %> - ( <%= pkg_cancel_link($pkg) %> ) - <% } %> - <% if ( $curuser->access_right('Cancel customer package later') ) { %> - ( <%= pkg_expire_link($pkg) %> ) - <% } %> +% if ( $curuser->access_right('Suspend customer package') ) { + + ( <% pkg_suspend_link($pkg) %> ) +% } +% if ( $curuser->access_right('Cancel customer package immediately') ) { + + ( <% pkg_cancel_link($pkg) %> ) +% } +% if ( $curuser->access_right('Cancel customer package later') ) { + + ( <% pkg_expire_link($pkg) %> ) +% } + <FONT> </TD> </TR> - <% } %> - - <% } %> +% } +% } +% } -<% } %> </TABLE> </TD> -<TD CLASS="inv" BGCOLOR="<%= $bgcolor %>"> +<TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> +% +% foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) { +% foreach my $service (@{$svcpart->{services}}) { +% - -<% - foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) { - foreach my $service (@{$svcpart->{services}}) { -%> <TR> - <TD ALIGN="right" VALIGN="top" ROWSPAN=2><%=svc_link($svcpart,$service)%></TD> - <TD STYLE="padding-bottom:0px"><B><%=svc_label_link($svcpart,$service)%></B></TD> + <TD ALIGN="right" VALIGN="top" ROWSPAN=2><%svc_link($svcpart,$service)%></TD> + <TD STYLE="padding-bottom:0px"><B><%svc_label_link($svcpart,$service)%></B></TD> </TR> +% if ( $curuser->access_right('Unprovision customer service') ) { - <% if ( $curuser->access_right('Unprovision customer service') ) { %> <TR> - <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">( <%=svc_unprovision_link($service)%> )</FONT></TD> + <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">( <%svc_unprovision_link($service)%> )</FONT></TD> </TR> - <% } %> - - <% } %> +% } +% } +% if ( $curuser->access_right('Provision customer service') +% && $svcpart->{count} < $svcpart->{quantity} +% ) +% { +% - <% if ( $curuser->access_right('Provision customer service') - && $svcpart->{count} < $svcpart->{quantity} - ) - { - %> <TR> <TD COLSPAN=2 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px"> - <B><%= svc_provision_link($pkg, $svcpart, $conf, $curuser) %></B> + <B><% svc_provision_link($pkg, $svcpart, $conf, $curuser) %></B> </TD> </TR> +% } +% } - <% } %> - -<% } %> </TABLE> </TD> +% } #end display packages +% -<% } #end display packages -%> </TABLE> +% } else { -<% } else { %> <BR> -<% } %> - -<% -#subroutines - -sub get_packages { - my $cust_main = shift or return undef; - my $conf = shift; - - my @packages = (); - my $method; - if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me - || ( $conf->exists('hidecancelledpackages') - && ! $cgi->param('showcancelledpackages') ) - ) - { - $method = 'ncancelled_pkgs'; - } else { - $method = 'all_pkgs'; - } - - foreach my $cust_pkg ( $cust_main->$method() ) { - - my $part_pkg = $cust_pkg->part_pkg; - - my %pkg = (); - - #to get back to the original object... should use it in the first place!! - $pkg{cust_pkg} = $cust_pkg; - $pkg{part_pkg} = $part_pkg; - - $pkg{pkgnum} = $cust_pkg->pkgnum; - $pkg{pkg} = $part_pkg->pkg; - $pkg{pkgpart} = $part_pkg->pkgpart; - $pkg{comment} = $part_pkg->getfield('comment'); - $pkg{freq} = $part_pkg->freq; - $pkg{setup} = $cust_pkg->getfield('setup'); - $pkg{last_bill} = $cust_pkg->getfield('last_bill'); - $pkg{next_bill} = $cust_pkg->getfield('bill'); - $pkg{susp} = $cust_pkg->getfield('susp'); - $pkg{expire} = $cust_pkg->getfield('expire'); - $pkg{cancel} = $cust_pkg->getfield('cancel'); - - - my %svcparts = map { - $_->svcpart => { - $_->part_svc->hash, - 'quantity' => $_->quantity, - 'count' => $cust_pkg->num_cust_svc($_->svcpart), - #'services' => [], - }; - } $part_pkg->pkg_svc; - - foreach my $cust_svc ( $cust_pkg->cust_svc ) { - #warn "svcnum ". $cust_svc->svcnum. " / svcpart ". $cust_svc->svcpart. "\n"; - my $svc = { - 'svcnum' => $cust_svc->svcnum, - 'label' => ($cust_svc->label)[1], - }; - - #false laziness with above, to catch extraneous services. whole - #damn thing should be OO... - my $svcpart = ( $svcparts{$cust_svc->svcpart} ||= { - $cust_svc->part_svc->hash, - 'quantity' => 0, - 'count' => $cust_pkg->num_cust_svc($cust_svc->svcpart), - #'services' => [], - } ); - - push @{$svcpart->{services}}, $svc; - - } - - $pkg{svcparts} = [ values %svcparts ]; - - push @packages, \%pkg; - - } - - return \@packages; - -} - -sub svc_link { - - my ($svcpart, $svc) = (shift,shift) or return ''; - return qq!<A HREF="${p}view/$svcpart->{svcdb}.cgi?$svc->{svcnum}">$svcpart->{svc}</A>!; - -} - -sub svc_label_link { - - my ($svcpart, $svc) = (shift,shift) or return ''; - return qq!<A HREF="${p}view/$svcpart->{svcdb}.cgi?$svc->{svcnum}">$svc->{label}</A>!; - -} - -sub svc_provision_link { - my ($pkg, $svcpart, $conf, $curuser) = @_; - ( my $svc_nbsp = $svcpart->{svc} ) =~ s/\s+/ /g; - my $num_left = $svcpart->{quantity} - $svcpart->{count}; - my $pkgnum_svcpart = "pkgnum$pkg->{pkgnum}-svcpart$svcpart->{svcpart}"; - - my $url; - if ( $svcpart->{svcdb} eq 'svc_external' - && $conf->exists('svc_external-skip_manual') - ) { - $url = "${p}edit/process/$svcpart->{svcdb}.cgi?". - "pkgnum=$pkg->{pkgnum}&". - "svcpart=$svcpart->{svcpart}"; - } else { - $url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart"; - } - - my $link = qq!<A CLASS="provision" HREF="$url">!. - "Provision $svc_nbsp ($num_left)</A>"; - if ( $conf->exists('legacy_link') - && $curuser->access_right('View/link unlinked services') - ) - { - $link .= '<BR>'. - qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!. - qq!$pkgnum_svcpart">!. - "Link to legacy $svc_nbsp ($num_left)</A>"; - } - $link; -} - -sub svc_unprovision_link { - my $svc = shift or return ''; - qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?$svc->{svcnum}',!. - qq!'Permanently unprovision and delete this service?')">Unprovision</A>!; -} - -# This should be generalized to use config options to determine order. -sub pkgsort_pkgnum_cancel { - if ($a->{cancel} and $b->{cancel}) { - return ($a->{pkgnum} <=> $b->{pkgnum}); - } elsif ($a->{cancel} or $b->{cancel}) { - return (-1) if ($b->{cancel}); - return (1) if ($a->{cancel}); - return (0); - } else { - return($a->{pkgnum} <=> $b->{pkgnum}); - } -} - -sub pkg_datestr { - my($pkg, $field, $conf) = @_ or return ''; - return ' ' unless $pkg->{$field}; - my $format = '<TD align="left"><B>%b</B></TD>'. - '<TD align="right"><B> %o,</B></TD>'. - '<TD align="right"><B> %Y</B></TD>'; - #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>' - $format .= '<TD ALIGN="right"><B> %l</TD>'. - '<TD ALIGN="center"><B>:</B></TD>'. - '<TD ALIGN="left"><B>%M</B></TD>'. - '<TD ALIGN="left"><B> %P</B></TD>' - if $conf->exists('cust_pkg-display_times'); - ( my $strip = time2str($format, $pkg->{$field}) ) =~ s/ (\d)/$1/g; - $strip; -} - -sub pkg_change_link { - my $pkg = shift or return ''; - return qq!<a href="${p}misc/change_pkg.cgi?$pkg->{pkgnum}">!. - qq!Change package</a>!; -} - -sub pkg_suspend_link { - my $pkg = shift or return ''; - return qq!<a href="${p}misc/susp_pkg.cgi?$pkg->{pkgnum}">Suspend</a>!; -} - -sub pkg_unsuspend_link { - my $pkg = shift or return ''; - return qq!<a href="${p}misc/unsusp_pkg.cgi?$pkg->{pkgnum}">Unsuspend</a>!; -} - -sub pkg_cancel_link { - my $pkg = shift or return ''; - qq!<A HREF="javascript:areyousure('${p}misc/cancel_pkg.cgi?$pkg->{pkgnum}', !. - qq!'Permanently delete included services and cancel this package?')">!. - qq!Cancel now</A>!; -} - -sub pkg_expire_link { - my $pkg = shift or return ''; - qq!<A HREF="${p}misc/expire_pkg.cgi?$pkg->{pkgnum}">Cancel later</A>!; -} - -sub pkg_dates_link { - my $pkg = shift or return ''; - qq!<A HREF="${p}edit/REAL_cust_pkg.cgi?$pkg->{pkgnum}">Edit dates</A>!; -} - -sub pkg_customize_link { - my $pkg = shift or return ''; - my $custnum = shift; - qq!<A HREF="${p}edit/part_pkg.cgi?keywords=$custnum;clone=$pkg->{pkgpart};!. - qq!pkgnum=$pkg->{pkgnum}">Customize</A>!; -} - -%> +% } +% +%#subroutines +% +%sub get_packages { +% my $cust_main = shift or return undef; +% my $conf = shift; +% +% my @packages = (); +% my $method; +% if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me +% || ( $conf->exists('hidecancelledpackages') +% && ! $cgi->param('showcancelledpackages') ) +% ) +% { +% $method = 'ncancelled_pkgs'; +% } else { +% $method = 'all_pkgs'; +% } +% +% foreach my $cust_pkg ( $cust_main->$method() ) { +% +% my $part_pkg = $cust_pkg->part_pkg; +% +% my %pkg = (); +% +% #to get back to the original object... should use it in the first place!! +% $pkg{cust_pkg} = $cust_pkg; +% $pkg{part_pkg} = $part_pkg; +% +% $pkg{pkgnum} = $cust_pkg->pkgnum; +% $pkg{pkg} = $part_pkg->pkg; +% $pkg{pkgpart} = $part_pkg->pkgpart; +% $pkg{comment} = $part_pkg->getfield('comment'); +% $pkg{freq} = $part_pkg->freq; +% $pkg{setup} = $cust_pkg->getfield('setup'); +% $pkg{last_bill} = $cust_pkg->getfield('last_bill'); +% $pkg{next_bill} = $cust_pkg->getfield('bill'); +% $pkg{susp} = $cust_pkg->getfield('susp'); +% $pkg{expire} = $cust_pkg->getfield('expire'); +% $pkg{cancel} = $cust_pkg->getfield('cancel'); +% +% +% my %svcparts = map { +% $_->svcpart => { +% $_->part_svc->hash, +% 'quantity' => $_->quantity, +% 'count' => $cust_pkg->num_cust_svc($_->svcpart), +% #'services' => [], +% }; +% } $part_pkg->pkg_svc; +% +% foreach my $cust_svc ( $cust_pkg->cust_svc ) { +% #warn "svcnum ". $cust_svc->svcnum. " / svcpart ". $cust_svc->svcpart. "\n"; +% my $svc = { +% 'svcnum' => $cust_svc->svcnum, +% 'label' => ($cust_svc->label)[1], +% }; +% +% #false laziness with above, to catch extraneous services. whole +% #damn thing should be OO... +% my $svcpart = ( $svcparts{$cust_svc->svcpart} ||= { +% $cust_svc->part_svc->hash, +% 'quantity' => 0, +% 'count' => $cust_pkg->num_cust_svc($cust_svc->svcpart), +% #'services' => [], +% } ); +% +% push @{$svcpart->{services}}, $svc; +% +% } +% +% $pkg{svcparts} = [ values %svcparts ]; +% +% push @packages, \%pkg; +% +% } +% +% return \@packages; +% +%} +% +%sub svc_link { +% +% my ($svcpart, $svc) = (shift,shift) or return ''; +% return qq!<A HREF="${p}view/$svcpart->{svcdb}.cgi?$svc->{svcnum}">$svcpart->{svc}</A>!; +% +%} +% +%sub svc_label_link { +% +% my ($svcpart, $svc) = (shift,shift) or return ''; +% return qq!<A HREF="${p}view/$svcpart->{svcdb}.cgi?$svc->{svcnum}">$svc->{label}</A>!; +% +%} +% +%sub svc_provision_link { +% my ($pkg, $svcpart, $conf, $curuser) = @_; +% ( my $svc_nbsp = $svcpart->{svc} ) =~ s/\s+/ /g; +% my $num_left = $svcpart->{quantity} - $svcpart->{count}; +% my $pkgnum_svcpart = "pkgnum$pkg->{pkgnum}-svcpart$svcpart->{svcpart}"; +% +% my $url; +% if ( $svcpart->{svcdb} eq 'svc_external' +% && $conf->exists('svc_external-skip_manual') +% ) { +% $url = "${p}edit/process/$svcpart->{svcdb}.cgi?". +% "pkgnum=$pkg->{pkgnum}&". +% "svcpart=$svcpart->{svcpart}"; +% } else { +% $url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart"; +% } +% +% my $link = qq!<A CLASS="provision" HREF="$url">!. +% "Provision $svc_nbsp ($num_left)</A>"; +% if ( $conf->exists('legacy_link') +% && $curuser->access_right('View/link unlinked services') +% ) +% { +% $link .= '<BR>'. +% qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!. +% qq!$pkgnum_svcpart">!. +% "Link to legacy $svc_nbsp ($num_left)</A>"; +% } +% $link; +%} +% +%sub svc_unprovision_link { +% my $svc = shift or return ''; +% qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?$svc->{svcnum}',!. +% qq!'Permanently unprovision and delete this service?')">Unprovision</A>!; +%} +% +%# This should be generalized to use config options to determine order. +%sub pkgsort_pkgnum_cancel { +% if ($a->{cancel} and $b->{cancel}) { +% return ($a->{pkgnum} <=> $b->{pkgnum}); +% } elsif ($a->{cancel} or $b->{cancel}) { +% return (-1) if ($b->{cancel}); +% return (1) if ($a->{cancel}); +% return (0); +% } else { +% return($a->{pkgnum} <=> $b->{pkgnum}); +% } +%} +% +%sub pkg_datestr { +% my($pkg, $field, $conf) = @_ or return ''; +% return ' ' unless $pkg->{$field}; +% my $format = '<TD align="left"><B>%b</B></TD>'. +% '<TD align="right"><B> %o,</B></TD>'. +% '<TD align="right"><B> %Y</B></TD>'; +% #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>' +% $format .= '<TD ALIGN="right"><B> %l</TD>'. +% '<TD ALIGN="center"><B>:</B></TD>'. +% '<TD ALIGN="left"><B>%M</B></TD>'. +% '<TD ALIGN="left"><B> %P</B></TD>' +% if $conf->exists('cust_pkg-display_times'); +% ( my $strip = time2str($format, $pkg->{$field}) ) =~ s/ (\d)/$1/g; +% $strip; +%} +% +%sub pkg_change_link { +% my $pkg = shift or return ''; +% return qq!<a href="${p}misc/change_pkg.cgi?$pkg->{pkgnum}">!. +% qq!Change package</a>!; +%} +% +%sub pkg_suspend_link { +% my $pkg = shift or return ''; +% return qq!<a href="${p}misc/susp_pkg.cgi?$pkg->{pkgnum}">Suspend</a>!; +%} +% +%sub pkg_unsuspend_link { +% my $pkg = shift or return ''; +% return qq!<a href="${p}misc/unsusp_pkg.cgi?$pkg->{pkgnum}">Unsuspend</a>!; +%} +% +%sub pkg_cancel_link { +% my $pkg = shift or return ''; +% qq!<A HREF="javascript:areyousure('${p}misc/cancel_pkg.cgi?$pkg->{pkgnum}', !. +% qq!'Permanently delete included services and cancel this package?')">!. +% qq!Cancel now</A>!; +%} +% +%sub pkg_expire_link { +% my $pkg = shift or return ''; +% qq!<A HREF="${p}misc/expire_pkg.cgi?$pkg->{pkgnum}">Cancel later</A>!; +%} +% +%sub pkg_dates_link { +% my $pkg = shift or return ''; +% qq!<A HREF="${p}edit/REAL_cust_pkg.cgi?$pkg->{pkgnum}">Edit dates</A>!; +%} +% +%sub pkg_customize_link { +% my $pkg = shift or return ''; +% my $custnum = shift; +% qq!<A HREF="${p}edit/part_pkg.cgi?keywords=$custnum;clone=$pkg->{pkgpart};!. +% qq!pkgnum=$pkg->{pkgnum}">Customize</A>!; +%} +% +% + diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index aef5fb8f8..244635c9a 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -1,421 +1,416 @@ -<% - my( $cust_main ) = @_; - my $custnum = $cust_main->custnum; +% +% my( $cust_main ) = @_; +% my $custnum = $cust_main->custnum; +% +% my $conf = new FS::Conf; +% +% my $curuser = $FS::CurrentUser::CurrentUser; +% +% my @payby = grep /\w/, $conf->config('payby'); +% #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) +% @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) +% unless @payby; +% my %payby = map { $_=>1 } @payby; +% +% my $s = 0; +% +% - my $conf = new FS::Conf; - - my $curuser = $FS::CurrentUser::CurrentUser; - - my @payby = grep /\w/, $conf->config('payby'); - #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) - @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) - unless @payby; - my %payby = map { $_=>1 } @payby; - - my $s = 0; - -%> <BR><BR><A NAME="history"><FONT SIZE="+2">Payment History</FONT></A><BR> +% if ( $payby{'BILL'} && $curuser->access_right('Post payment') ) { -<% if ( $payby{'BILL'} && $curuser->access_right('Post payment') ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<%= $p %>edit/cust_pay.cgi?popup=1;payby=BILL;custnum=<%= $custnum %>', 392, 336, 'cust_pay_popup' ), CAPTION, 'Enter check payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter check payment</A> - -<% } %> - -<% if ( $payby{'CASH'} && $curuser->access_right('Post payment') ) { %> - - <%= $s++ ? ' | ' : '' %> - <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<%= $p %>edit/cust_pay.cgi?popup=1;payby=CASH;custnum=<%= $custnum %>', 392, 336, 'cust_pay_popup' ), CAPTION, 'Enter cash payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter cash payment</A> -<% } %> + <% $s++ ? ' | ' : '' %> + <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<% $p %>edit/cust_pay.cgi?popup=1;payby=BILL;custnum=<% $custnum %>', 392, 336, 'cust_pay_popup' ), CAPTION, 'Enter check payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter check payment</A> +% } +% if ( $payby{'CASH'} && $curuser->access_right('Post payment') ) { -<% if ( $payby{'WEST'} && $curuser->access_right('Post payment') ) { %> - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;custnum=<%= $custnum %>">Enter Western Union payment</A> + <% $s++ ? ' | ' : '' %> + <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<% $p %>edit/cust_pay.cgi?popup=1;payby=CASH;custnum=<% $custnum %>', 392, 336, 'cust_pay_popup' ), CAPTION, 'Enter cash payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter cash payment</A> +% } +% if ( $payby{'WEST'} && $curuser->access_right('Post payment') ) { -<% } %> -<% if ( ( $payby{'CARD'} || $payby{'DCRD'} ) - && $curuser->access_right('Process payment') - ) { -%> + <% $s++ ? ' | ' : '' %> + <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;custnum=<% $custnum %>">Enter Western Union payment</A> +% } +% if ( ( $payby{'CARD'} || $payby{'DCRD'} ) +% && $curuser->access_right('Process payment') +% ) { +% - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>misc/payment.cgi?payby=CARD;custnum=<%= $custnum %>">Process credit card payment</A> -<% } %> + <% $s++ ? ' | ' : '' %> + <A HREF="<% $p %>misc/payment.cgi?payby=CARD;custnum=<% $custnum %>">Process credit card payment</A> +% } +% if ( ( $payby{'CHEK'} || $payby{'DCHK'} ) +% && $curuser->access_right('Process payment') +% ) { +% -<% if ( ( $payby{'CHEK'} || $payby{'DCHK'} ) - && $curuser->access_right('Process payment') - ) { -%> - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>misc/payment.cgi?payby=CHEK;custnum=<%= $custnum %>">Process electronic check (ACH) payment</A> + <% $s++ ? ' | ' : '' %> + <A HREF="<% $p %>misc/payment.cgi?payby=CHEK;custnum=<% $custnum %>">Process electronic check (ACH) payment</A> +% } +% if ( $payby{'MCRD'} && $curuser->access_right('Post payment') ) { -<% } %> -<% if ( $payby{'MCRD'} && $curuser->access_right('Post payment') ) { %> + <% $s++ ? ' | ' : '' %> + <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;custnum=<% $custnum %>">Post manual (offline) credit card payment</A> +% } - <%= $s++ ? ' | ' : '' %> - <A HREF="<%= $p %>edit/cust_pay.cgi?payby=MCRD;custnum=<%= $custnum %>">Post manual (offline) credit card payment</A> - -<% } %> <BR> +% if ( $curuser->access_right('Post credit') ) { -<% if ( $curuser->access_right('Post credit') ) { %> - <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<%= $p %>edit/cust_credit.cgi?<%= $custnum %>', 392, 336, 'cust_credit_popup' ), CAPTION, 'Enter credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter credit</A> + <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<% $p %>edit/cust_credit.cgi?<% $custnum %>', 392, 336, 'cust_credit_popup' ), CAPTION, 'Enter credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Enter credit</A> <BR> +% } +% +%#get payment history +%my @history = (); +% +%#invoices +%foreach my $cust_bill ($cust_main->cust_bill) { +% my $pre = ( $cust_bill->owed > 0 ) +% ? '<B><FONT SIZE="+1" COLOR="#FF0000">Open ' +% : ''; +% my $post = ( $cust_bill->owed > 0 ) ? '</FONT></B>' : ''; +% my $invnum = $cust_bill->invnum; +% my $link = $curuser->access_right('View invoices') +% ? qq!<A HREF="${p}view/cust_bill.cgi?$invnum">! +% : ''; +% push @history, { +% 'date' => $cust_bill->_date, +% 'desc' => $link. $pre. +% "Invoice #$invnum (Balance \$". $cust_bill->owed. ')'. +% $post. ( $link ? '</A>' : '' ), +% 'charge' => $cust_bill->charged, +% }; +%} +% +%#payments (some false laziness w/credits) +%foreach my $cust_pay ($cust_main->cust_pay) { +% +% my $payby = $cust_pay->payby; +% +% my $payinfo; +% if ( $payby eq 'CARD' ) { +% $payinfo = $cust_pay->payinfo_masked; +% } elsif ( $payby eq 'CHEK' && $cust_pay->payinfo =~ /^(\d+)\@(\d+)$/ ) { +% $payinfo = "ABA $2, Acct# $1"; +% } else { +% $payinfo = $cust_pay->payinfo; +% } +% my @cust_bill_pay = $cust_pay->cust_bill_pay; +% my @cust_pay_refund = $cust_pay->cust_pay_refund; +% +% my $target = "$payby$payinfo"; +% $payby =~ s/^BILL$/Check #/ if $payinfo; +% $payby =~ s/^CHEK$/Electronic check /; +% $payby =~ s/^PREP$/Prepaid card /; +% $payby =~ s/^CARD$/Credit card #/; +% $payby =~ s/^COMP$/Complimentary by /; +% $payby =~ s/^CASH$/Cash/; +% $payby =~ s/^WEST$/Western Union/; +% $payby =~ s/^MCRD$/Manual credit card/; +% $payby =~ s/^BILL$//; +% my $info = $payby ? " ($payby$payinfo)" : ''; +% +% my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' ); +% if ( scalar(@cust_bill_pay) == 0 +% && scalar(@cust_pay_refund) == 0 ) { +% #completely unapplied +% $pre = '<B><FONT COLOR="#FF0000">Unapplied '; +% $post = '</FONT></B>'; +% $apply = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_bill_pay.cgi?!. +% $cust_pay->paynum. +% qq!', 392, 336, 'cust_bill_pay_popup' ), CAPTION, 'Apply payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!; +% +% } elsif ( scalar(@cust_bill_pay) == 1 +% && scalar(@cust_pay_refund) == 0 +% && $cust_pay->unapplied == 0 ) { +% #applied to one invoice, the usual situation +% $desc = ' applied to Invoice #'. $cust_bill_pay[0]->invnum; +% } elsif ( scalar(@cust_bill_pay) == 0 +% && scalar(@cust_pay_refund) == 1 +% && $cust_pay->unapplied == 0 ) { +% #applied to one refund +% $desc = ' refunded on '. time2str("%D", $cust_pay_refund[0]->_date); +% } else { +% #complicated +% $desc = '<BR>'; +% foreach my $app ( sort { $a->_date <=> $b->_date } +% ( @cust_bill_pay, @cust_pay_refund ) ) { +% if ( $app->isa('FS::cust_bill_pay') ) { +% $desc .= ' '. +% '$'. $app->amount. +% ' applied to Invoice #'. $app->invnum. +% '<BR>'; +% #' on '. time2str("%D", $cust_bill_pay->_date). +% } elsif ( $app->isa('FS::cust_pay_refund') ) { +% $desc .= ' '. +% '$'. $app->amount. +% ' refunded on '. time2str("%D", $app->_date). +% '<BR>'; +% } else { +% die "$app is not a FS::cust_bill_pay or FS::cust_pay_refund"; +% } +% } +% if ( $cust_pay->unapplied > 0 ) { +% $desc .= ' '. +% '<B><FONT COLOR="#FF0000">$'. +% $cust_pay->unapplied. ' unapplied</FONT></B>'. +% qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_bill_pay.cgi?!. +% $cust_pay->paynum. +% qq!', 392, 336, 'cust_bill_pay_popup' ), CAPTION, 'Apply payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!. +% '<BR>'; +% } +% } +% +% my $refund = ''; +% my $refund_days = $conf->config('card_refund-days') || 120; +% if ( $cust_pay->closed !~ /^Y/i +% && $cust_pay->payby =~ /^(CARD|CHEK)$/ +% && time-$cust_pay->_date < $refund_days*86400 +% && $cust_pay->unrefunded > 0 +% && $curuser->access_right('Refund payment') +% ) { +% $refund = qq! (<A HREF="${p}edit/cust_refund.cgi?payby=$1;!. +% qq!paynum=!. $cust_pay->paynum. '"'. +% qq! TITLE="Send a refund for this payment to the payment gateway"!. +% qq!>refund</A>)!; +% } +% +% my $void = ''; +% if ( $cust_pay->closed !~ /^Y/i +% && ( ( $cust_pay->payby eq 'CARD' +% && $curuser->access_right('Credit card void') +% ) +% || ( $cust_pay->payby eq 'CHEK' +% && $curuser->access_right('Echeck void') +% ) +% || ( $cust_pay->payby !~ /^(CARD|CHEK)$/ +% && $curuser->access_right('Regular void') +% ) +% ) +% ) +% { +% $void = qq! (<A HREF="javascript:areyousure('!. +% qq!${p}misc/void-cust_pay.cgi?!. $cust_pay->paynum. +% qq!', 'Are you sure you want to void this payment?')"!. +% qq! TITLE="Void this payment from the database!. +% ( $cust_pay->payby =~ /^(CARD|CHEK)$/ +% ? ' (do not send anything to the payment gateway)' +% : '' +% ). '"'. +% qq!>void</A>)!; +% } +% +% my $delete = ''; +% if ( $cust_pay->closed !~ /^Y/i +% && $conf->exists('deletepayments') +% && $curuser->access_right('Delete payment') +% ) +% { +% $delete = qq! (<A HREF="javascript:areyousure('!. +% qq!${p}misc/delete-cust_pay.cgi?!. $cust_pay->paynum. +% qq!', 'Are you sure you want to delete this payment?')"!. +% qq! TITLE="Delete this payment from the database completely - not recommended"!. +% qq!>delete</A>)!; +% } +% +% my $unapply = ''; +% if ( $cust_pay->closed !~ /^Y/i +% && scalar(@cust_bill_pay) +% && $curuser->access_right('Unapply payment') +% ) +% { +% $unapply = qq! (<A HREF="javascript:areyousure('!. +% qq!${p}misc/unapply-cust_pay.cgi?!. $cust_pay->paynum. +% qq!', 'Are you sure you want to unapply this payment?')"!. +% qq! TITLE="Keep this payment, but dissociate it from the invoices it is currently applied against"!. +% qq!>unapply</A>)!; +% } +% +% push @history, { +% 'date' => $cust_pay->_date, +% 'desc' => $pre. "Payment$post$info$desc". +% "$apply$refund$void$delete$unapply", +% 'payment' => $cust_pay->paid, +% 'target' => $target, +% }; +%} +% +%#voided payments +%foreach my $cust_pay_void ($cust_main->cust_pay_void) { +% +% my $payby = $cust_pay_void->payby; +% my $payinfo = $payby eq 'CARD' +% ? $cust_pay_void->payinfo_masked +% : $cust_pay_void->payinfo; +% +% $payby =~ s/^BILL$/Check #/ if $payinfo; +% $payby =~ s/^CHEK$/Electronic check /; +% $payby =~ s/^BILL$//; +% $payby =~ s/^(CARD|COMP)$/$1 /; +% my $info = $payby ? " ($payby$payinfo)" : ''; +% +% my $unvoid = ''; +% if ( $cust_pay_void->closed !~ /^Y/i +% && $curuser->access_right('Unvoid') +% ) +% { +% $unvoid = qq! (<A HREF="javascript:areyousure('!. +% qq!${p}misc/unvoid-cust_pay_void.cgi?!. $cust_pay_void->paynum. +% qq!', 'Are you sure you want to unvoid this payment?')"!. +% qq! TITLE="Unvoid this payment from the database!. +% ( $cust_pay_void->payby =~ /^(CARD|CHEK)$/ +% ? ' (do not send anything to the payment gateway)' +% : '' +% ). '"'. +% qq!>unvoid</A>)!; +% } +% +% push @history, { +% 'date' => $cust_pay_void->_date, +% 'desc' => "<DEL>Payment $info</DEL> <I>voided ". +% time2str("%D", $cust_pay_void->void_date). +% " by ". $cust_pay_void->otaker. '</i>'. $unvoid, +% 'void_payment' => $cust_pay_void->paid, +% }; +% +%} +% +%#credits (some false laziness w/payments) +%foreach my $cust_credit ($cust_main->cust_credit) { +% +% my @cust_credit_bill = $cust_credit->cust_credit_bill; +% my @cust_credit_refund = $cust_credit->cust_credit_refund; +% +% my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' ); +% if ( scalar(@cust_credit_bill) == 0 +% && scalar(@cust_credit_refund) == 0 ) { +% #completely unapplied +% $pre = '<B><FONT COLOR="#FF0000">Unapplied '; +% $post = '</FONT></B>'; +% $apply = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_credit_bill.cgi?!. +% $cust_credit->crednum. +% qq!', 392, 336, 'cust_credit_bill_popup' ), CAPTION, 'Apply credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!; +% } elsif ( scalar(@cust_credit_bill) == 1 +% && scalar(@cust_credit_refund) == 0 +% && $cust_credit->credited == 0 ) { +% #applied to one invoice, the usual situation +% $desc = ' applied to Invoice #'. $cust_credit_bill[0]->invnum; +% } elsif ( scalar(@cust_credit_bill) == 0 +% && scalar(@cust_credit_refund) == 1 +% && $cust_credit->credited == 0 ) { +% #applied to one refund +% $desc = ' refunded on '. time2str("%D", $cust_credit_refund[0]->_date); +% } else { +% #complicated +% $desc = '<BR>'; +% foreach my $app ( sort { $a->_date <=> $b->_date } +% ( @cust_credit_bill, @cust_credit_refund ) ) { +% if ( $app->isa('FS::cust_credit_bill') ) { +% $desc .= ' '. +% '$'. $app->amount. +% ' applied to Invoice #'. $app->invnum. +% '<BR>'; +% #' on '. time2str("%D", $app->_date). +% } elsif ( $app->isa('FS::cust_credit_refund') ) { +% $desc .= ' '. +% '$'. $app->amount. +% ' refunded on '. time2str("%D", $app->_date). +% '<BR>'; +% } else { +% die "$app is not a FS::cust_credit_bill or a FS::cust_credit_refund"; +% } +% } +% if ( $cust_credit->credited > 0 ) { +% $desc .= ' <B><FONT COLOR="#FF0000">$'. +% $cust_credit->credited. ' unapplied</FONT></B>'. +% qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_credit_bill.cgi?!. +% $cust_credit->crednum. +% qq!', 392, 336, 'cust_credit_bill_popup' ), CAPTION, 'Apply credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!. +% '<BR>'; +% } +% } +%# +% my $delete = ''; +% if ( $cust_credit->closed !~ /^Y/i +% +% #s'pose deleting a credit isn't bad like deleting a payment +% # and this needs to be generally available until we have credit voiding.. +% #&& $conf->exists('deletecredits') +% +% && $curuser->access_right('Delete credit') +% ) +% { +% $delete = qq! (<A HREF="javascript:areyousure('!. +% qq!${p}misc/delete-cust_credit.cgi?!. $cust_credit->crednum. +% qq!', 'Are you sure you want to delete this credit?')">!. +% qq!delete</A>)!; +% } +% +% my $unapply = ''; +% if ( $cust_credit->closed !~ /^Y/i +% && scalar(@cust_credit_bill) +% && $curuser->access_right('Unapply credit') +% ) +% { +% $unapply = qq! (<A HREF="javascript:areyousure('!. +% qq!${p}misc/unapply-cust_credit.cgi?!. $cust_credit->crednum. +% qq!', 'Are you sure you want to unapply this credit?')">!. +% qq!unapply</A>)!; +% } +% +% push @history, { +% 'date' => $cust_credit->_date, +% 'desc' => $pre. "Credit$post by ". $cust_credit->otaker. +% ( $cust_credit->reason +% ? ' ('. $cust_credit->reason. ')' +% : '' +% ). +% "$desc$apply$delete$unapply", +% 'credit' => $cust_credit->amount, +% }; +% +%} +% +%#refunds +%foreach my $cust_refund ($cust_main->cust_refund) { +% +% my $payby = $cust_refund->payby; +% my $payinfo = $payby eq 'CARD' +% ? $cust_refund->payinfo_masked +% : $cust_refund->payinfo; +% +% $payby =~ s/^BILL$/Check #/ if $payinfo; +% $payby =~ s/^CHEK$/Electronic check /; +% $payby =~ s/^(CARD|COMP)$/$1 /; +% +% push @history, { +% 'date' => $cust_refund->_date, +% 'desc' => "Refund ($payby$payinfo) by ". $cust_refund->otaker, +% 'refund' => $cust_refund->refund, +% }; +% +%} +% +% + + +<% include("/elements/table-grid.html") %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; +% -<% } %> - -<% -#get payment history -my @history = (); - -#invoices -foreach my $cust_bill ($cust_main->cust_bill) { - my $pre = ( $cust_bill->owed > 0 ) - ? '<B><FONT SIZE="+1" COLOR="#FF0000">Open ' - : ''; - my $post = ( $cust_bill->owed > 0 ) ? '</FONT></B>' : ''; - my $invnum = $cust_bill->invnum; - my $link = $curuser->access_right('View invoices') - ? qq!<A HREF="${p}view/cust_bill.cgi?$invnum">! - : ''; - push @history, { - 'date' => $cust_bill->_date, - 'desc' => $link. $pre. - "Invoice #$invnum (Balance \$". $cust_bill->owed. ')'. - $post. ( $link ? '</A>' : '' ), - 'charge' => $cust_bill->charged, - }; -} - -#payments (some false laziness w/credits) -foreach my $cust_pay ($cust_main->cust_pay) { - - my $payby = $cust_pay->payby; - - my $payinfo; - if ( $payby eq 'CARD' ) { - $payinfo = $cust_pay->payinfo_masked; - } elsif ( $payby eq 'CHEK' && $cust_pay->payinfo =~ /^(\d+)\@(\d+)$/ ) { - $payinfo = "ABA $2, Acct# $1"; - } else { - $payinfo = $cust_pay->payinfo; - } - my @cust_bill_pay = $cust_pay->cust_bill_pay; - my @cust_pay_refund = $cust_pay->cust_pay_refund; - - my $target = "$payby$payinfo"; - $payby =~ s/^BILL$/Check #/ if $payinfo; - $payby =~ s/^CHEK$/Electronic check /; - $payby =~ s/^PREP$/Prepaid card /; - $payby =~ s/^CARD$/Credit card #/; - $payby =~ s/^COMP$/Complimentary by /; - $payby =~ s/^CASH$/Cash/; - $payby =~ s/^WEST$/Western Union/; - $payby =~ s/^MCRD$/Manual credit card/; - $payby =~ s/^BILL$//; - my $info = $payby ? " ($payby$payinfo)" : ''; - - my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' ); - if ( scalar(@cust_bill_pay) == 0 - && scalar(@cust_pay_refund) == 0 ) { - #completely unapplied - $pre = '<B><FONT COLOR="#FF0000">Unapplied '; - $post = '</FONT></B>'; - $apply = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_bill_pay.cgi?!. - $cust_pay->paynum. - qq!', 392, 336, 'cust_bill_pay_popup' ), CAPTION, 'Apply payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!; - - } elsif ( scalar(@cust_bill_pay) == 1 - && scalar(@cust_pay_refund) == 0 - && $cust_pay->unapplied == 0 ) { - #applied to one invoice, the usual situation - $desc = ' applied to Invoice #'. $cust_bill_pay[0]->invnum; - } elsif ( scalar(@cust_bill_pay) == 0 - && scalar(@cust_pay_refund) == 1 - && $cust_pay->unapplied == 0 ) { - #applied to one refund - $desc = ' refunded on '. time2str("%D", $cust_pay_refund[0]->_date); - } else { - #complicated - $desc = '<BR>'; - foreach my $app ( sort { $a->_date <=> $b->_date } - ( @cust_bill_pay, @cust_pay_refund ) ) { - if ( $app->isa('FS::cust_bill_pay') ) { - $desc .= ' '. - '$'. $app->amount. - ' applied to Invoice #'. $app->invnum. - '<BR>'; - #' on '. time2str("%D", $cust_bill_pay->_date). - } elsif ( $app->isa('FS::cust_pay_refund') ) { - $desc .= ' '. - '$'. $app->amount. - ' refunded on '. time2str("%D", $app->_date). - '<BR>'; - } else { - die "$app is not a FS::cust_bill_pay or FS::cust_pay_refund"; - } - } - if ( $cust_pay->unapplied > 0 ) { - $desc .= ' '. - '<B><FONT COLOR="#FF0000">$'. - $cust_pay->unapplied. ' unapplied</FONT></B>'. - qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_bill_pay.cgi?!. - $cust_pay->paynum. - qq!', 392, 336, 'cust_bill_pay_popup' ), CAPTION, 'Apply payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!. - '<BR>'; - } - } - - my $refund = ''; - my $refund_days = $conf->config('card_refund-days') || 120; - if ( $cust_pay->closed !~ /^Y/i - && $cust_pay->payby =~ /^(CARD|CHEK)$/ - && time-$cust_pay->_date < $refund_days*86400 - && $cust_pay->unrefunded > 0 - && $curuser->access_right('Refund payment') - ) { - $refund = qq! (<A HREF="${p}edit/cust_refund.cgi?payby=$1;!. - qq!paynum=!. $cust_pay->paynum. '"'. - qq! TITLE="Send a refund for this payment to the payment gateway"!. - qq!>refund</A>)!; - } - - my $void = ''; - if ( $cust_pay->closed !~ /^Y/i - && ( ( $cust_pay->payby eq 'CARD' - && $curuser->access_right('Credit card void') - ) - || ( $cust_pay->payby eq 'CHEK' - && $curuser->access_right('Echeck void') - ) - || ( $cust_pay->payby !~ /^(CARD|CHEK)$/ - && $curuser->access_right('Regular void') - ) - ) - ) - { - $void = qq! (<A HREF="javascript:areyousure('!. - qq!${p}misc/void-cust_pay.cgi?!. $cust_pay->paynum. - qq!', 'Are you sure you want to void this payment?')"!. - qq! TITLE="Void this payment from the database!. - ( $cust_pay->payby =~ /^(CARD|CHEK)$/ - ? ' (do not send anything to the payment gateway)' - : '' - ). '"'. - qq!>void</A>)!; - } - - my $delete = ''; - if ( $cust_pay->closed !~ /^Y/i - && $conf->exists('deletepayments') - && $curuser->access_right('Delete payment') - ) - { - $delete = qq! (<A HREF="javascript:areyousure('!. - qq!${p}misc/delete-cust_pay.cgi?!. $cust_pay->paynum. - qq!', 'Are you sure you want to delete this payment?')"!. - qq! TITLE="Delete this payment from the database completely - not recommended"!. - qq!>delete</A>)!; - } - - my $unapply = ''; - if ( $cust_pay->closed !~ /^Y/i - && scalar(@cust_bill_pay) - && $curuser->access_right('Unapply payment') - ) - { - $unapply = qq! (<A HREF="javascript:areyousure('!. - qq!${p}misc/unapply-cust_pay.cgi?!. $cust_pay->paynum. - qq!', 'Are you sure you want to unapply this payment?')"!. - qq! TITLE="Keep this payment, but dissociate it from the invoices it is currently applied against"!. - qq!>unapply</A>)!; - } - - push @history, { - 'date' => $cust_pay->_date, - 'desc' => $pre. "Payment$post$info$desc". - "$apply$refund$void$delete$unapply", - 'payment' => $cust_pay->paid, - 'target' => $target, - }; -} - -#voided payments -foreach my $cust_pay_void ($cust_main->cust_pay_void) { - - my $payby = $cust_pay_void->payby; - my $payinfo = $payby eq 'CARD' - ? $cust_pay_void->payinfo_masked - : $cust_pay_void->payinfo; - - $payby =~ s/^BILL$/Check #/ if $payinfo; - $payby =~ s/^CHEK$/Electronic check /; - $payby =~ s/^BILL$//; - $payby =~ s/^(CARD|COMP)$/$1 /; - my $info = $payby ? " ($payby$payinfo)" : ''; - - my $unvoid = ''; - if ( $cust_pay_void->closed !~ /^Y/i - && $curuser->access_right('Unvoid') - ) - { - $unvoid = qq! (<A HREF="javascript:areyousure('!. - qq!${p}misc/unvoid-cust_pay_void.cgi?!. $cust_pay_void->paynum. - qq!', 'Are you sure you want to unvoid this payment?')"!. - qq! TITLE="Unvoid this payment from the database!. - ( $cust_pay_void->payby =~ /^(CARD|CHEK)$/ - ? ' (do not send anything to the payment gateway)' - : '' - ). '"'. - qq!>unvoid</A>)!; - } - - push @history, { - 'date' => $cust_pay_void->_date, - 'desc' => "<DEL>Payment $info</DEL> <I>voided ". - time2str("%D", $cust_pay_void->void_date). - " by ". $cust_pay_void->otaker. '</i>'. $unvoid, - 'void_payment' => $cust_pay_void->paid, - }; - -} - -#credits (some false laziness w/payments) -foreach my $cust_credit ($cust_main->cust_credit) { - - my @cust_credit_bill = $cust_credit->cust_credit_bill; - my @cust_credit_refund = $cust_credit->cust_credit_refund; - - my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' ); - if ( scalar(@cust_credit_bill) == 0 - && scalar(@cust_credit_refund) == 0 ) { - #completely unapplied - $pre = '<B><FONT COLOR="#FF0000">Unapplied '; - $post = '</FONT></B>'; - $apply = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_credit_bill.cgi?!. - $cust_credit->crednum. - qq!', 392, 336, 'cust_credit_bill_popup' ), CAPTION, 'Apply credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!; - } elsif ( scalar(@cust_credit_bill) == 1 - && scalar(@cust_credit_refund) == 0 - && $cust_credit->credited == 0 ) { - #applied to one invoice, the usual situation - $desc = ' applied to Invoice #'. $cust_credit_bill[0]->invnum; - } elsif ( scalar(@cust_credit_bill) == 0 - && scalar(@cust_credit_refund) == 1 - && $cust_credit->credited == 0 ) { - #applied to one refund - $desc = ' refunded on '. time2str("%D", $cust_credit_refund[0]->_date); - } else { - #complicated - $desc = '<BR>'; - foreach my $app ( sort { $a->_date <=> $b->_date } - ( @cust_credit_bill, @cust_credit_refund ) ) { - if ( $app->isa('FS::cust_credit_bill') ) { - $desc .= ' '. - '$'. $app->amount. - ' applied to Invoice #'. $app->invnum. - '<BR>'; - #' on '. time2str("%D", $app->_date). - } elsif ( $app->isa('FS::cust_credit_refund') ) { - $desc .= ' '. - '$'. $app->amount. - ' refunded on '. time2str("%D", $app->_date). - '<BR>'; - } else { - die "$app is not a FS::cust_credit_bill or a FS::cust_credit_refund"; - } - } - if ( $cust_credit->credited > 0 ) { - $desc .= ' <B><FONT COLOR="#FF0000">$'. - $cust_credit->credited. ' unapplied</FONT></B>'. - qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_credit_bill.cgi?!. - $cust_credit->crednum. - qq!', 392, 336, 'cust_credit_bill_popup' ), CAPTION, 'Apply credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!. - '<BR>'; - } - } -# - my $delete = ''; - if ( $cust_credit->closed !~ /^Y/i - - #s'pose deleting a credit isn't bad like deleting a payment - # and this needs to be generally available until we have credit voiding.. - #&& $conf->exists('deletecredits') - - && $curuser->access_right('Delete credit') - ) - { - $delete = qq! (<A HREF="javascript:areyousure('!. - qq!${p}misc/delete-cust_credit.cgi?!. $cust_credit->crednum. - qq!', 'Are you sure you want to delete this credit?')">!. - qq!delete</A>)!; - } - - my $unapply = ''; - if ( $cust_credit->closed !~ /^Y/i - && scalar(@cust_credit_bill) - && $curuser->access_right('Unapply credit') - ) - { - $unapply = qq! (<A HREF="javascript:areyousure('!. - qq!${p}misc/unapply-cust_credit.cgi?!. $cust_credit->crednum. - qq!', 'Are you sure you want to unapply this credit?')">!. - qq!unapply</A>)!; - } - - push @history, { - 'date' => $cust_credit->_date, - 'desc' => $pre. "Credit$post by ". $cust_credit->otaker. - ( $cust_credit->reason - ? ' ('. $cust_credit->reason. ')' - : '' - ). - "$desc$apply$delete$unapply", - 'credit' => $cust_credit->amount, - }; - -} - -#refunds -foreach my $cust_refund ($cust_main->cust_refund) { - - my $payby = $cust_refund->payby; - my $payinfo = $payby eq 'CARD' - ? $cust_refund->payinfo_masked - : $cust_refund->payinfo; - - $payby =~ s/^BILL$/Check #/ if $payinfo; - $payby =~ s/^CHEK$/Electronic check /; - $payby =~ s/^(CARD|COMP)$/$1 /; - - push @history, { - 'date' => $cust_refund->_date, - 'desc' => "Refund ($payby$payinfo) by ". $cust_refund->otaker, - 'refund' => $cust_refund->refund, - }; - -} - -%> - -<%= include("/elements/table-grid.html") %> - -<% my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor = ''; -%> <TR> <TH CLASS="grid" BGCOLOR="#cccccc">Date</TH> @@ -426,41 +421,41 @@ foreach my $cust_refund ($cust_main->cust_refund) { <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Refund</FONT></TH> <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Balance</FONT></TH> </TR> +% +%#display payment history +% +%my $balance = 0; +%my %target = (); +%my $money_char = $conf->config('money_char') || '$'; +% +%my $years = $conf->config('payment_history-years') || 2; +%my $older_than = time - $years * 31556736; #60*60*24*365.24 +%my $hidden = 0; +%my $seen = 0; +%my $old_history = 0; +% +%foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { +% +% my $display; +% if ( $item->{'date'} < $older_than ) { +% $display = ' STYLE="display:none" '; +% $hidden = 1; +% } else { +% +% $display = ''; +% +% if ( $hidden && ! $seen++ ) { +% ( my $balance_forward = $money_char. $balance ) =~ s/^\$\-/- \$/; +% -<% -#display payment history - -my $balance = 0; -my %target = (); -my $money_char = $conf->config('money_char') || '$'; - -my $years = $conf->config('payment_history-years') || 2; -my $older_than = time - $years * 31556736; #60*60*24*365.24 -my $hidden = 0; -my $seen = 0; -my $old_history = 0; - -foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { - - my $display; - if ( $item->{'date'} < $older_than ) { - $display = ' STYLE="display:none" '; - $hidden = 1; - } else { - - $display = ''; - - if ( $hidden && ! $seen++ ) { - ( my $balance_forward = $money_char. $balance ) =~ s/^\$\-/- \$/; - %> <TR ID="balance_forward_row"> <TD CLASS="grid" BGCOLOR="#dddddd"> - <%= time2str("%D",$item->{'date'}) %> + <% time2str("%D",$item->{'date'}) %> </TD> <TD CLASS="grid" BGCOLOR="#dddddd"> - <I>Starting balance on <%= time2str("%D",$item->{'date'}) %></I> + <I>Starting balance on <% time2str("%D",$item->{'date'}) %></I> (<A HREF="javascript:void(0);" onClick="show_history();">show prior history</A>) </TD> @@ -468,86 +463,90 @@ foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { <TD CLASS="grid" BGCOLOR="#dddddd"></TD> <TD CLASS="grid" BGCOLOR="#dddddd"></TD> <TD CLASS="grid" BGCOLOR="#dddddd"></TD> - <TD CLASS="grid" BGCOLOR="#dddddd"><I><%= $balance_forward %></I></TD> + <TD CLASS="grid" BGCOLOR="#dddddd"><I><% $balance_forward %></I></TD> </TR> +% +% } +% +% } +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% my $charge = exists($item->{'charge'}) +% ? sprintf("$money_char\%.2f", $item->{'charge'}) +% : ''; +% +% my $payment = exists($item->{'payment'}) +% ? sprintf("- $money_char\%.2f", $item->{'payment'}) +% : ''; +% +% $payment ||= sprintf( "<DEL>- $money_char\%.2f</DEL>", +% $item->{'void_payment'} +% ) +% if exists($item->{'void_payment'}); +% +% my $credit = exists($item->{'credit'}) +% ? sprintf("- $money_char\%.2f", $item->{'credit'}) +% : ''; +% +% my $refund = exists($item->{'refund'}) +% ? sprintf("$money_char\%.2f", $item->{'refund'}) +% : ''; +% +% my $target = exists($item->{'target'}) ? $item->{'target'} : ''; +% +% $balance += $item->{'charge'} if exists $item->{'charge'}; +% $balance -= $item->{'payment'} if exists $item->{'payment'}; +% $balance -= $item->{'credit'} if exists $item->{'credit'}; +% $balance += $item->{'refund'} if exists $item->{'refund'}; +% $balance = sprintf("%.2f", $balance); +% $balance =~ s/^\-0\.00$/0.00/; #yay ieee fp +% ( my $showbalance = $money_char. $balance ) =~ s/^\$\-/- \$/; +% +% + + + <TR <% $display ? $display.' ID="old_history'.$old_history++.'"' : ''%>> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> +% unless ( !$target || $target{$target}++ ) { + + <A NAME="<% $target %>"> +% } + + <% time2str("%D",$item->{'date'}) %> +% if ( $target && $target{$target} == 1 ) { - <% - } - - } - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - - my $charge = exists($item->{'charge'}) - ? sprintf("$money_char\%.2f", $item->{'charge'}) - : ''; - - my $payment = exists($item->{'payment'}) - ? sprintf("- $money_char\%.2f", $item->{'payment'}) - : ''; - - $payment ||= sprintf( "<DEL>- $money_char\%.2f</DEL>", - $item->{'void_payment'} - ) - if exists($item->{'void_payment'}); - - my $credit = exists($item->{'credit'}) - ? sprintf("- $money_char\%.2f", $item->{'credit'}) - : ''; - - my $refund = exists($item->{'refund'}) - ? sprintf("$money_char\%.2f", $item->{'refund'}) - : ''; - - my $target = exists($item->{'target'}) ? $item->{'target'} : ''; - - $balance += $item->{'charge'} if exists $item->{'charge'}; - $balance -= $item->{'payment'} if exists $item->{'payment'}; - $balance -= $item->{'credit'} if exists $item->{'credit'}; - $balance += $item->{'refund'} if exists $item->{'refund'}; - $balance = sprintf("%.2f", $balance); - $balance =~ s/^\-0\.00$/0.00/; #yay ieee fp - ( my $showbalance = $money_char. $balance ) =~ s/^\$\-/- \$/; - -%> - - <TR <%= $display ? $display.' ID="old_history'.$old_history++.'"' : ''%>> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <% unless ( !$target || $target{$target}++ ) { %> - <A NAME="<%= $target %>"> - <% } %> - <%= time2str("%D",$item->{'date'}) %> - <% if ( $target && $target{$target} == 1 ) { %> </A> - <% } %> +% } + </FONT> </TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <%= $item->{'desc'} %> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $item->{'desc'} %> </TD> - <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <%= $charge %> + <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $charge %> </TD> - <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <%= $payment %> + <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $payment %> </TD> - <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <%= $credit %> + <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $credit %> </TD> - <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <%= $refund %> + <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $refund %> </TD> - <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>"> - <%= $showbalance %> + <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $showbalance %> </TD> </TR> +% } -<% } %> </TABLE> @@ -559,7 +558,7 @@ function show_history () { var balance_forward_row = document.getElementById('balance_forward_row'); balance_forward_row.style.display = 'none'; - for ( var i = 0; i < <%= $old_history %>; i++ ) { + for ( var i = 0; i < <% $old_history %>; i++ ) { var oldRow = document.getElementById('old_history'+i); oldRow.style.display = ''; } diff --git a/httemplate/view/cust_main/quick-charge.html b/httemplate/view/cust_main/quick-charge.html index 2fe3d5f3d..be8b9d838 100644 --- a/httemplate/view/cust_main/quick-charge.html +++ b/httemplate/view/cust_main/quick-charge.html @@ -1,16 +1,17 @@ -<% - my( $cust_main ) = @_; -%> +% +% my( $cust_main ) = @_; +% -<FORM ACTION="<%=$p%>edit/process/quick-charge.cgi" METHOD="POST"> -<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $cust_main->custnum %>"> +<FORM ACTION="<%$p%>edit/process/quick-charge.cgi" METHOD="POST"> + +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>"> Description:<INPUT TYPE="text" NAME="pkg"> Amount:<INPUT TYPE="text" NAME="amount" SIZE=6> -<%= include('/elements/select-taxclass.html') %> +<% include('/elements/select-taxclass.html') %> <INPUT TYPE="submit" VALUE="One-time charge"> diff --git a/httemplate/view/cust_main/tickets.html b/httemplate/view/cust_main/tickets.html index 93cb51f25..65cdcbfa7 100644 --- a/httemplate/view/cust_main/tickets.html +++ b/httemplate/view/cust_main/tickets.html @@ -1,43 +1,44 @@ -<% - my( $cust_main ) = @_; +% +% my( $cust_main ) = @_; +% +% my $conf = new FS::Conf; +% my $num = $conf->config('cust_main-max_tickets') || 10; +% +% my @tickets = (); +% unless ( $conf->config('ticket_system-custom_priority_field') ) { +% +% @tickets = +% @{ FS::TicketSystem->customer_tickets($cust_main->custnum, $num) }; +% +% } else { +% +% foreach my $priority ( +% $conf->config('ticket_system-custom_priority_field-values'), '' +% ) { +% last if scalar(@tickets) >= $num; +% push @tickets, +% @{ FS::TicketSystem->customer_tickets( $cust_main->custnum, +% $num - scalar(@tickets), +% $priority, +% ) +% }; +% } +% +% } +% +% - my $conf = new FS::Conf; - my $num = $conf->config('cust_main-max_tickets') || 10; - - my @tickets = (); - unless ( $conf->config('ticket_system-custom_priority_field') ) { - - @tickets = - @{ FS::TicketSystem->customer_tickets($cust_main->custnum, $num) }; - - } else { - - foreach my $priority ( - $conf->config('ticket_system-custom_priority_field-values'), '' - ) { - last if scalar(@tickets) >= $num; - push @tickets, - @{ FS::TicketSystem->customer_tickets( $cust_main->custnum, - $num - scalar(@tickets), - $priority, - ) - }; - } - - } - -%> Highest priority tickets -(<A HREF="<%= FS::TicketSystem->href_customer_tickets($cust_main->custnum) %>">View all tickets for this customer</A>) -(<A HREF="<%= FS::TicketSystem->href_new_ticket($cust_main, join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) ) %>">New ticket for this customer</A>) +(<A HREF="<% FS::TicketSystem->href_customer_tickets($cust_main->custnum) %>">View all tickets for this customer</A>) +(<A HREF="<% FS::TicketSystem->href_new_ticket($cust_main, join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) ) %>">New ticket for this customer</A>) -<%= include("/elements/table-grid.html") %> +<% include("/elements/table-grid.html") %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; +% -<% my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor = ''; -%> <TR> <TH CLASS="grid" BGCOLOR="#cccccc">#</TH> @@ -46,31 +47,31 @@ Highest priority tickets <TH CLASS="grid" BGCOLOR="#cccccc">Queue</TH> <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH> </TR> +% foreach my $ticket ( @tickets ) { +% my $href = FS::TicketSystem->href_ticket($ticket->{id}); +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% -<% foreach my $ticket ( @tickets ) { - my $href = FS::TicketSystem->href_ticket($ticket->{id}); - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } -%> <TR> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF=<%=$href%>><%= $ticket->{id} %></A></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF=<%$href%>><% $ticket->{id} %></A></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF=<%=$href%>><%= $ticket->{subject} %></A></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF=<%$href%>><% $ticket->{subject} %></A></TD> - <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $ticket->{content} || $ticket->{priority} %></TD> + <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $ticket->{content} || $ticket->{priority} %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $ticket->{name} %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $ticket->{name} %></TD> - <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $ticket->{status} %></TD> + <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $ticket->{status} %></TD> </TR> +% } -<% } %> </TABLE> diff --git a/httemplate/view/cust_pkg.cgi b/httemplate/view/cust_pkg.cgi index a20149ae2..78b42f127 100755 --- a/httemplate/view/cust_pkg.cgi +++ b/httemplate/view/cust_pkg.cgi @@ -1,165 +1,166 @@ <!-- mason kludge --> -<% +% +% +%my $conf = new FS::Conf; +% +%my %uiview = (); +%my %uiadd = (); +%foreach my $part_svc ( qsearch('part_svc',{}) ) { +% $uiview{$part_svc->svcpart} = popurl(2). "view/". $part_svc->svcdb . ".cgi"; +% $uiadd{$part_svc->svcpart}= popurl(2). "edit/". $part_svc->svcdb . ".cgi"; +%} +% +%my ($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $pkgnum = $1; +% +%#get package record +%my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +%die "No package!" unless $cust_pkg; +%my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')}); +% +%my $custnum = $cust_pkg->getfield('custnum'); +%print header('Package View', menubar( +% "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum", +% 'Main Menu' => popurl(2) +%)); +% +%#print info +%my ($susp,$cancel,$expire)=( +% $cust_pkg->getfield('susp'), +% $cust_pkg->getfield('cancel'), +% $cust_pkg->getfield('expire'), +%); +%my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment')); +%my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill')); +%my $otaker = $cust_pkg->getfield('otaker'); +% +%print <<END; +%<SCRIPT> +%function areyousure(href) { +% if (confirm("Permanently delete included services and cancel this package?") == true) +% window.location.href = href; +%} +%</SCRIPT> +%END +% +%print "Package information"; +%print ' (<A HREF="'. popurl(2). 'misc/unsusp_pkg.cgi?'. $pkgnum. +% '">unsuspend</A>)' +% if ( $susp && ! $cancel ); +% +%print ' (<A HREF="'. popurl(2). 'misc/susp_pkg.cgi?'. $pkgnum. +% '">suspend</A>)' +% unless ( $susp || $cancel ); +% +%print ' (<A HREF="javascript:areyousure(\''. popurl(2). 'misc/cancel_pkg.cgi?'. +% $pkgnum. '\')">cancel</A>)' +% unless $cancel; +% +%print ' (<A HREF="'. popurl(2). 'edit/REAL_cust_pkg.cgi?'. $pkgnum. +% '">edit dates</A>)'; +% +%print &ntable("#cccccc"), '<TR><TD>', &ntable("#cccccc",2), +% '<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">', +% $pkgnum, '</TD></TR>', +% '<TR><TD ALIGN="right">Package</TD><TD BGCOLOR="#ffffff">', +% $pkg, '</TD></TR>', +% '<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">', +% $comment, '</TD></TR>', +% '<TR><TD ALIGN="right">Setup date</TD><TD BGCOLOR="#ffffff">', +% ( $setup ? time2str("%D",$setup) : "(Not setup)" ), '</TD></TR>'; +% +%print '<TR><TD ALIGN="right">Last bill date</TD><TD BGCOLOR="#ffffff">', +% ( $cust_pkg->get('last_bill') ? time2str("%D",$cust_pkg->get('last_bill')) : " " ), +% '</TD></TR>' +% if $cust_pkg->dbdef_table->column('last_bill'); +% +%print '<TR><TD ALIGN="right">Next bill date</TD><TD BGCOLOR="#ffffff">', +% ( $bill ? time2str("%D",$bill) : " " ), '</TD></TR>'; +% +%print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">', +% time2str("%D",$susp), '</TD></TR>' if $susp; +%print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">', +% time2str("%D",$expire), '</TD></TR>' if $expire; +%print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">', +% time2str("%D",$cancel), '</TD></TR>' if $cancel; +%print '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">', +% $otaker, '</TD></TR>', +% '</TABLE></TD></TR></TABLE>'; +% +%unless ($expire) { +% print <<END; +%<FORM ACTION="../misc/expire_pkg.cgi" METHOD="post"> +%<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum"> +%Expire (date): <INPUT TYPE="text" NAME="date" VALUE="" > +%<INPUT TYPE="submit" VALUE="Cancel later"> +%END +%} +% +%unless ($cancel) { +% +% #services +% print '<BR>Service Information', &table(); +% +% #list of services this pkgpart includes +% my $pkg_svc; +% my %pkg_svc; +% #foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $cust_pkg->pkgpart }) ) { +% foreach $pkg_svc ( $cust_pkg->part_pkg->pkg_svc ) { +% $pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity; +% } +% +% #list of records from cust_svc +% my $svcpart; +% foreach $svcpart (sort {$a <=> $b} keys %pkg_svc) { +% +% my($svc)=qsearchs('part_svc',{'svcpart'=>$svcpart})->getfield('svc'); +% +% my(@cust_svc)=qsearch('cust_svc',{'pkgnum'=>$pkgnum, +% 'svcpart'=>$svcpart, +% }); +% +% my($enum); +% for $enum ( 1 .. $pkg_svc{$svcpart} ) { +% +% my($cust_svc); +% if ( $cust_svc=shift @cust_svc ) { +% my($svcnum)=$cust_svc->svcnum; +% my($label, $value, $svcdb) = $cust_svc->label; +% print <<END; +%<TR><TD><A HREF="$uiview{$svcpart}?$svcnum">(View/Edit) $svc: $value<A></TD></TR> +%END +% } else { +% print qq!<TR><TD>!. +% qq!<A HREF="$uiadd{$svcpart}?pkgnum$pkgnum-svcpart$svcpart">!. +% qq!(Provision) $svc</A>!; +% +% print qq! or <A HREF="../misc/link.cgi?pkgnum$pkgnum-svcpart$svcpart">!. +% qq!(Link to legacy) $svc</A>! +% if $conf->exists('legacy_link'); +% +% print '</TD></TR>'; +% } +% +% } +% warn "WARNING: Leftover services pkgnum $pkgnum!" if @cust_svc;; +% } +% +% print "</TABLE><FONT SIZE=-1>", +% "Choose (View/Edit) to view or edit an existing service<BR>", +% "Choose (Provision) to setup a new service<BR>"; +% +% print "Choose (Link to legacy) to link to a legacy (pre-Freeside) service" +% if $conf->exists('legacy_link'); +% +% print "</FONT>"; +%} +% +%#formatting +%print <<END; +% </BODY> +%</HTML> +%END +% +% -my $conf = new FS::Conf; - -my %uiview = (); -my %uiadd = (); -foreach my $part_svc ( qsearch('part_svc',{}) ) { - $uiview{$part_svc->svcpart} = popurl(2). "view/". $part_svc->svcdb . ".cgi"; - $uiadd{$part_svc->svcpart}= popurl(2). "edit/". $part_svc->svcdb . ".cgi"; -} - -my ($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $pkgnum = $1; - -#get package record -my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); -die "No package!" unless $cust_pkg; -my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')}); - -my $custnum = $cust_pkg->getfield('custnum'); -print header('Package View', menubar( - "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum", - 'Main Menu' => popurl(2) -)); - -#print info -my ($susp,$cancel,$expire)=( - $cust_pkg->getfield('susp'), - $cust_pkg->getfield('cancel'), - $cust_pkg->getfield('expire'), -); -my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment')); -my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill')); -my $otaker = $cust_pkg->getfield('otaker'); - -print <<END; -<SCRIPT> -function areyousure(href) { - if (confirm("Permanently delete included services and cancel this package?") == true) - window.location.href = href; -} -</SCRIPT> -END - -print "Package information"; -print ' (<A HREF="'. popurl(2). 'misc/unsusp_pkg.cgi?'. $pkgnum. - '">unsuspend</A>)' - if ( $susp && ! $cancel ); - -print ' (<A HREF="'. popurl(2). 'misc/susp_pkg.cgi?'. $pkgnum. - '">suspend</A>)' - unless ( $susp || $cancel ); - -print ' (<A HREF="javascript:areyousure(\''. popurl(2). 'misc/cancel_pkg.cgi?'. - $pkgnum. '\')">cancel</A>)' - unless $cancel; - -print ' (<A HREF="'. popurl(2). 'edit/REAL_cust_pkg.cgi?'. $pkgnum. - '">edit dates</A>)'; - -print &ntable("#cccccc"), '<TR><TD>', &ntable("#cccccc",2), - '<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">', - $pkgnum, '</TD></TR>', - '<TR><TD ALIGN="right">Package</TD><TD BGCOLOR="#ffffff">', - $pkg, '</TD></TR>', - '<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">', - $comment, '</TD></TR>', - '<TR><TD ALIGN="right">Setup date</TD><TD BGCOLOR="#ffffff">', - ( $setup ? time2str("%D",$setup) : "(Not setup)" ), '</TD></TR>'; - -print '<TR><TD ALIGN="right">Last bill date</TD><TD BGCOLOR="#ffffff">', - ( $cust_pkg->get('last_bill') ? time2str("%D",$cust_pkg->get('last_bill')) : " " ), - '</TD></TR>' - if $cust_pkg->dbdef_table->column('last_bill'); - -print '<TR><TD ALIGN="right">Next bill date</TD><TD BGCOLOR="#ffffff">', - ( $bill ? time2str("%D",$bill) : " " ), '</TD></TR>'; - -print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">', - time2str("%D",$susp), '</TD></TR>' if $susp; -print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">', - time2str("%D",$expire), '</TD></TR>' if $expire; -print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">', - time2str("%D",$cancel), '</TD></TR>' if $cancel; -print '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">', - $otaker, '</TD></TR>', - '</TABLE></TD></TR></TABLE>'; - -unless ($expire) { - print <<END; -<FORM ACTION="../misc/expire_pkg.cgi" METHOD="post"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum"> -Expire (date): <INPUT TYPE="text" NAME="date" VALUE="" > -<INPUT TYPE="submit" VALUE="Cancel later"> -END -} - -unless ($cancel) { - - #services - print '<BR>Service Information', &table(); - - #list of services this pkgpart includes - my $pkg_svc; - my %pkg_svc; - #foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $cust_pkg->pkgpart }) ) { - foreach $pkg_svc ( $cust_pkg->part_pkg->pkg_svc ) { - $pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity; - } - - #list of records from cust_svc - my $svcpart; - foreach $svcpart (sort {$a <=> $b} keys %pkg_svc) { - - my($svc)=qsearchs('part_svc',{'svcpart'=>$svcpart})->getfield('svc'); - - my(@cust_svc)=qsearch('cust_svc',{'pkgnum'=>$pkgnum, - 'svcpart'=>$svcpart, - }); - - my($enum); - for $enum ( 1 .. $pkg_svc{$svcpart} ) { - - my($cust_svc); - if ( $cust_svc=shift @cust_svc ) { - my($svcnum)=$cust_svc->svcnum; - my($label, $value, $svcdb) = $cust_svc->label; - print <<END; -<TR><TD><A HREF="$uiview{$svcpart}?$svcnum">(View/Edit) $svc: $value<A></TD></TR> -END - } else { - print qq!<TR><TD>!. - qq!<A HREF="$uiadd{$svcpart}?pkgnum$pkgnum-svcpart$svcpart">!. - qq!(Provision) $svc</A>!; - - print qq! or <A HREF="../misc/link.cgi?pkgnum$pkgnum-svcpart$svcpart">!. - qq!(Link to legacy) $svc</A>! - if $conf->exists('legacy_link'); - - print '</TD></TR>'; - } - - } - warn "WARNING: Leftover services pkgnum $pkgnum!" if @cust_svc;; - } - - print "</TABLE><FONT SIZE=-1>", - "Choose (View/Edit) to view or edit an existing service<BR>", - "Choose (Provision) to setup a new service<BR>"; - - print "Choose (Link to legacy) to link to a legacy (pre-Freeside) service" - if $conf->exists('legacy_link'); - - print "</FONT>"; -} - -#formatting -print <<END; - </BODY> -</HTML> -END - -%> diff --git a/httemplate/view/elements/svc_Common.html b/httemplate/view/elements/svc_Common.html index 0f103e3e0..35434632e 100644 --- a/httemplate/view/elements/svc_Common.html +++ b/httemplate/view/elements/svc_Common.html @@ -1,116 +1,116 @@ -<% - - # options example... - # - # 'table' => 'svc_something' - # - # 'labels' => { - # 'column' => 'Label', - # }, - # - # listref - each item is a literal column name (or method) or (notyet) coderef - # if not specified all columns (except for the primary key) will be viewable - # 'fields' => [ - # ] - - my(%opt) = @_; - - my $table = $opt{'table'}; - - my $fields = $opt{'fields'} - #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ]; - || [ grep { $_ ne 'svcnum' } fields($table) ]; - - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - my $svcnum = $1; - my $svc_x = qsearchs( $opt{'table'}, { 'svcnum' => $svcnum } ) - or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n"; - - my $cust_svc = $svc_x->cust_svc; - my($label, $value, $svcdb) = $cust_svc->label; - - my $pkgnum = $cust_svc->pkgnum; - - my($cust_pkg, $custnum); - if ($pkgnum) { - $cust_pkg = $cust_svc->cust_pkg; - $custnum = $cust_pkg->custnum; - } else { - $cust_pkg = ''; - $custnum = ''; - } - -%> - -<% if ( $custnum ) { %> - - <%= include("/elements/header.html","View $label: $value", menubar( +% +% +% # options example... +% # +% # 'table' => 'svc_something' +% # +% # 'labels' => { +% # 'column' => 'Label', +% # }, +% # +% # listref - each item is a literal column name (or method) or (notyet) coderef +% # if not specified all columns (except for the primary key) will be viewable +% # 'fields' => [ +% # ] +% +% my(%opt) = @_; +% +% my $table = $opt{'table'}; +% +% my $fields = $opt{'fields'} +% #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ]; +% || [ grep { $_ ne 'svcnum' } fields($table) ]; +% +% my($query) = $cgi->keywords; +% $query =~ /^(\d+)$/; +% my $svcnum = $1; +% my $svc_x = qsearchs( $opt{'table'}, { 'svcnum' => $svcnum } ) +% or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n"; +% +% my $cust_svc = $svc_x->cust_svc; +% my($label, $value, $svcdb) = $cust_svc->label; +% +% my $pkgnum = $cust_svc->pkgnum; +% +% my($cust_pkg, $custnum); +% if ($pkgnum) { +% $cust_pkg = $cust_svc->cust_pkg; +% $custnum = $cust_pkg->custnum; +% } else { +% $cust_pkg = ''; +% $custnum = ''; +% } +% +% +% if ( $custnum ) { + + + <% include("/elements/header.html","View $label: $value", menubar( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", )) %> - <%= include( '/elements/small_custview.html', $custnum, '', 1 ) %> + <% include( '/elements/small_custview.html', $custnum, '', 1 ) %> <BR> +% } else { -<% } else { %> <SCRIPT> function areyousure(href) { - if (confirm("Permanently delete this <%= $label %>?") == true) + if (confirm("Permanently delete this <% $label %>?") == true) window.location.href = href; } </SCRIPT> - <%= include("/elements/header.html","View $label: $value", menubar( + <% include("/elements/header.html","View $label: $value", menubar( "Cancel this (unaudited) $label" => "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')" )) %> +% } -<% } %> -Service #<B><%= $svcnum %></B> -| <A HREF="<%=$p%>edit/<%= $opt{'table'} %>.cgi?<%=$svcnum%>">Edit this <%= $label %></A> +Service #<B><% $svcnum %></B> +| <A HREF="<%$p%>edit/<% $opt{'table'} %>.cgi?<%$svcnum%>">Edit this <% $label %></A> <BR> -<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %> - -<% foreach my $f ( @$fields ) { +<% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %> +% foreach my $f ( @$fields ) { +% +% my( $field, $type); +% if ( ref($f) ) { +% $field = $f->{'field'}, +% $type = $f->{'type'} || 'text', +% } else { +% $field = $f; +% $type = 'text'; +% } +% - my( $field, $type); - if ( ref($f) ) { - $field = $f->{'field'}, - $type = $f->{'type'} || 'text', - } else { - $field = $f; - $type = 'text'; - } -%> <TR> <TD ALIGN="right"> - <%= ( $opt{labels} && exists $opt{labels}->{$field} ) + <% ( $opt{labels} && exists $opt{labels}->{$field} ) ? $opt{labels}->{$field} : $field %> </TD> +% +% #eventually more options for <SELECT>, etc. fields +% - <% - #eventually more options for <SELECT>, etc. fields - %> - <TD BGCOLOR="#ffffff"><%= $svc_x->$field %><TD> + <TD BGCOLOR="#ffffff"><% $svc_x->$field %><TD> </TR> +% } +% foreach (sort { $a cmp $b } $svc_x->virtual_fields) { -<% } %> + <% $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %> +% } -<% foreach (sort { $a cmp $b } $svc_x->virtual_fields) { %> - <%= $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %> -<% } %> </TABLE></TD></TR></TABLE> <BR> -<%= joblisting({'svcnum'=>$svcnum}, 1) %> +<% joblisting({'svcnum'=>$svcnum}, 1) %> -<%= include('/elements/footer.html') %> +<% include('/elements/footer.html') %> diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index f4f39084c..9c2fbc94d 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -1,51 +1,51 @@ -<% - -my $conf = new FS::Conf; - -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; -my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); -die "Unknown svcnum" unless $svc_acct; - -#false laziness w/all svc_*.cgi -my $cust_svc = qsearchs( 'cust_svc' , { 'svcnum' => $svcnum } ); -my $pkgnum = $cust_svc->getfield('pkgnum'); -my($cust_pkg, $custnum); -if ($pkgnum) { - $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); - $custnum = $cust_pkg->custnum; -} else { - $cust_pkg = ''; - $custnum = ''; -} -#eofalse - -my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ); -die "Unknown svcpart" unless $part_svc; -my $svc = $part_svc->svc; - -die 'Empty domsvc for svc_acct.svcnum '. $svc_acct->svcnum - unless $svc_acct->domsvc; -my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } ); -die 'Unknown domain (domsvc '. $svc_acct->domsvc. - ' for svc_acct.svcnum '. $svc_acct->svcnum. ')' - unless $svc_domain; -my $domain = $svc_domain->domain; - -%> - -<% if ( $custnum ) { %> - - <%= include("/elements/header.html","View $svc account", menubar( +% +% +%my $conf = new FS::Conf; +% +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +%my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); +%die "Unknown svcnum" unless $svc_acct; +% +%#false laziness w/all svc_*.cgi +%my $cust_svc = qsearchs( 'cust_svc' , { 'svcnum' => $svcnum } ); +%my $pkgnum = $cust_svc->getfield('pkgnum'); +%my($cust_pkg, $custnum); +%if ($pkgnum) { +% $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); +% $custnum = $cust_pkg->custnum; +%} else { +% $cust_pkg = ''; +% $custnum = ''; +%} +%#eofalse +% +%my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ); +%die "Unknown svcpart" unless $part_svc; +%my $svc = $part_svc->svc; +% +%die 'Empty domsvc for svc_acct.svcnum '. $svc_acct->svcnum +% unless $svc_acct->domsvc; +%my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } ); +%die 'Unknown domain (domsvc '. $svc_acct->domsvc. +% ' for svc_acct.svcnum '. $svc_acct->svcnum. ')' +% unless $svc_domain; +%my $domain = $svc_domain->domain; +% +% +% if ( $custnum ) { + + + <% include("/elements/header.html","View $svc account", menubar( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", "Main menu" => $p, )) %> - <%= include( '/elements/small_custview.html', $custnum, '', 1 ) %> + <% include( '/elements/small_custview.html', $custnum, '', 1 ) %> <BR> +% } else { -<% } else { %> <SCRIPT> function areyousure(href) { @@ -54,76 +54,80 @@ my $domain = $svc_domain->domain; } </SCRIPT> - <%= include("/elements/header.html",'Account View', menubar( + <% include("/elements/header.html",'Account View', menubar( "Cancel this (unaudited) account" => "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')", "Main menu" => $p, )) %> +% } +% if ( $part_svc->part_export_usage ) { +% +% my $last_bill; +% my %plandata; +% if ( $cust_pkg ) { +% #false laziness w/httemplate/edit/part_pkg... this stuff doesn't really +% #belong in plan data +% %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } +% split("\n", $cust_pkg->part_pkg->plandata ); +% +% $last_bill = $cust_pkg->last_bill; +% } else { +% $last_bill = 0; +% %plandata = (); +% } +% +% my $seconds = $svc_acct->seconds_since_sqlradacct( $last_bill, time ); +% my $hour = int($seconds/3600); +% my $min = int( ($seconds%3600) / 60 ); +% my $sec = $seconds%60; +% +% my $input = $svc_acct->attribute_since_sqlradacct( +% $last_bill, time, 'AcctInputOctets' +% ) / 1048576; +% my $output = $svc_acct->attribute_since_sqlradacct( +% $last_bill, time, 'AcctOutputOctets' +% ) / 1048576; +% +% -<% } %> - -<% if ( $part_svc->part_export_usage ) { - - my $last_bill; - my %plandata; - if ( $cust_pkg ) { - #false laziness w/httemplate/edit/part_pkg... this stuff doesn't really - #belong in plan data - %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } - split("\n", $cust_pkg->part_pkg->plandata ); - - $last_bill = $cust_pkg->last_bill; - } else { - $last_bill = 0; - %plandata = (); - } - - my $seconds = $svc_acct->seconds_since_sqlradacct( $last_bill, time ); - my $hour = int($seconds/3600); - my $min = int( ($seconds%3600) / 60 ); - my $sec = $seconds%60; - - my $input = $svc_acct->attribute_since_sqlradacct( - $last_bill, time, 'AcctInputOctets' - ) / 1048576; - my $output = $svc_acct->attribute_since_sqlradacct( - $last_bill, time, 'AcctOutputOctets' - ) / 1048576; - -%> RADIUS session information<BR> - <%= ntable('#cccccc',2) %> + <% ntable('#cccccc',2) %> <TR><TD BGCOLOR="#ffffff"> +% if ( $seconds ) { + + Online <B><% $hour %></B>h <B><% $min %></B>m <B><% $sec %></B>s +% } else { - <% if ( $seconds ) { %> - Online <B><%= $hour %></B>h <B><%= $min %></B>m <B><%= $sec %></B>s - <% } else { %> Has not logged on - <% } %> +% } +% if ( $cust_pkg ) { + + since last bill (<% time2str('%a %b %o %Y', $last_bill) %>) +% if ( length($plandata{recur_included_hours}) ) { + + - <% $plandata{recur_included_hours} %> total hours in plan +% } - <% if ( $cust_pkg ) { %> - since last bill (<%= time2str('%a %b %o %Y', $last_bill) %>) - <% if ( length($plandata{recur_included_hours}) ) { %> - - <%= $plandata{recur_included_hours} %> total hours in plan - <% } %> <BR> - <% } else { %> +% } else { + (no billing cycle available for unaudited account)<BR> - <% } %> +% } - Upload: <B><%= sprintf("%.3f", $input) %></B> megabytes<BR> - Download: <B><%= sprintf("%.3f", $output) %></B> megabytes<BR> - <% my $href = qq!<A HREF="${p}search/sqlradius.cgi?svcnum=$svcnum!; %> + Upload: <B><% sprintf("%.3f", $input) %></B> megabytes<BR> + Download: <B><% sprintf("%.3f", $output) %></B> megabytes<BR> +% my $href = qq!<A HREF="${p}search/sqlradius.cgi?svcnum=$svcnum!; + View session detail: - <%= $href %>;begin=<%= $last_bill %>">this billing cycle</A> - | <%= $href %>;begin=<%= time-15552000 %>">past six months</A> - | <%= $href %>">all sessions</A> + <% $href %>;begin=<% $last_bill %>">this billing cycle</A> + | <% $href %>;begin=<% time-15552000 %>">past six months</A> + | <% $href %>">all sessions</A> </TD></TR></TABLE><BR> +% } -<% } %> <SCRIPT TYPE="text/javascript"> function enable_change () { @@ -134,199 +138,204 @@ function enable_change () { } } </SCRIPT> -<FORM NAME="OneTrueForm" ACTION="<%=$p%>edit/process/cust_svc.cgi"> -<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%= $svcnum %>"> -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> - -<% #print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!; %> - -<% - my @part_svc = (); - if ( $pkgnum ) { - @part_svc = grep { $_->svcdb eq 'svc_acct' - && $_->svcpart != $part_svc->svcpart } - $cust_pkg->available_part_svc; - } else { - @part_svc = qsearch('part_svc', { - svcdb => 'svc_acct', - disabled => '', - svcpart => { op=>'!=', value=>$part_svc->svcpart }, - } ); - } -%> +<FORM NAME="OneTrueForm" ACTION="<%$p%>edit/process/cust_svc.cgi"> +<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>"> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>"> +% #print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!; +% +% my @part_svc = (); +% if ( $pkgnum ) { +% @part_svc = grep { $_->svcdb eq 'svc_acct' +% && $_->svcpart != $part_svc->svcpart } +% $cust_pkg->available_part_svc; +% } else { +% @part_svc = qsearch('part_svc', { +% svcdb => 'svc_acct', +% disabled => '', +% svcpart => { op=>'!=', value=>$part_svc->svcpart }, +% } ); +% } +% + + +Service #<B><% $svcnum %></B> +| <A HREF="<%$p%>edit/svc_acct.cgi?<%$svcnum%>">Edit this service</A> +% if ( @part_svc ) { -Service #<B><%= $svcnum %></B> -| <A HREF="<%=$p%>edit/svc_acct.cgi?<%=$svcnum%>">Edit this service</A> - -<% if ( @part_svc ) { %> | <SELECT NAME="svcpart" onChange="enable_change()"> <OPTION VALUE="">Change service</OPTION> <OPTION VALUE="">--------------</OPTION> - <% foreach my $opt_part_svc ( @part_svc ) { %> - <OPTION VALUE="<%= $opt_part_svc->svcpart %>"><%= $opt_part_svc->svc %></OPTION> - <% } %> +% foreach my $opt_part_svc ( @part_svc ) { + + <OPTION VALUE="<% $opt_part_svc->svcpart %>"><% $opt_part_svc->svc %></OPTION> +% } + </SELECT> <INPUT NAME="submit" TYPE="submit" VALUE="Change" disabled> -<% } %> +% } + -<%= &ntable("#cccccc") %><TR><TD><%= &ntable("#cccccc",2) %> +<% &ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %> <TR> <TD ALIGN="right">Service</TD> - <TD BGCOLOR="#ffffff"><%= $part_svc->svc %></TD> + <TD BGCOLOR="#ffffff"><% $part_svc->svc %></TD> </TR> <TR> <TD ALIGN="right">Username</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->username %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->username %></TD> </TR> <TR> <TD ALIGN="right">Domain</TD> - <TD BGCOLOR="#ffffff"><%= $domain %></TD> + <TD BGCOLOR="#ffffff"><% $domain %></TD> </TR> <TR> <TD ALIGN="right">Password</TD> <TD BGCOLOR="#ffffff"> +% my $password = $svc_acct->_password; +% if ( $password =~ /^\*\w+\* (.*)$/ ) { +% $password = $1; +% - <% my $password = $svc_acct->_password; %> - <% if ( $password =~ /^\*\w+\* (.*)$/ ) { - $password = $1; - %> <I>(login disabled)</I> - <% } %> +% } +% if ( $conf->exists('showpasswords') ) { + + <PRE><% encode_entities($password) %></PRE> +% } else { - <% if ( $conf->exists('showpasswords') ) { %> - <PRE><%= encode_entities($password) %></PRE> - <% } else { %> <I>(hidden)</I> - <% } %> +% } + </TD> </TR> -<% $password = ''; %> +% $password = ''; +% if ( $conf->exists('security_phrase') ) { +% my $sec_phrase = $svc_acct->sec_phrase; +% -<% if ( $conf->exists('security_phrase') ) { - my $sec_phrase = $svc_acct->sec_phrase; -%> <TR> <TD ALIGN="right">Security phrase</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->sec_phrase %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->sec_phrase %></TD> </TR> -<% } %> +% } +% if ( $svc_acct->popnum ) { +% my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum}); +% -<% if ( $svc_acct->popnum ) { - my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum}); -%> <TR> <TD ALIGN="right">Access number</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct_pop->text %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct_pop->text %></TD> </TR> -<% } %> +% } +% if ($svc_acct->uid ne '') { -<% if ($svc_acct->uid ne '') { %> <TR> <TD ALIGN="right">UID</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->uid %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->uid %></TD> </TR> -<% } %> +% } +% if ($svc_acct->gid ne '') { -<% if ($svc_acct->gid ne '') { %> <TR> <TD ALIGN="right">GID</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->gid %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->gid %></TD> </TR> -<% } %> +% } +% if ($svc_acct->finger ne '') { -<% if ($svc_acct->finger ne '') { %> <TR> <TD ALIGN="right">GECOS</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->finger %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->finger %></TD> </TR> -<% } %> +% } +% if ($svc_acct->dir ne '') { -<% if ($svc_acct->dir ne '') { %> <TR> <TD ALIGN="right">Home directory</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->dir %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->dir %></TD> </TR> -<% } %> +% } +% if ($svc_acct->shell ne '') { -<% if ($svc_acct->shell ne '') { %> <TR> <TD ALIGN="right">Shell</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->shell %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->shell %></TD> </TR> -<% } %> +% } +% if ($svc_acct->quota ne '') { -<% if ($svc_acct->quota ne '') { %> <TR> <TD ALIGN="right">Quota</TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->quota %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->quota %></TD> </TR> -<% } %> +% } +% if ($svc_acct->slipip) { -<% if ($svc_acct->slipip) { %> <TR> <TD ALIGN="right">IP address</TD> <TD BGCOLOR="#ffffff"> - <%= ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) + <% ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) ? "<I>(Dynamic)</I>" : $svc_acct->slipip %> </TD> </TR> -<% } %> +% } +% foreach my $attribute ( grep /^radius_/, $svc_acct->fields ) { +% $attribute =~ /^radius_(.*)$/; +% my $pattribute = $FS::raddb::attrib{$1}; +% -<% foreach my $attribute ( grep /^radius_/, $svc_acct->fields ) { - $attribute =~ /^radius_(.*)$/; - my $pattribute = $FS::raddb::attrib{$1}; -%> <TR> - <TD ALIGN="right">Radius (reply) <%= $pattribute %></TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->getfield($attribute) %></TD> + <TD ALIGN="right">Radius (reply) <% $pattribute %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->getfield($attribute) %></TD> </TR> -<% } %> +% } +% foreach my $attribute ( grep /^rc_/, $svc_acct->fields ) { +% $attribute =~ /^rc_(.*)$/; +% my $pattribute = $FS::raddb::attrib{$1}; +% -<% foreach my $attribute ( grep /^rc_/, $svc_acct->fields ) { - $attribute =~ /^rc_(.*)$/; - my $pattribute = $FS::raddb::attrib{$1}; -%> <TR> - <TD ALIGN="right">Radius (check) <%= $pattribute %></TD> - <TD BGCOLOR="#ffffff"><%= $svc_acct->getfield($attribute) %></TD> + <TD ALIGN="right">Radius (check) <% $pattribute %></TD> + <TD BGCOLOR="#ffffff"><% $svc_acct->getfield($attribute) %></TD> </TR> -<% } %> +% } + <TR> <TD ALIGN="right">RADIUS groups</TD> - <TD BGCOLOR="#ffffff"><%= join('<BR>', $svc_acct->radius_groups) %></TD> + <TD BGCOLOR="#ffffff"><% join('<BR>', $svc_acct->radius_groups) %></TD> </TR> +% if ( $svc_acct->seconds =~ /^\d+$/ ) { -<% if ( $svc_acct->seconds =~ /^\d+$/ ) { %> <TR> <TD ALIGN="right">Prepaid time</TD> - <TD BGCOLOR="#ffffff"><%= duration_exact($svc_acct->seconds) %></TD> + <TD BGCOLOR="#ffffff"><% duration_exact($svc_acct->seconds) %></TD> </TR> -<% } %> +% } +% +%# Can this be abstracted further? Maybe a library function like +%# widget('HTML', 'view', $svc_acct) ? It would definitely make UI +%# style management easier. +% +% foreach (sort { $a cmp $b } $svc_acct->virtual_fields) { -<% -# Can this be abstracted further? Maybe a library function like -# widget('HTML', 'view', $svc_acct) ? It would definitely make UI -# style management easier. -%> + <% $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)) %> +% } -<% foreach (sort { $a cmp $b } $svc_acct->virtual_fields) { %> - <%= $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)) %> -<% } %> </TABLE></TD></TR></TABLE> </FORM> <BR><BR> -<%= join("<BR>", $conf->config('svc_acct-notes') ) %> +<% join("<BR>", $conf->config('svc_acct-notes') ) %> <BR><BR> -<%= joblisting({'svcnum'=>$svcnum}, 1) %> +<% joblisting({'svcnum'=>$svcnum}, 1) %> </BODY> </HTML> diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi index 263fd70f5..1800541f0 100644 --- a/httemplate/view/svc_broadband.cgi +++ b/httemplate/view/svc_broadband.cgi @@ -1,50 +1,51 @@ <!-- mason kludge --> -<% - -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; -my $svc_broadband = qsearchs( 'svc_broadband', { 'svcnum' => $svcnum } ) - or die "svc_broadband: Unknown svcnum $svcnum"; - -#false laziness w/all svc_*.cgi -my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } ); -my $pkgnum = $cust_svc->getfield('pkgnum'); -my($cust_pkg, $custnum); -if ($pkgnum) { - $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); - $custnum = $cust_pkg->custnum; -} else { - $cust_pkg = ''; - $custnum = ''; -} -#eofalse - -my $addr_block = $svc_broadband->addr_block; -my $router = $addr_block->router; - -if (not $router) { die "Could not lookup router for svc_broadband (svcnum $svcnum)" }; - -my ( - $routername, - $routernum, - $speed_down, - $speed_up, - $ip_addr, - $ip_gateway, - $ip_netmask, - ) = ( - $router->getfield('routername'), - $router->getfield('routernum'), - $svc_broadband->getfield('speed_down'), - $svc_broadband->getfield('speed_up'), - $svc_broadband->getfield('ip_addr'), - $addr_block->ip_gateway, - $addr_block->NetAddr->mask, - ); -%> +% +% +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +%my $svc_broadband = qsearchs( 'svc_broadband', { 'svcnum' => $svcnum } ) +% or die "svc_broadband: Unknown svcnum $svcnum"; +% +%#false laziness w/all svc_*.cgi +%my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } ); +%my $pkgnum = $cust_svc->getfield('pkgnum'); +%my($cust_pkg, $custnum); +%if ($pkgnum) { +% $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); +% $custnum = $cust_pkg->custnum; +%} else { +% $cust_pkg = ''; +% $custnum = ''; +%} +%#eofalse +% +%my $addr_block = $svc_broadband->addr_block; +%my $router = $addr_block->router; +% +%if (not $router) { die "Could not lookup router for svc_broadband (svcnum $svcnum)" }; +% +%my ( +% $routername, +% $routernum, +% $speed_down, +% $speed_up, +% $ip_addr, +% $ip_gateway, +% $ip_netmask, +% ) = ( +% $router->getfield('routername'), +% $router->getfield('routernum'), +% $svc_broadband->getfield('speed_down'), +% $svc_broadband->getfield('speed_up'), +% $svc_broadband->getfield('ip_addr'), +% $addr_block->ip_gateway, +% $addr_block->NetAddr->mask, +% ); +% + -<%=include("/elements/header.html",'Broadband Service View', menubar( +<%include("/elements/header.html",'Broadband Service View', menubar( ( ( $custnum ) ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", ) @@ -55,101 +56,108 @@ my ( )) %> -<A HREF="<%=${p}%>edit/svc_broadband.cgi?<%=$svcnum%>">Edit this information</A> +<A HREF="<%${p}%>edit/svc_broadband.cgi?<%$svcnum%>">Edit this information</A> <BR> -<%=ntable("#cccccc")%> +<%ntable("#cccccc")%> <TR> <TD> - <%=ntable("#cccccc",2)%> + <%ntable("#cccccc",2)%> <TR> <TD ALIGN="right">Service number</TD> - <TD BGCOLOR="#ffffff"><%=$svcnum%></TD> + <TD BGCOLOR="#ffffff"><%$svcnum%></TD> </TR> <TR> <TD ALIGN="right">Router</TD> - <TD BGCOLOR="#ffffff"><%=$routernum%>: <%=$routername%></TD> + <TD BGCOLOR="#ffffff"><%$routernum%>: <%$routername%></TD> </TR> <TR> <TD ALIGN="right">Download Speed</TD> - <TD BGCOLOR="#ffffff"><%=$speed_down%></TD> + <TD BGCOLOR="#ffffff"><%$speed_down%></TD> </TR> <TR> <TD ALIGN="right">Upload Speed</TD> - <TD BGCOLOR="#ffffff"><%=$speed_up%></TD> + <TD BGCOLOR="#ffffff"><%$speed_up%></TD> </TR> <TR> <TD ALIGN="right">IP Address</TD> - <TD BGCOLOR="#ffffff"><%=$ip_addr%></TD> + <TD BGCOLOR="#ffffff"><%$ip_addr%></TD> </TR> <TR> <TD ALIGN="right">IP Netmask</TD> - <TD BGCOLOR="#ffffff"><%=$ip_netmask%></TD> + <TD BGCOLOR="#ffffff"><%$ip_netmask%></TD> </TR> <TR> <TD ALIGN="right">IP Gateway</TD> - <TD BGCOLOR="#ffffff"><%=$ip_gateway%></TD> + <TD BGCOLOR="#ffffff"><%$ip_gateway%></TD> </TR> <TR COLSPAN="2"><TD></TD></TR> +% +%foreach (sort { $a cmp $b } $svc_broadband->virtual_fields) { +% print $svc_broadband->pvf($_)->widget('HTML', 'view', +% $svc_broadband->getfield($_)), "\n"; +%} +% +% -<% -foreach (sort { $a cmp $b } $svc_broadband->virtual_fields) { - print $svc_broadband->pvf($_)->widget('HTML', 'view', - $svc_broadband->getfield($_)), "\n"; -} - -%> </TABLE> </TD> </TR> </TABLE> <BR> -<%=ntable("#cccccc", 2)%> -<% - my $sb_router = qsearchs('router', { svcnum => $svcnum }); - if ($sb_router) { - %> - <B>Router associated: <%=$sb_router->routername%> </B> - <A HREF="<%=popurl(2)%>edit/router.cgi?<%=$sb_router->routernum%>"> +<%ntable("#cccccc", 2)%> +% +% my $sb_router = qsearchs('router', { svcnum => $svcnum }); +% if ($sb_router) { +% + + <B>Router associated: <%$sb_router->routername%> </B> + <A HREF="<%popurl(2)%>edit/router.cgi?<%$sb_router->routernum%>"> (details) </A> <BR> - <% my @sb_addr_block; - if (@sb_addr_block = $sb_router->addr_block) { - %> +% my @sb_addr_block; +% if (@sb_addr_block = $sb_router->addr_block) { +% + <B>Address space </B> - <A HREF="<%=popurl(2)%>browse/addr_block.cgi"> + <A HREF="<%popurl(2)%>browse/addr_block.cgi"> (edit) </A> <BR> - <% print ntable("#cccccc", 1); - foreach (@sb_addr_block) { %> +% print ntable("#cccccc", 1); +% foreach (@sb_addr_block) { + <TR> - <TD><%=$_->ip_gateway%>/<%=$_->ip_netmask%></TD> + <TD><%$_->ip_gateway%>/<%$_->ip_netmask%></TD> </TR> - <% } %> +% } + </TABLE> - <% } else { %> +% } else { + <B>No address space allocated.</B> - <% } %> +% } + <BR> - <% - } else { -%> +% +% } else { +% + -<FORM METHOD="GET" ACTION="<%=popurl(2)%>edit/router.cgi"> - <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%=$svcnum%>"> +<FORM METHOD="GET" ACTION="<%popurl(2)%>edit/router.cgi"> + <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>"> Add router named - <INPUT TYPE="text" NAME="routername" SIZE="32" VALUE="Broadband router (<%=$svcnum%>)"> + <INPUT TYPE="text" NAME="routername" SIZE="32" VALUE="Broadband router (<%$svcnum%>)"> <INPUT TYPE="submit" VALUE="Add router"> </FORM> +% +%} +% -<% -} -%> <BR> -<%=joblisting({'svcnum'=>$svcnum}, 1)%> +<%joblisting({'svcnum'=>$svcnum}, 1)%> </BODY> </HTML> diff --git a/httemplate/view/svc_domain.cgi b/httemplate/view/svc_domain.cgi index f39663094..44390bf8b 100755 --- a/httemplate/view/svc_domain.cgi +++ b/httemplate/view/svc_domain.cgi @@ -1,38 +1,39 @@ <!-- mason kludge --> -<% +% +% +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +%my $svc_domain = qsearchs('svc_domain',{'svcnum'=>$svcnum}); +%die "Unknown svcnum" unless $svc_domain; +% +%my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +%my $pkgnum = $cust_svc->getfield('pkgnum'); +%my($cust_pkg, $custnum); +%if ($pkgnum) { +% $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +% $custnum=$cust_pkg->getfield('custnum'); +%} else { +% $cust_pkg = ''; +% $custnum = ''; +%} +% +%my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ); +%die "Unknown svcpart" unless $part_svc; +% +%my $email = ''; +%if ($svc_domain->catchall) { +% my $svc_acct = qsearchs('svc_acct',{'svcnum'=> $svc_domain->catchall } ); +% die "Unknown svcpart" unless $svc_acct; +% $email = $svc_acct->email; +%} +% +%my $domain = $svc_domain->domain; +% +% -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; -my $svc_domain = qsearchs('svc_domain',{'svcnum'=>$svcnum}); -die "Unknown svcnum" unless $svc_domain; -my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -my $pkgnum = $cust_svc->getfield('pkgnum'); -my($cust_pkg, $custnum); -if ($pkgnum) { - $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - $custnum=$cust_pkg->getfield('custnum'); -} else { - $cust_pkg = ''; - $custnum = ''; -} - -my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ); -die "Unknown svcpart" unless $part_svc; - -my $email = ''; -if ($svc_domain->catchall) { - my $svc_acct = qsearchs('svc_acct',{'svcnum'=> $svc_domain->catchall } ); - die "Unknown svcpart" unless $svc_acct; - $email = $svc_acct->email; -} - -my $domain = $svc_domain->domain; - -%> - -<%= include("/elements/header.html",'Domain View', menubar( +<% include("/elements/header.html",'Domain View', menubar( ( ( $pkgnum || $custnum ) ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", ) @@ -42,12 +43,12 @@ my $domain = $svc_domain->domain; "Main menu" => $p, )) %> -Service #<%= $svcnum %> -<BR>Service: <B><%= $part_svc->svc %></B> -<BR>Domain name: <B><%= $domain %></B> -<BR>Catch all email <A HREF="<%= ${p} %>misc/catchall.cgi?<%= $svcnum %>">(change)</A>: -<%= $email ? "<B>$email</B>" : "<I>(none)<I>" %> -<BR><BR><A HREF="<%= ${p} %>misc/whois.cgi?custnum=<%=$custnum%>;svcnum=<%=$svcnum%>;domain=<%=$domain%>">View whois information.</A> +Service #<% $svcnum %> +<BR>Service: <B><% $part_svc->svc %></B> +<BR>Domain name: <B><% $domain %></B> +<BR>Catch all email <A HREF="<% ${p} %>misc/catchall.cgi?<% $svcnum %>">(change)</A>: +<% $email ? "<B>$email</B>" : "<I>(none)<I>" %> +<BR><BR><A HREF="<% ${p} %>misc/whois.cgi?custnum=<%$custnum%>;svcnum=<%$svcnum%>;domain=<%$domain%>">View whois information.</A> <BR><BR> <SCRIPT> function areyousure(href, message) { @@ -58,51 +59,58 @@ Service #<%= $svcnum %> return confirm("Remove all records and slave from " + document.SlaveForm.recdata.value + "?"); } </SCRIPT> +% my @records; if ( @records = $svc_domain->domain_record ) { -<% my @records; if ( @records = $svc_domain->domain_record ) { %> - <%= ntable("",2) %> + <% ntable("",2) %> <tr><th>Zone</th><th>Type</th><th>Data</th></tr> +% foreach my $domain_record ( @records ) { +% my $type = $domain_record->rectype eq '_mstr' +% ? "(slave)" +% : $domain_record->recaf. ' '. $domain_record->rectype; +% - <% foreach my $domain_record ( @records ) { - my $type = $domain_record->rectype eq '_mstr' - ? "(slave)" - : $domain_record->recaf. ' '. $domain_record->rectype; - %> - <tr><td><%= $domain_record->reczone %></td> - <td><%= $type %></td> - <td><%= $domain_record->recdata %> + <tr><td><% $domain_record->reczone %></td> + <td><% $type %></td> + <td><% $domain_record->recdata %> +% unless ( $domain_record->rectype eq 'SOA' ) { + + (<A HREF="javascript:areyousure('<%$p%>misc/delete-domain_record.cgi?<%$domain_record->recnum%>', 'Delete \'<% $domain_record->reczone %> <% $type %> <% $domain_record->recdata %>\' ?' )">delete</A>) +% } - <% unless ( $domain_record->rectype eq 'SOA' ) { %> - (<A HREF="javascript:areyousure('<%=$p%>misc/delete-domain_record.cgi?<%=$domain_record->recnum%>', 'Delete \'<%= $domain_record->reczone %> <%= $type %> <%= $domain_record->recdata %>\' ?' )">delete</A>) - <% } %> </td></tr> - <% } %> +% } + </table> -<% } %> +% } + <BR> -<FORM METHOD="POST" ACTION="<%=$p%>edit/process/domain_record.cgi"> -<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%=$svcnum%>"> +<FORM METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi"> +<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>"> <INPUT TYPE="text" NAME="reczone"> <INPUT TYPE="hidden" NAME="recaf" VALUE="IN"> IN <SELECT NAME="rectype"> -<% foreach (qw( A NS CNAME MX PTR TXT) ) { %> - <OPTION VALUE="<%=$_%>"><%=$_%></OPTION> -<% } %> +% foreach (qw( A NS CNAME MX PTR TXT) ) { + + <OPTION VALUE="<%$_%>"><%$_%></OPTION> +% } + </SELECT> <INPUT TYPE="text" NAME="recdata"> <INPUT TYPE="submit" VALUE="Add record"> </FORM><BR><BR>or<BR><BR> -<FORM NAME="SlaveForm" METHOD="POST" ACTION="<%=$p%>edit/process/domain_record.cgi"> -<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%=$svcnum%>"> +<FORM NAME="SlaveForm" METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi"> +<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>"> +% if ( @records ) { + Delete all records and +% } -<% if ( @records ) { %> Delete all records and <% } %> Slave from nameserver IP -<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%=$svcnum%>"> +<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>"> <INPUT TYPE="hidden" NAME="reczone" VALUE="@"> <INPUT TYPE="hidden" NAME="recaf" VALUE="IN"> <INPUT TYPE="hidden" NAME="rectype" VALUE="_mstr"> <INPUT TYPE="text" NAME="recdata"> <INPUT TYPE="submit" VALUE="Slave domain" onClick="return slave_areyousure()"> </FORM> -<BR><BR><%= joblisting({'svcnum'=>$svcnum}, 1) %> +<BR><BR><% joblisting({'svcnum'=>$svcnum}, 1) %> </BODY></HTML> diff --git a/httemplate/view/svc_external.cgi b/httemplate/view/svc_external.cgi index 7816d88dc..06302bd8f 100644 --- a/httemplate/view/svc_external.cgi +++ b/httemplate/view/svc_external.cgi @@ -1,30 +1,31 @@ -<% - -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; -my $svc_external = qsearchs( 'svc_external', { 'svcnum' => $svcnum } ) - or die "svc_external: Unknown svcnum $svcnum"; - -my $conf = new FS::Conf; - -#false laziness w/all svc_*.cgi -my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } ); -my $pkgnum = $cust_svc->getfield('pkgnum'); -my($cust_pkg, $custnum); -if ($pkgnum) { - $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); - $custnum = $cust_pkg->custnum; -} else { - $cust_pkg = ''; - $custnum = ''; -} -#eofalse - - -%> - -<%= include("/elements/header.html",'External Service View', menubar( +% +% +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +%my $svc_external = qsearchs( 'svc_external', { 'svcnum' => $svcnum } ) +% or die "svc_external: Unknown svcnum $svcnum"; +% +%my $conf = new FS::Conf; +% +%#false laziness w/all svc_*.cgi +%my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } ); +%my $pkgnum = $cust_svc->getfield('pkgnum'); +%my($cust_pkg, $custnum); +%if ($pkgnum) { +% $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); +% $custnum = $cust_pkg->custnum; +%} else { +% $cust_pkg = ''; +% $custnum = ''; +%} +%#eofalse +% +% +% + + +<% include("/elements/header.html",'External Service View', menubar( ( ( $custnum ) ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", ) @@ -34,20 +35,21 @@ if ($pkgnum) { "Main menu" => $p, )) %> -<A HREF="<%=$p%>edit/svc_external.cgi?<%=$svcnum%>">Edit this information</A><BR> -<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %> +<A HREF="<%$p%>edit/svc_external.cgi?<%$svcnum%>">Edit this information</A><BR> +<% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %> <TR><TD ALIGN="right">Service number</TD> - <TD BGCOLOR="#ffffff"><%= $svcnum %></TD></TR> -<TR><TD ALIGN="right"><%= FS::Msgcat::_gettext('svc_external-id') || 'External ID' %></TD> - <TD BGCOLOR="#ffffff"><%= $conf->config('svc_external-display_type') eq 'artera_turbo' ? sprintf('%010d', $svc_external->id) : $svc_external->id %></TD></TR> -<TR><TD ALIGN="right"><%= FS::Msgcat::_gettext('svc_external-title') || 'Title' %></TD> - <TD BGCOLOR="#ffffff"><%= $svc_external->title %></TD></TR> + <TD BGCOLOR="#ffffff"><% $svcnum %></TD></TR> +<TR><TD ALIGN="right"><% FS::Msgcat::_gettext('svc_external-id') || 'External ID' %></TD> + <TD BGCOLOR="#ffffff"><% $conf->config('svc_external-display_type') eq 'artera_turbo' ? sprintf('%010d', $svc_external->id) : $svc_external->id %></TD></TR> +<TR><TD ALIGN="right"><% FS::Msgcat::_gettext('svc_external-title') || 'Title' %></TD> + <TD BGCOLOR="#ffffff"><% $svc_external->title %></TD></TR> +% foreach (sort { $a cmp $b } $svc_external->virtual_fields) { + + <% $svc_external->pvf($_)->widget('HTML', 'view', $svc_external->getfield($_)) %> +% } -<% foreach (sort { $a cmp $b } $svc_external->virtual_fields) { %> - <%= $svc_external->pvf($_)->widget('HTML', 'view', $svc_external->getfield($_)) %> -<% } %> </TABLE></TD></TR></TABLE> -<BR><%= joblisting({'svcnum'=>$svcnum}, 1) %> +<BR><% joblisting({'svcnum'=>$svcnum}, 1) %> </BODY></HTML> diff --git a/httemplate/view/svc_forward.cgi b/httemplate/view/svc_forward.cgi index 52360bcc2..fcc0bc96f 100755 --- a/httemplate/view/svc_forward.cgi +++ b/httemplate/view/svc_forward.cgi @@ -1,84 +1,85 @@ <!-- mason kludge --> -<% +% +% +%my $conf = new FS::Conf; +% +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +%my $svc_forward = qsearchs('svc_forward',{'svcnum'=>$svcnum}); +%die "Unknown svcnum" unless $svc_forward; +% +%my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +%my $pkgnum = $cust_svc->getfield('pkgnum'); +%my($cust_pkg, $custnum); +%if ($pkgnum) { +% $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +% $custnum=$cust_pkg->getfield('custnum'); +%} else { +% $cust_pkg = ''; +% $custnum = ''; +%} +% +%my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ) +% or die "Unkonwn svcpart"; +% +%print header('Mail Forward View', menubar( +% ( ( $pkgnum || $custnum ) +% ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", +% ) +% : ( "Cancel this (unaudited) mail forward" => +% "${p}misc/cancel-unaudited.cgi?$svcnum" ) +% ), +% "Main menu" => $p, +%)); +% +%my($srcsvc,$dstsvc,$dst) = ( +% $svc_forward->srcsvc, +% $svc_forward->dstsvc, +% $svc_forward->dst, +%); +%my $src = $svc_forward->dbdef_table->column('src') ? $svc_forward->src : ''; +% +%my $svc = $part_svc->svc; +% +%my $source; +%if ($srcsvc) { +% my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$srcsvc}) +% or die "Corrupted database: no svc_acct.svcnum matching srcsvc $srcsvc"; +% $source = $svc_acct->email; +%} else { +% $source = $src; +%} +% +%my $destination; +%if ($dstsvc) { +% my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$dstsvc}) +% or die "Corrupted database: no svc_acct.svcnum matching dstsvc $dstsvc"; +% $destination = $svc_acct->email; +%} else { +% $destination = $dst; +%} +% +%print qq!<A HREF="${p}edit/svc_forward.cgi?$svcnum">Edit this information</A>!. +% ntable("#cccccc",2). +% '<TR><TD ALIGN="right">Service number</TD>'. +% qq!<TD BGCOLOR="#ffffff">$svcnum</TD></TR>!. +% '<TR><TD ALIGN="right">Service</TD>'. +% qq!<TD BGCOLOR="#ffffff">$svc</TD></TR>!. +% qq!<TR><TD ALIGN="right">Email to</TD>!. +% qq!<TD BGCOLOR="#ffffff">$source</TD></TR>!. +% qq!<TR><TD ALIGN="right">Forwards to </TD>!. +% qq!<TD BGCOLOR="#ffffff">$destination</TD></TR>!; +% +%foreach (sort { $a cmp $b } $svc_forward->virtual_fields) { +% print $svc_forward->pvf($_)->widget('HTML', 'view', $svc_forward->getfield($_)), +% "\n"; +%} +% +%print qq! </TABLE>!. +% '<BR>'. joblisting({'svcnum'=>$svcnum}, 1). +% '</BODY></HTML>' +%; +% +% -my $conf = new FS::Conf; - -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; -my $svc_forward = qsearchs('svc_forward',{'svcnum'=>$svcnum}); -die "Unknown svcnum" unless $svc_forward; - -my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -my $pkgnum = $cust_svc->getfield('pkgnum'); -my($cust_pkg, $custnum); -if ($pkgnum) { - $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - $custnum=$cust_pkg->getfield('custnum'); -} else { - $cust_pkg = ''; - $custnum = ''; -} - -my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ) - or die "Unkonwn svcpart"; - -print header('Mail Forward View', menubar( - ( ( $pkgnum || $custnum ) - ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", - ) - : ( "Cancel this (unaudited) mail forward" => - "${p}misc/cancel-unaudited.cgi?$svcnum" ) - ), - "Main menu" => $p, -)); - -my($srcsvc,$dstsvc,$dst) = ( - $svc_forward->srcsvc, - $svc_forward->dstsvc, - $svc_forward->dst, -); -my $src = $svc_forward->dbdef_table->column('src') ? $svc_forward->src : ''; - -my $svc = $part_svc->svc; - -my $source; -if ($srcsvc) { - my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$srcsvc}) - or die "Corrupted database: no svc_acct.svcnum matching srcsvc $srcsvc"; - $source = $svc_acct->email; -} else { - $source = $src; -} - -my $destination; -if ($dstsvc) { - my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$dstsvc}) - or die "Corrupted database: no svc_acct.svcnum matching dstsvc $dstsvc"; - $destination = $svc_acct->email; -} else { - $destination = $dst; -} - -print qq!<A HREF="${p}edit/svc_forward.cgi?$svcnum">Edit this information</A>!. - ntable("#cccccc",2). - '<TR><TD ALIGN="right">Service number</TD>'. - qq!<TD BGCOLOR="#ffffff">$svcnum</TD></TR>!. - '<TR><TD ALIGN="right">Service</TD>'. - qq!<TD BGCOLOR="#ffffff">$svc</TD></TR>!. - qq!<TR><TD ALIGN="right">Email to</TD>!. - qq!<TD BGCOLOR="#ffffff">$source</TD></TR>!. - qq!<TR><TD ALIGN="right">Forwards to </TD>!. - qq!<TD BGCOLOR="#ffffff">$destination</TD></TR>!; - -foreach (sort { $a cmp $b } $svc_forward->virtual_fields) { - print $svc_forward->pvf($_)->widget('HTML', 'view', $svc_forward->getfield($_)), - "\n"; -} - -print qq! </TABLE>!. - '<BR>'. joblisting({'svcnum'=>$svcnum}, 1). - '</BODY></HTML>' -; - -%> diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi index 8de7cc8e7..732f3cd79 100644 --- a/httemplate/view/svc_phone.cgi +++ b/httemplate/view/svc_phone.cgi @@ -1,4 +1,4 @@ -<%= include('elements/svc_Common.html', +<% include('elements/svc_Common.html', 'table' => 'svc_phone', 'fields' => [qw( countrycode phonenum )], #pin 'labels' => { diff --git a/httemplate/view/svc_www.cgi b/httemplate/view/svc_www.cgi index 6c8cd6a0b..f2be5c717 100644 --- a/httemplate/view/svc_www.cgi +++ b/httemplate/view/svc_www.cgi @@ -1,73 +1,74 @@ <!-- mason kludge --> -<% +% +% +%my($query) = $cgi->keywords; +%$query =~ /^(\d+)$/; +%my $svcnum = $1; +%my $svc_www = qsearchs( 'svc_www', { 'svcnum' => $svcnum } ) +% or die "svc_www: Unknown svcnum $svcnum"; +% +%#false laziness w/all svc_*.cgi +%my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } ); +%my $pkgnum = $cust_svc->getfield('pkgnum'); +%my($cust_pkg, $custnum); +%if ($pkgnum) { +% $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); +% $custnum = $cust_pkg->custnum; +%} else { +% $cust_pkg = ''; +% $custnum = ''; +%} +%#eofalse +% +%my $usersvc = $svc_www->usersvc; +%my $svc_acct = ''; +%my $email = ''; +%if ( $usersvc ) { +% $svc_acct = qsearchs('svc_acct', { 'svcnum' => $usersvc } ) +% or die "svc_www: Unknown usersvc $usersvc"; +% $email = $svc_acct->email; +%} +% +%my $domain_record = qsearchs('domain_record', { 'recnum' => $svc_www->recnum } ) +% or die "svc_www: Unknown recnum ". $svc_www->recnum; +% +%my $www = $domain_record->zone; +% +%print header('Website View', menubar( +% ( ( $custnum ) +% ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", +% ) +% : ( "Cancel this (unaudited) website" => +% "${p}misc/cancel-unaudited.cgi?$svcnum" ) +% ), +% "Main menu" => $p, +%)). +% qq!<A HREF="${p}edit/svc_www.cgi?$svcnum">Edit this information</A><BR>!. +% ntable("#cccccc"). '<TR><TD>'. ntable("#cccccc",2). +% qq!<TR><TD ALIGN="right">Service number</TD>!. +% qq!<TD BGCOLOR="#ffffff">$svcnum</TD></TR>!. +% qq!<TR><TD ALIGN="right">Website name</TD>!. +% qq!<TD BGCOLOR="#ffffff"><A HREF="http://$www">$www<A></TD></TR>!. +% qq!<TR><TD ALIGN="right">Account</TD>!. +% qq!<TD BGCOLOR="#ffffff">!; +% +%if ( $usersvc ) { +% print qq!<A HREF="${p}view/svc_acct.cgi?$usersvc">$email</A>!; +%} else { +% print '</i>(none)</i>'; +%} +% +%print '</TD></TR>'; +% +%foreach (sort { $a cmp $b } $svc_www->virtual_fields) { +% print $svc_www->pvf($_)->widget('HTML', 'view', $svc_www->getfield($_)), +% "\n"; +%} +% +% +%print '</TABLE></TD></TR></TABLE>'. +% '<BR>'. joblisting({'svcnum'=>$svcnum}, 1). +% '</BODY></HTML>' +%; +% -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; -my $svc_www = qsearchs( 'svc_www', { 'svcnum' => $svcnum } ) - or die "svc_www: Unknown svcnum $svcnum"; - -#false laziness w/all svc_*.cgi -my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } ); -my $pkgnum = $cust_svc->getfield('pkgnum'); -my($cust_pkg, $custnum); -if ($pkgnum) { - $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); - $custnum = $cust_pkg->custnum; -} else { - $cust_pkg = ''; - $custnum = ''; -} -#eofalse - -my $usersvc = $svc_www->usersvc; -my $svc_acct = ''; -my $email = ''; -if ( $usersvc ) { - $svc_acct = qsearchs('svc_acct', { 'svcnum' => $usersvc } ) - or die "svc_www: Unknown usersvc $usersvc"; - $email = $svc_acct->email; -} - -my $domain_record = qsearchs('domain_record', { 'recnum' => $svc_www->recnum } ) - or die "svc_www: Unknown recnum ". $svc_www->recnum; - -my $www = $domain_record->zone; - -print header('Website View', menubar( - ( ( $custnum ) - ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", - ) - : ( "Cancel this (unaudited) website" => - "${p}misc/cancel-unaudited.cgi?$svcnum" ) - ), - "Main menu" => $p, -)). - qq!<A HREF="${p}edit/svc_www.cgi?$svcnum">Edit this information</A><BR>!. - ntable("#cccccc"). '<TR><TD>'. ntable("#cccccc",2). - qq!<TR><TD ALIGN="right">Service number</TD>!. - qq!<TD BGCOLOR="#ffffff">$svcnum</TD></TR>!. - qq!<TR><TD ALIGN="right">Website name</TD>!. - qq!<TD BGCOLOR="#ffffff"><A HREF="http://$www">$www<A></TD></TR>!. - qq!<TR><TD ALIGN="right">Account</TD>!. - qq!<TD BGCOLOR="#ffffff">!; - -if ( $usersvc ) { - print qq!<A HREF="${p}view/svc_acct.cgi?$usersvc">$email</A>!; -} else { - print '</i>(none)</i>'; -} - -print '</TD></TR>'; - -foreach (sort { $a cmp $b } $svc_www->virtual_fields) { - print $svc_www->pvf($_)->widget('HTML', 'view', $svc_www->getfield($_)), - "\n"; -} - - -print '</TABLE></TD></TR></TABLE>'. - '<BR>'. joblisting({'svcnum'=>$svcnum}, 1). - '</BODY></HTML>' -; -%> |