RT# 74665 - set a default close date if global config quotation_disable_after_days...
authorChristopher Burger <burgerc@freeside.biz>
Thu, 6 Apr 2017 13:09:57 +0000 (09:09 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Thu, 6 Apr 2017 13:09:57 +0000 (09:09 -0400)
httemplate/edit/quotation.html

index 3cedef8..8c9fce1 100644 (file)
@@ -17,7 +17,7 @@
                    { field=>'prospectnum',           type=>'fixed-prospect_main' },
                    { field=>'custnum',               type=>'fixed-cust_main' },
                    { field=>'_date',                 type=>'fixed-date' },
-                   { field=>'close_date',            type=>'input-date-field' },
+                   { field=>'close_date',            type=>'input-date-field', value=>'30' },
                    { field=>'confidence',            type=>'text', size=>3, postfix=>'%' },
                    { field=>'quotation_description', type=>'text', size=>50 },
                    ($can_disable ? { field=>'disabled', type=>'checkbox', value=>'Y'} : ()),
@@ -28,6 +28,9 @@
                                            foreach qw( prospectnum custnum );
                                          $quotation->_date(time);
                                        },
+                 'field_callback' => sub { my( $cgi, $quotation, $field_hashref ) = @_;
+                                         $quotation->close_date(($default_close_days * 86400) + time) if !$quotation->close_date && $default_close_days; 
+                                       },
            )
 %>
 <%init>
@@ -37,4 +40,8 @@ die "access denied"
 
 my $can_disable = $FS::CurrentUser::CurrentUser->access_right('Disable quotation');
 
+my $conf = new FS::Conf;
+
+my $default_close_days ||= $conf->config('quotation_disable_after_days');
+
 </%init>