diff options
author | ivan <ivan> | 2006-08-23 22:25:39 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-08-23 22:25:39 +0000 |
commit | 3ce7691203a7737406bf2d4442f7fd84b81f847e (patch) | |
tree | 90658b097da96772224f04771888ac6ca1a940aa /httemplate/edit | |
parent | 15e561850b61b10a92a46d8f3e316d53d4970087 (diff) |
Will things ever be the same again?
It's the final masonize
Diffstat (limited to 'httemplate/edit')
96 files changed, 6151 insertions, 5978 deletions
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 -%> |