X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_main.cgi;h=c3d1804bcf53741e64f0be9980f9c9cb66e83047;hb=b19897e1db4c110d7d7e8b52800cda5ab58ce9e0;hp=d10b21a4a7b7423e9d026c524f8dbfc1b60ba7a4;hpb=9e342300c380e29af1b9678f1a9604609e0061b6;p=freeside.git diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index d10b21a4a..c3d1804bc 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -35,6 +35,7 @@ if ( $cgi->param('error') ) { $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+)$/; @@ -63,100 +64,100 @@ if ( $cgi->param('error') ) { @invoicing_list = (); } $cgi->delete_all(); + my $action = $custnum ? 'Edit' : 'Add'; +$action .= ": ". $cust_main->name if $custnum; + +my $r = qq!* !; %> -<%= header("Customer $action", '', ' onUnload="myclose()"') %> +<%= include('/elements/header.html', + "Customer $action", + '', + ' onUnload="myclose()"' +) %> <% if ( $error ) { %> -Error: <%= $error %> +Error: <%= $error %>

<% } %>
-Customer # <%= $custnum ? "$custnum" : " (NEW)" %> - - - -<% +<% if ( $custnum ) { %> + Customer #<%= $custnum %> - + + <%= ucfirst($cust_main->status) %> + +

+<% } %> -my $r = qq!* !; +<%= &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 + +<%= include('/elements/tr-select-agent.html', $cust_main->agentnum, + 'label' => "${r}Agent", + 'empty_label' => 'Select agent', + ) %> -<% if ( scalar(@agents) == 1 ) { %> - -<% } else { %> -

<%=$r%>Agent -<% } %> + <% +my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; +if ( $custnum && ! $conf->exists('editreferrals') ) { +%> -# (referral and referring customer still need to be "template"ized) + -#referral +<% } else { %> -my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0; -if ( $custnum && ! $conf->exists('editreferrals') ) { - print qq!!; -} 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; - print qq!!; - } else { - print qq!

${r}Advertising source "; - } -} + <%= include('/elements/tr-select-part_referral.html') %> -#referring customer +<% } %> -#print qq!

Referring Customer: !; + + +<% my $referring_cust_main = ''; if ( $cust_main->referral_custnum and $referring_cust_main = qsearchs('cust_main', { custnum => $cust_main->referral_custnum } ) ) { - print '

Referring Customer: '. - $cust_main->referral_custnum. ': '. - ( $referring_cust_main->company - || $referring_cust_main->last. ', '. $referring_cust_main->first ). - ''; -} elsif ( ! $conf->exists('disable_customer_referrals') ) { - print '

Referring customer number: '; -} else { - print ''; -} - %> + + Referring customer + + <%= $cust_main->referral_custnum %>: <%= $referring_cust_main->name %> + + + + +<% } elsif ( ! $conf->exists('disable_customer_referrals') ) { %> + + + Referring customer + + + <%= include('/elements/search-cust_main.html', + 'field_name' => 'referral_custnum', + ) + %> + + + +<% } else { %> + + + +<% } %> + + +

@@ -227,7 +228,10 @@ Service address -<%= include('cust_main/billing.html', $cust_main ) %> +<%= include( 'cust_main/billing.html', $cust_main, + 'invoicing_list' => \@invoicing_list, + ) +%> @@ -334,9 +340,11 @@ function copyelement(from, to) { 'payname', 'exp_month', 'exp_year', 'paycvv', 'paystart_month', 'paystart_year', 'payissue', 'payip', + 'paid', 'tax', - 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX' + 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX', + 'spool_cdr' ) { %> @@ -359,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; @@ -379,49 +387,66 @@ unless ( $custnum ) { if ( @part_pkg ) { -# print "

First package", &itable("#cccccc", "0 ALIGN=LEFT"), -#apiabuse & undesirable wrapping - print "
First package", &ntable("#cccccc"), - qq! +