From 8b70832328eb02dc9253dab7b436c6479b588162 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Wed, 2 Mar 2016 15:11:04 -0600 Subject: [PATCH] RT#38733: Sales forecasting using quotes --- FS/FS/Schema.pm | 2 ++ FS/FS/quotation.pm | 9 +++++++++ httemplate/edit/process/quotation.html | 4 ++++ httemplate/edit/quotation.html | 10 ++++++++-- httemplate/search/quotation.html | 12 +++++++++++- httemplate/view/quotation.html | 31 +++++++++++++++++++++++++++++-- 6 files changed, 63 insertions(+), 5 deletions(-) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 3d271b78b..33fea0209 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1909,6 +1909,8 @@ sub tables_hashref { '_date', @date_type, '', '', 'disabled', 'char', 'NULL', 1, '', '', 'usernum', 'int', 'NULL', '', '', '', + 'close_date', @date_type, '', '', + 'confidence', 'int', 'NULL', '', '', '', #'total', @money_type, '', '', #'quotation_term', 'varchar', 'NULL', $char_d, '', '', ], diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm index cb3d80b3a..db8b0fcb3 100644 --- a/FS/FS/quotation.pm +++ b/FS/FS/quotation.pm @@ -69,6 +69,13 @@ disabled usernum +=item close_date + +projected date when the quotation will be closed + +=item confidence + +projected confidence (expressed as integer) that quotation will close =back @@ -122,6 +129,8 @@ sub check { || $self->ut_numbern('_date') || $self->ut_enum('disabled', [ '', 'Y' ]) || $self->ut_numbern('usernum') + || $self->ut_numbern('close_date') + || $self->ut_numbern('confidence') ; return $error if $error; diff --git a/httemplate/edit/process/quotation.html b/httemplate/edit/process/quotation.html index a69566581..1cda30f60 100644 --- a/httemplate/edit/process/quotation.html +++ b/httemplate/edit/process/quotation.html @@ -8,4 +8,8 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Generate quotation'); +my $close_date = $cgi->param('close_date'); +$close_date = parse_datetime($close_date); +$cgi->param('close_date',$close_date); + diff --git a/httemplate/edit/quotation.html b/httemplate/edit/quotation.html index cc95d8781..437284094 100644 --- a/httemplate/edit/quotation.html +++ b/httemplate/edit/quotation.html @@ -7,13 +7,17 @@ 'prospectnum' => 'Prospect', 'custnum' => 'Customer', '_date' => 'Date', - 'disabled' => 'Disabled', + 'close_date' => 'Close Date', + 'confidence' => 'Confidence', + ($can_disable ? ('disabled' => 'Disabled') : ()), }, 'fields' => [ { field=>'prospectnum', type=>'fixed-prospect_main' }, { field=>'custnum', type=>'fixed-cust_main' }, { field=>'_date', type=>'fixed-date' }, - { field=>'disabled', type=>'checkbox', value=>'Y'}, + { field=>'close_date', type=>'input-date-field' }, + { field=>'confidence', type=>'text', size=>6 }, + ($can_disable ? { field=>'disabled', type=>'checkbox', value=>'Y'} : ()), ], #XXX some way to disable the "view all" 'new_callback' => sub { my( $cgi, $quotation) = @_; @@ -28,4 +32,6 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Generate quotation'); +my $can_disable = $FS::CurrentUser::CurrentUser->access_right('Disable quotation'); + diff --git a/httemplate/search/quotation.html b/httemplate/search/quotation.html index 55c60f0c1..2eba71cb0 100755 --- a/httemplate/search/quotation.html +++ b/httemplate/search/quotation.html @@ -15,6 +15,8 @@ emt('Date'), emt('Prospect'), emt('Customer'), + emt('Confidence'), + emt('Close date'), ], 'fields' => [ 'quotationnum', @@ -27,6 +29,10 @@ sub { my $cust_main = shift->cust_main; $cust_main ? $cust_main->name : ''; }, + 'confidence', + sub { my $quot = shift; + $quot->close_date ? time2str('%b %d %Y', $quot->close_date) : ''; + }, #\&FS::UI::Web::cust_fields, ], 'sort_fields' => [ @@ -36,8 +42,10 @@ '_date', '', '', + 'confidence', + 'close_date', ], - 'align' => 'rrrrll', #.FS::UI::Web::cust_aligns(), + 'align' => 'rrrrllrr', #.FS::UI::Web::cust_aligns(), 'links' => [ $link, $link, @@ -45,6 +53,8 @@ $link, $prospect_link, $cust_link, + $link, + $link, #( map { $_ ne 'Cust. Status' ? $cust_link : '' } # FS::UI::Web::cust_header() #), diff --git a/httemplate/view/quotation.html b/httemplate/view/quotation.html index 18625095e..484bedd04 100755 --- a/httemplate/view/quotation.html +++ b/httemplate/view/quotation.html @@ -11,20 +11,31 @@ function areyousure(href, message) { % unless ( $quotation->disabled eq 'Y' ) { +% my $inrow = 0; % if ( $curuser->access_right('Order customer package') ) { <& /elements/order_pkg_link.html, 'label' => emt('Add package'), 'actionlabel' => emt('Add package'), map { $_ => $quotation->$_ } qw( quotationnum custnum prospectnum ) &> +% $inrow++; % } % if ( $curuser->access_right('One-time charge') ) { - | <& /elements/one_time_charge_link.html, + <% $inrow ? ' | ' : '' %> + <& /elements/one_time_charge_link.html, map { $_ => $quotation->$_ } qw( quotationnum custnum prospectnum ) &> +% $inrow++; % } -

+ +% if ( $can_generate_quotation ) { + <% $inrow ? ' | ' : '' %> + Edit quotation fields +% $inrow++; +% } + + <% $inrow ? '

' : '' %> % if ( 1 ) { #if ( $curuser->access_right('Send quotations') ) @@ -76,6 +87,22 @@ function areyousure(href, message) {
<% emt('Error calculating quotation: [_1]', $error) %>
% } +% my $close_date = $quotation->close_date; +% my $confidence = $quotation->confidence; +% if ($close_date or length($confidence)) { + +% if ($close_date) { + + + + +% } +% if (length($confidence)) { + +% } +
Close Date:<% time2str($conf->config('date_format') || '%m/%d/%Y',$close_date) %>
Confidence:<% $confidence %>
+% } + % if ( $conf->exists('quotation_html') ) { <% join('', $quotation->print_html( preref_callback=>$preref_callback )) %> % } else { -- 2.11.0