'columns' => [
'prospectnum', 'serial', '', '', '', '',
'agentnum', 'int', '', '', '', '',
- 'company', 'varchar', '', $char_d, '', '',
- #'disabled', 'char', 'NULL', 1, '', '',
+ 'company', 'varchar', 'NULL', $char_d, '', '',
+ 'add_date', @date_type, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ 'custnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'prospectnum',
'unique' => [],
- 'index' => [ [ 'company' ], [ 'agentnum' ], ],
+ 'index' => [ [ 'company' ], [ 'agentnum' ], [ 'disabled' ] ],
},
#eventually use for billing & ship from cust_main too
my $error =
$self->ut_numbern('prospectnum')
|| $self->ut_foreign_key('agentnum', 'agent', 'agentnum' )
- || $self->ut_text('company')
+ || $self->ut_textn('company')
;
return $error if $error;
sub name {
my $self = shift;
- $self->company; #at least until this is nullable
+ return $self->company if $self->company;
+
+ my $contact = ($self->contact)[0]; #first contact? good enough for now
+ return $contact->line if $contact;
+
+ $self->prospectnum;
}
=item contact
% $g_row = 1 if $type eq 'tablebreak-tr-title';
% $g_row++;
% $g_row++ if $type eq 'title';
+% $g_row += scalar( @{ $f->{options} } )-1 if $type eq 'radio';
% } else {
% if ( $type eq 'columnstart' ) {
% push @g_row_stack, $g_row;
'empty_label' => 'Select agent',
'colspan' => 6,
},
- { 'field' => 'company',
- 'type' => 'text',
- 'size' => 50,
- 'colspan' => 6,
+ { 'field' => 'residential_commercial',
+ 'type' => 'radio',
+ 'options' => [ 'Residential', 'Commercial', ],
+ 'onchange' => 'rescom_changed',
+ },
+ { 'field' => 'company',
+ 'type' => 'text',
+ 'size' => 50,
+ 'colspan' => 6,
},
{ 'field' => 'contactnum',
'type' => 'contact',
],
'new_callback' => $new_callback,
'edit_callback' => $edit_callback,
- 'error_callbacck' => $error_callback,
+ 'error_callback' => $error_callback,
'agent_virt' => 1,
+ 'html_bottom' => $javascript,
+ 'body_etc' => 'onLoad="rescom_changed()"',
)
%>
<%init>
}
+ #config to default to commercial and/or disable residential when someone needs
+ $prospect_main->set('residential_commercial', 'Residential');
+
};
my $edit_callback = sub {
$prospect_main->set('locationnum', $cust_location[0]->locationnum)
if scalar(@cust_location);
#warn 'prospect_main.locationnum '.$prospect_main->get('locationnum');
+
+ $prospect_main->set('residential_commercial',
+ length($prospect_main->company)
+ ? 'Commercial'
+ : 'Residential'
+ );
};
my $error_callback = sub {
or die 'illegal locationnum '. $cgi->param('locationnum');
my $locationnum = $1;
$prospect_main->set('locationnum', $locationnum);
+
+ $prospect_main->set('residential_commercial',
+ ($cgi->param('residential_commercial') eq 'Commercial')
+ ? 'Commercial'
+ : 'Residential'
+ );
+
};
my $m2_error_callback = sub {
#my @agentnums = $FS::CurrentUser::CurrentUser->agentnums;
+my $javascript = <<END;
+ <SCRIPT TYPE="text/javascript">
+ function rescom_changed() {
+ var f = document.edit_topform;
+ var c = f.company;
+ if ( f.residential_commercial_Residential.checked ) {
+ c.disabled = true;
+ } else if ( f.residential_commercial_Commercial.checked ) {
+ c.disabled = false;
+ }
+ }
+ </SCRIPT>
+END
+
</%init>
--- /dev/null
+<% $opt{'prefix'} %><INPUT TYPE = "radio"
+ NAME = "<% $opt{field} %>"
+ ID = "<% $opt{id}.'_'.$opt{value} %>"
+ VALUE = "<% $opt{value} %>"
+ <% $opt{curr_value} eq $opt{value}
+ ? ' CHECKED'
+ : ''
+ %>
+ <% $onchange %>
+ ><% $opt{'postfix'} %>
+<%init>
+
+my %opt = @_;
+
+my $onchange = $opt{'onchange'}
+ ? 'onChange="'. $opt{'onchange'}. '(this)"'
+ : '';
+
+</%init>
--- /dev/null
+% foreach my $option ( @{ $opt{options} } ) { #just arrayref for now
+
+ <% include('tr-td-label.html', @_, label=> $labels->{$option} || $option ) %>
+
+ <TD <% $style %>>
+ <% include('radio.html', @_, value=> $option ) %>
+ </TD>
+
+ </TR>
+
+% }
+<%init>
+
+my %opt = @_;
+
+my $labels = $opt{'option_labels'} || $opt{'labels'};
+
+my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+</%init>
+
'Contact(s)',
],
'fields' => [ 'prospectnum',
- 'company',
+ 'name',
sub {
my $pm = shift;
[ map {
</TR>
%}
-<TR>
- <TD ALIGN="right">Company</TD>
- <TD BGCOLOR="#FFFFFF"><B><% $prospect_main->company |h %></B></TD>
-</TR>
+% if ( $prospect_main->company ) {
+ <TR>
+ <TD ALIGN="right">Company</TD>
+ <TD BGCOLOR="#FFFFFF"><B><% $prospect_main->company |h %></B></TD>
+ </TR>
+% }
% foreach my $contact ( $prospect_main->contact ) {
<TR>
% if ( $curuser->access_right('Qualify service') ) {
<% include( '/elements/popup_link-prospect_main.html',
- 'action' => $p. 'misc/qual.html',
- 'label' => 'New Qualification',
- 'actionlabel' => 'New Qualification',
- 'color' => '#333399',
- 'prospect_main' => $prospect_main,
- 'closetext' => 'Close',
- 'width' => 763,
- 'height' => 436,
+ 'action' => $p. 'misc/qual.html',
+ 'label' => 'New Qualification',
+ 'actionlabel' => 'New Qualification',
+ 'color' => '#333399',
+ 'prospect_main' => $prospect_main,
+ 'closetext' => 'Close',
+ 'width' => 763,
+ 'height' => 436,
)
%>
| <A HREF="<%$p%>search/qual.cgi?prospectnum=<% $prospect_main->prospectnum %>">View Qualifications</A>