more contact-aware new customer screen, RT#16819
[freeside.git] / httemplate / edit / cust_main / top_misc.html
1 <TABLE CLASS="fsinnerbox">
2
3 <TR>
4   <TD ALIGN="right">Residential</TD>
5   <TD><INPUT TYPE     = "radio"
6              NAME     = "residential_commercial"
7              ID       = "residential_commercial_Residential"
8              VALUE    = "Residential"
9              onChange = "rescom_changed(this)"
10        <% $cust_main->residential_commercial eq 'Commercial' ? '' : 'CHECKED' %>
11   ></TD>
12 </TR>
13 <TR>
14   <TD ALIGN="right">Commercial</TD>
15   <TD><INPUT TYPE     = "radio"
16              NAME     = "residential_commercial"
17              ID       = "residential_commercial_Commercial"
18              VALUE    = "Commercial"
19              onChange = "rescom_changed(this)"
20        <% $cust_main->residential_commercial eq 'Commercial' ? 'CHECKED' : '' %>
21   ></TD>
22 </TR>
23
24 <SCRIPT TYPE="text/javascript">
25   function rescom_changed() {
26     var f = document.CustomerForm;
27
28     if        ( f.residential_commercial_Residential.checked ) {
29       document.getElementById('contacts_div').style.display = 'none';
30     } else { // if ( f.residential_commercial_Commercial.checked ) {
31       document.getElementById('contacts_div').style.display = '';
32     }
33
34     if        ( f.residential_commercial_Residential.checked && ! f.company.value.length ) {
35       document.getElementById('company_row').style.display = 'none'
36     } else { // if ( f.residential_commercial_Commercial.checked ) {
37       document.getElementById('company_row').style.display = '';
38     }
39
40     if        ( f.residential_commercial_Residential.checked && ! f.ship_company.value.length ) {
41       document.getElementById('ship_company_row').style.display = 'none'
42     } else { // if ( f.residential_commercial_Commercial.checked ) {
43       document.getElementById('ship_company_row').style.display = '';
44     }
45   }
46 </SCRIPT>
47
48 % foreach my $field ($cust_main->virtual_fields) {
49     <% $cust_main->pvf($field)->widget('HTML', 'edit',$cust_main->getfield($field)) %>
50 % }
51
52 %# tags
53 <& /elements/tr-select-cust_tag.html,
54              'custnum' => $custnum,
55              'cgi'     => $cgi,
56 &>
57
58 %# agent
59 % if ( $cgi->param('lock_agentnum') =~ /^(\d+)$/ && $curuser->agentnum($1) ) {
60 %
61 %   my $agentnum = $1;
62 %   $cust_main->agentnum($agentnum);
63
64     <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
65     <INPUT TYPE="hidden" NAME="agentnum"      VALUE="<% $agentnum %>">
66     <TR>
67       <TD ALIGN="right"><% mt('Agent') |h %></TD>
68       <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
69     </TR>
70  
71 % } else {
72
73   <& /elements/tr-select-agent.html, 
74                 'curr_value'    => $cust_main->agentnum,
75                 'label'         => "<B>${r}".emt('Agent')."</B>",
76                 'empty_label'   => emt('Select agent'),
77                 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
78                 'viewall_right' => emt('None'), 
79   &>
80
81 % }
82
83 %# agent_custid
84 % if ( $conf->exists('cust_main-edit_agent_custid') ) {
85
86     <TR>
87       <TD ALIGN="right"><% mt('Customer identifier') |h %></TD>
88       <TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
89     </TR>
90
91 % } else {
92
93     <INPUT TYPE="hidden" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>">
94
95 % }
96
97 %# class
98 <& /elements/tr-select-cust_class.html,
99              'curr_value'  => $cust_main->classnum,
100              'label'       => emt("Class"),
101 &>
102
103 %# referral (advertising source)
104 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
105 %if ( $custnum && ! $conf->exists('editreferrals') ) {
106
107   <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
108
109 % } else { 
110
111    <& /elements/tr-select-part_referral.html,
112                 'curr_value' => $refnum
113    &>
114 % } 
115
116
117 %# referring customer
118 %my $referring_cust_main = '';
119 %if ( $cust_main->referral_custnum
120 %     and $referring_cust_main =
121 %           qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
122 %     and ! $curuser->access_right('Edit referring customer')
123 %) {
124
125   <TR>
126     <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
127     <TD>
128       <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name %></A>
129     </TD>
130   </TR>
131   <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
132
133 % } elsif ( ! $conf->exists('disable_customer_referrals') ) { 
134
135   <TR>
136     <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
137     <TD>
138       <& /elements/search-cust_main.html,
139                     'field_name' => 'referral_custnum',
140                     'curr_value' => $cust_main->referral_custnum,
141       &>
142     </TD>
143   </TR>
144
145 % } else { 
146   <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
147 % } 
148
149 %# signup date
150 % if ( $conf->exists('cust_main-edit_signupdate') ) {
151     <& /elements/tr-input-date-field.html, {
152                   'name'        => 'signupdate',
153                   'value'       => $cust_main->signupdate,
154                   'label'       => emt('Signup date'),
155                   'format'      => ( $conf->config('date_format') || "%m/%d/%Y" ),
156               }
157     &>
158 % }
159
160 % # permission to edit ticket subjects
161 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
162   <TR>
163     <TD ALIGN="right">
164       <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <% 
165         $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
166     <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
167   </TR>
168 % } else {
169   <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
170 % }
171
172 % # permission to edit
173 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
174   <TR>
175     <TD ALIGN="right">
176       <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <% 
177         $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
178     <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
179   </TR>
180 % } else {
181   <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
182 % }
183
184 </TABLE>
185
186 <%init>
187
188 my( $cust_main, %opt ) = @_;
189
190 my $custnum = $opt{'custnum'};
191
192 if ( $cgi->param('error') ) {
193   $cust_main->set('residential_commercial',
194     ($cgi->param('residential_commercial') eq 'Commercial')
195       ? 'Commercial'
196       : 'Residential'
197   );
198 } elsif ( $custnum ) { #editing
199   $cust_main->set('residential_commercial',
200     length($cust_main->company)
201       ? 'Commercial'
202       : 'Residential'
203   );
204 } else { #new customer
205   #config to default to commercial and/or disable residential when someone needs
206   $cust_main->set('residential_commercial', 'Residential');
207 }
208
209 my $conf = new FS::Conf;
210
211 my $curuser = $FS::CurrentUser::CurrentUser;
212
213 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
214
215 </%init>