summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/access_user.html2
-rwxr-xr-xhttemplate/edit/cust_credit.cgi4
-rwxr-xr-xhttemplate/edit/cust_main.cgi88
-rwxr-xr-xhttemplate/edit/cust_pay.cgi20
-rw-r--r--httemplate/edit/elements/edit.html15
-rwxr-xr-xhttemplate/edit/part_referral.cgi44
-rwxr-xr-xhttemplate/edit/part_referral.html9
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi2
-rwxr-xr-xhttemplate/edit/process/cust_pay.cgi30
-rwxr-xr-xhttemplate/edit/process/part_referral.cgi28
-rwxr-xr-xhttemplate/edit/process/part_referral.html5
-rwxr-xr-xhttemplate/edit/svc_acct.cgi15
12 files changed, 114 insertions, 148 deletions
diff --git a/httemplate/edit/access_user.html b/httemplate/edit/access_user.html
index 2b19dbf7b..fb2a97196 100644
--- a/httemplate/edit/access_user.html
+++ b/httemplate/edit/access_user.html
@@ -6,6 +6,7 @@
{ field=>'_password', type=>'password' },
'last',
'first',
+ { field=>'disabled', type=>'checkbox', value=>'Y' },
],
'labels' => {
'usernum' => 'User number',
@@ -13,6 +14,7 @@
'_password' => 'Password',
'last' => 'Last name',
'first' => 'First name',
+ 'disabled' => 'Disable employee',
},
'viewall_dir' => 'browse',
'html_bottom' =>
diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi
index d19f0e4b3..8de627d20 100755
--- a/httemplate/edit/cust_credit.cgi
+++ b/httemplate/edit/cust_credit.cgi
@@ -24,7 +24,7 @@ my $otaker = getotaker;
my $p1 = popurl(1);
-%><%= include('/elements/header-popup.html', 'Post Credit') %>
+%><%= include('/elements/header-popup.html', 'Enter Credit') %>
<% if ( $cgi->param('error') ) { %>
<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
@@ -72,7 +72,7 @@ Credit
</TABLE>
<BR>
-<CENTER><INPUT TYPE="submit" VALUE="Post credit"></CENTER>
+<CENTER><INPUT TYPE="submit" VALUE="Enter credit"></CENTER>
</FORM>
</BODY>
</HTML>
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index bb2a8618e..c3d1804bc 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -64,7 +64,11 @@ if ( $cgi->param('error') ) {
@invoicing_list = ();
}
$cgi->delete_all();
+
my $action = $custnum ? 'Edit' : 'Add';
+$action .= ": ". $cust_main->name if $custnum;
+
+my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
%>
@@ -77,38 +81,29 @@ my $action = $custnum ? 'Edit' : 'Add';
) %>
<% if ( $error ) { %>
-<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $error %></FONT>
+<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $error %></FONT><BR><BR>
<% } %>
<FORM NAME="topform" STYLE="margin-bottom: 0">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
-Customer # <%= $custnum ? "<B>$custnum</B>" : " (NEW)" %>
-
-<!-- agent -->
-
-<%
+<% if ( $custnum ) { %>
+ Customer #<B><%= $custnum %></B> -
+ <B><FONT COLOR="<%= $cust_main->statuscolor %>">
+ <%= ucfirst($cust_main->status) %>
+ </FONT></B>
+ <BR><BR>
+<% } %>
-my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
+<%= &ntable("#cccccc") %>
-my %agent_search = dbdef->table('agent')->column('disabled')
- ? ( 'disabled' => '' ) : ();
-my @agents = qsearch( 'agent', \%agent_search );
-#die "No agents created!" unless @agents;
-eidiot "You have not created any agents (or all agents are disabled). You must create at least one agent before adding a customer. Go to ". popurl(2). "browse/agent.cgi and create one or more agents." unless @agents;
-my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first
+<!-- agent -->
+<%= include('/elements/tr-select-agent.html', $cust_main->agentnum,
+ 'label' => "<B>${r}Agent</B>",
+ 'empty_label' => 'Select agent',
+ )
%>
-<% if ( scalar(@agents) == 1 ) { %>
- <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agentnum %>">
-<% } else { %>
- <BR><BR><%=$r%>Agent <SELECT NAME="agentnum" SIZE="1">
- <% foreach my $agent (sort { $a->agent cmp $b->agent; } @agents) { %>
- <OPTION VALUE="<%= $agent->agentnum %>"<%= " SELECTED"x($agent->agentnum==$agentnum) %>><%= $agent->agent %>
- <% } %>
- </SELECT>
-<% } %>
-
<!-- referral (advertising source) -->
<%
@@ -118,28 +113,9 @@ if ( $custnum && ! $conf->exists('editreferrals') ) {
<INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $refnum %>">
-<%
- } else {
-
- my(@referrals) = qsearch('part_referral',{});
- if ( scalar(@referrals) == 0 ) {
- eidiot "You have not created any advertising sources. You must create at least one advertising source before adding a customer. Go to ". popurl(2). "browse/part_referral.cgi and create one or more advertising sources.";
- } elsif ( scalar(@referrals) == 1 ) {
- $refnum ||= $referrals[0]->refnum;
-%>
-
- <INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $refnum %>">
-
<% } else { %>
- <BR><BR><%=$r%>Advertising source
- <SELECT NAME="refnum" SIZE="1">
- <%= $refnum ? '' : '<OPTION VALUE="">' %>
- <% foreach my $referral (sort { $a->refnum <=> $b->refnum } @referrals) { %>
- <OPTION VALUE="<%= $referral->refnum %>" <%= $referral->refnum == $refnum ? 'SELECTED' : '' %>><%= $referral->refnum %>: <%= $referral->referral %>
- <% } %>
- </SELECT>
-<% } %>
+ <%= include('/elements/tr-select-part_referral.html') %>
<% } %>
@@ -153,14 +129,26 @@ if ( $cust_main->referral_custnum
) {
%>
- <BR><BR>Referring Customer:
- <A HREF="<%= popurl(1) %>/cust_main.cgi?<%= $cust_main->referral_custnum %>"><%= $cust_main->referral_custnum %>: <%= $referring_cust_main->name %></A>
+ <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>
+ </TD>
+ </TR>
<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<%= $cust_main->referral_custnum %>">
<% } elsif ( ! $conf->exists('disable_customer_referrals') ) { %>
- <BR><BR>Referring customer number:
- <INPUT TYPE="text" NAME="referral_custnum" VALUE="">
+ <TR>
+ <TD ALIGN="right">Referring customer</TD>
+ <TD>
+ <!-- <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> -->
+ <%= include('/elements/search-cust_main.html',
+ 'field_name' => 'referral_custnum',
+ )
+ %>
+ </TD>
+ </TR>
<% } else { %>
@@ -168,6 +156,8 @@ if ( $cust_main->referral_custnum
<% } %>
+</TABLE>
+
<!-- contact info -->
<BR><BR>
@@ -377,10 +367,10 @@ unless ( $custnum ) {
#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
- my($agent)=qsearchs('agent',{'agentnum'=> $agentnum });
- $pkgpart = $agent->pkgpart_hashref;
+ $pkgpart = $agents[0]->pkgpart_hashref;
} else {
#can't know (agent not chosen), so, allow all
my %typenum;
diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi
index a03a245eb..e7734c1fc 100755
--- a/httemplate/edit/cust_pay.cgi
+++ b/httemplate/edit/cust_pay.cgi
@@ -9,22 +9,20 @@ my %payby = (
'MCRD' => 'Manual credit card',
);
-my($link, $linknum, $paid, $payby, $payinfo, $quickpay, $_date);
+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');
- $quickpay = $cgi->param('quickpay');
$_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time;
} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
- $link = 'custnum';
+ $link = $cgi->param('popup') ? 'popup' : 'custnum';
$linknum = $1;
$paid = '';
$payby = $cgi->param('payby') || 'BILL';
$payinfo = '';
- $quickpay = $cgi->param('quickpay');
$_date = time;
} elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
$link = 'invnum';
@@ -32,7 +30,6 @@ if ( $cgi->param('error') ) {
$paid = '';
$payby = $cgi->param('payby') || 'BILL';
$payinfo = "";
- $quickpay = '';
$_date = time;
} else {
die "illegal query ". $cgi->keywords;
@@ -43,9 +40,15 @@ 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, '') %>
+<%= include("/elements/header.html", $title, '') %>
+
+<% } %>
<% if ( $cgi->param('error') ) { %>
<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
@@ -60,7 +63,6 @@ $title .= " against Invoice #$linknum" if $link eq 'invnum';
<FORM ACTION="<%= popurl(1) %>process/cust_pay.cgi" METHOD=POST>
<INPUT TYPE="hidden" NAME="link" VALUE="<%= $link %>">
<INPUT TYPE="hidden" NAME="linknum" VALUE="<%= $linknum %>">
-<INPUT TYPE="hidden" NAME="quickpay" VALUE="<%= $quickpay %>">
<%
my $money_char = $conf->config('money_char') || '$';
@@ -74,7 +76,9 @@ if ( $link eq 'invnum' ) {
}
%>
+<% unless ( $link eq 'popup' ) { %>
<%= small_custview($custnum, $conf->config('countrydefault')) %>
+<% } %>
<INPUT TYPE="hidden" NAME="payby" VALUE="<%= $payby %>">
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index f79cc0b24..c40a00492 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -15,7 +15,9 @@
# 'fields' => [
# 'columname',
# { 'field' => 'another_columname',
- # 'type' => 'text', #text, fixed, hidden
+ # 'type' => 'text', #text, fixed, hidden, checkbox
+ # #eventually more for <SELECT>, etc.
+ # 'value' => 'Y', #only for checkbox
# },
# ]
#
@@ -150,14 +152,17 @@
%>
</TD>
- <%
- #eventually more options for <SELECT>, etc. fields
- if ( $type eq 'fixed' ) {
- %>
+ <% if ( $type eq 'fixed' ) { %>
<TD BGCOLOR="#dddddd"><%= $f->{'value'} %></TD>
<INPUT TYPE="hidden" NAME="<%= $field %>" VALUE="<%= $f->{'value'} %>">
+ <% } elsif ( $type eq 'checkbox' ) { %>
+
+ <TD>
+ <INPUT TYPE="checkbox" NAME="<%= $field %>" VALUE="<%= $f->{'value'} %>" <%= $object->$field() eq $f->{'value'} ? ' CHECKED' : '' %>>
+ </TD>
+
<% } else { %>
<TD>
diff --git a/httemplate/edit/part_referral.cgi b/httemplate/edit/part_referral.cgi
deleted file mode 100755
index dce1e6394..000000000
--- a/httemplate/edit/part_referral.cgi
+++ /dev/null
@@ -1,44 +0,0 @@
-<%
-
-my $part_referral;
-if ( $cgi->param('error') ) {
- $part_referral = new FS::part_referral ( {
- map { $_, scalar($cgi->param($_)) } fields('part_referral')
- } );
-} elsif ( $cgi->keywords ) {
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/;
- $part_referral = qsearchs( 'part_referral', { 'refnum' => $1 } );
-} else { #adding
- $part_referral = new FS::part_referral {};
-}
-my $action = $part_referral->refnum ? 'Edit' : 'Add';
-my $hashref = $part_referral->hashref;
-
-my $p1 = popurl(1);
-
-%><%= include('/elements/header.html', "$action Advertising source", menubar(
- 'Main Menu' => popurl(2),
- 'View all advertising sources' => popurl(2). "browse/part_referral.cgi",
-)) %>
-
-<% if ( $cgi->param('error') ) { %>
- <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
-<% } %>
-
-<FORM ACTION="<%= $p1 %>process/part_referral.cgi" METHOD=POST>
-
-<INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $hashref->{refnum} %>">
-
-<%
-#print "Referral #", $hashref->{refnum} ? $hashref->{refnum} : "(NEW)";
-%>
-
-Advertising source <INPUT TYPE="text" NAME="referral" SIZE=32 VALUE="<%= $hashref->{referral} %>">
-
-<BR>
-<INPUT TYPE="submit" VALUE="<%= $hashref->{refnum} ? "Apply changes" : "Add advertising source" %>">
-
-</FORM>
-
-<%= include('/elements/footer.html') %>
diff --git a/httemplate/edit/part_referral.html b/httemplate/edit/part_referral.html
new file mode 100755
index 000000000..ec0f32f58
--- /dev/null
+++ b/httemplate/edit/part_referral.html
@@ -0,0 +1,9 @@
+<%= include( 'elements/edit.html',
+ 'name' => 'Advertising source',
+ 'table' => 'part_referral',
+ 'fields' => [ 'referral' ],
+ 'labels' => { 'referral' => 'Advertising source' },
+ 'viewall_dir' => 'browse',
+ 'html_table_bottom' => include('/elements/tr-select-agent.html'),
+ )
+%>
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index 09a42544c..4ba30c435 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -103,8 +103,6 @@ if ( $new->custnum eq '' ) {
'popnum' => $cgi->param('popnum'),
} );
- my $y = $svc_acct->setdefault; # arguably should be in new method
- $error ||= $y unless ref($y);
#and just in case you were silly
$svc_acct->svcpart($svcpart);
$svc_acct->username($cgi->param('username'));
diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi
index 87d6011e7..cecccb59e 100755
--- a/httemplate/edit/process/cust_pay.cgi
+++ b/httemplate/edit/process/cust_pay.cgi
@@ -4,15 +4,16 @@ $cgi->param('linknum') =~ /^(\d+)$/
or die "Illegal linknum: ". $cgi->param('linknum');
my $linknum = $1;
-$cgi->param('link') =~ /^(custnum|invnum)$/
+$cgi->param('link') =~ /^(custnum|invnum|popup)$/
or die "Illegal link: ". $cgi->param('link');
-my $link = $1;
+my $field = my $link = $1;
+$field = 'custnum' if $field eq 'popup';
my $_date = str2time($cgi->param('_date'));
my $new = new FS::cust_pay ( {
- $link => $linknum,
- _date => $_date,
+ $field => $linknum,
+ _date => $_date,
map {
$_, scalar($cgi->param($_));
} qw(paid payby payinfo paybatch)
@@ -24,19 +25,30 @@ my $error = $new->insert;
if ($error) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). 'cust_pay.cgi?'. $cgi->query_string );
-} elsif ( $link eq 'invnum' ) {
+} elsif ( $field eq 'invnum' ) {
print $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum");
-} elsif ( $link eq 'custnum' ) {
+} 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 ( $cgi->param('quickpay') eq 'yes' ) {
- print $cgi->redirect(popurl(3). "search/cust_main-quickpay.html");
- } else {
+ 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";
}
+
}
%>
diff --git a/httemplate/edit/process/part_referral.cgi b/httemplate/edit/process/part_referral.cgi
deleted file mode 100755
index fd2c01506..000000000
--- a/httemplate/edit/process/part_referral.cgi
+++ /dev/null
@@ -1,28 +0,0 @@
-<%
-
-my $refnum = $cgi->param('refnum');
-
-my $new = new FS::part_referral ( {
- map {
- $_, scalar($cgi->param($_));
- } fields('part_referral')
-} );
-
-my $error;
-if ( $refnum ) {
- my $old = qsearchs( 'part_referral', { 'refnum' =>$ refnum } );
- die "(Old) Record not found!" unless $old;
- $error = $new->replace($old);
-} else {
- $error = $new->insert;
-}
-$refnum=$new->refnum;
-
-if ( $error ) {
- $cgi->param('error', $error);
- print $cgi->redirect(popurl(2). "part_referral.cgi?". $cgi->query_string );
-} else {
- print $cgi->redirect(popurl(3). "browse/part_referral.cgi");
-}
-
-%>
diff --git a/httemplate/edit/process/part_referral.html b/httemplate/edit/process/part_referral.html
new file mode 100755
index 000000000..0b5d959a0
--- /dev/null
+++ b/httemplate/edit/process/part_referral.html
@@ -0,0 +1,5 @@
+<%= include( 'elements/process.html',
+ 'table' => 'part_referral',
+ 'viewall_dir' => 'browse',
+ )
+%>
diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi
index 4b324a501..71b324d99 100755
--- a/httemplate/edit/svc_acct.cgi
+++ b/httemplate/edit/svc_acct.cgi
@@ -69,7 +69,20 @@ unless ( $svcnum || $cgi->param('error') ) { #adding
}
$svc_acct->set_default_and_fixed( {
- 'usergroup' => sub { @groups = split(',', shift ); },
+ #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 = ();
+ [];
+ }
+ }
} );
}