summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Schema.pm8
-rw-r--r--FS/FS/prospect_main.pm9
-rw-r--r--httemplate/edit/elements/edit.html1
-rw-r--r--httemplate/edit/prospect_main.html47
-rw-r--r--httemplate/elements/radio.html19
-rw-r--r--httemplate/elements/tr-radio.html21
-rw-r--r--httemplate/search/prospect_main.html2
-rw-r--r--httemplate/view/prospect_main.html26
8 files changed, 110 insertions, 23 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 2bfe11a08..6d4fb03d9 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -982,12 +982,14 @@ sub tables_hashref {
'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
diff --git a/FS/FS/prospect_main.pm b/FS/FS/prospect_main.pm
index 78e865a7e..079ad2561 100644
--- a/FS/FS/prospect_main.pm
+++ b/FS/FS/prospect_main.pm
@@ -203,7 +203,7 @@ sub check {
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;
@@ -216,7 +216,12 @@ sub check {
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
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 975f8fb65..1ed75c3ef 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -379,6 +379,7 @@ Example:
% $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;
diff --git a/httemplate/edit/prospect_main.html b/httemplate/edit/prospect_main.html
index 4495cab29..ab01930e5 100644
--- a/httemplate/edit/prospect_main.html
+++ b/httemplate/edit/prospect_main.html
@@ -13,10 +13,15 @@
'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',
@@ -35,8 +40,10 @@
],
'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>
@@ -103,6 +110,9 @@ my $new_callback = sub {
}
+ #config to default to commercial and/or disable residential when someone needs
+ $prospect_main->set('residential_commercial', 'Residential');
+
};
my $edit_callback = sub {
@@ -115,6 +125,12 @@ 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 {
@@ -124,6 +140,13 @@ 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 {
@@ -154,4 +177,18 @@ 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>
diff --git a/httemplate/elements/radio.html b/httemplate/elements/radio.html
new file mode 100644
index 000000000..9af533246
--- /dev/null
+++ b/httemplate/elements/radio.html
@@ -0,0 +1,19 @@
+<% $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>
diff --git a/httemplate/elements/tr-radio.html b/httemplate/elements/tr-radio.html
new file mode 100644
index 000000000..b5a2afaf1
--- /dev/null
+++ b/httemplate/elements/tr-radio.html
@@ -0,0 +1,21 @@
+% 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>
+
diff --git a/httemplate/search/prospect_main.html b/httemplate/search/prospect_main.html
index 12e3e1812..328d1202f 100644
--- a/httemplate/search/prospect_main.html
+++ b/httemplate/search/prospect_main.html
@@ -8,7 +8,7 @@
'Contact(s)',
],
'fields' => [ 'prospectnum',
- 'company',
+ 'name',
sub {
my $pm = shift;
[ map {
diff --git a/httemplate/view/prospect_main.html b/httemplate/view/prospect_main.html
index f4b2f58ee..d92d27097 100644
--- a/httemplate/view/prospect_main.html
+++ b/httemplate/view/prospect_main.html
@@ -23,10 +23,12 @@
</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>
@@ -58,14 +60,14 @@
% if ( $curuser->access_right('Qualify service') ) {
<% include( '/elements/popup_link-prospect_main.html',
- 'action' => $p. 'misc/qual.html',
- 'label' => 'New&nbsp;Qualification',
- 'actionlabel' => 'New Qualification',
- 'color' => '#333399',
- 'prospect_main' => $prospect_main,
- 'closetext' => 'Close',
- 'width' => 763,
- 'height' => 436,
+ 'action' => $p. 'misc/qual.html',
+ 'label' => 'New&nbsp;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>