RT# 74665 - set a default close date if global config quotation_disable_after_days...
[freeside.git] / httemplate / edit / quotation.html
1 <% include( 'elements/edit.html',
2                  'name'    => 'Quotation',
3                  'table'   => 'quotation',
4                  'menubar' => [],
5                  'labels'  => { 
6                                 'quotationnum'          => 'Quotation number',
7                                 'prospectnum'           => 'Prospect',
8                                 'custnum'               => 'Customer',
9                                 '_date'                 => 'Date',
10                                 'close_date'            => 'Close Date',
11                                 'confidence'            => 'Confidence',
12                                 'quotation_description' => 'Description',
13                                 ($can_disable ? ('disabled'     => 'Disabled') : ()),
14                               },
15                  'fields'  => [
16                    { field=>'prospectnum',           type=>'fixed-prospect_main' },
17                    { field=>'custnum',               type=>'fixed-cust_main' },
18                    { field=>'_date',                 type=>'fixed-date' },
19                    { field=>'quotation_description', type=>'text', size=>50 },
20                    { field=>'close_date',            type=>'input-date-field', value=>'30' },
21                    { field=>'confidence',            type=>'text', size=>3, postfix=>'%' },
22                    ($can_disable ? { field=>'disabled', type=>'checkbox', value=>'Y'} : ()),
23                               ],
24                  #XXX some way to disable the "view all"
25                  'new_callback' => sub { my( $cgi, $quotation) = @_;
26                                          $quotation->$_( $cgi->param($_) )
27                                            foreach qw( prospectnum custnum );
28                                          $quotation->_date(time);
29                                        },
30                  'field_callback' => sub { my( $cgi, $quotation, $field_hashref ) = @_;
31                                          $quotation->close_date(($default_close_days * 86400) + time) if !$quotation->close_date && $default_close_days; 
32                                        },
33            )
34 %>
35 <%init>
36
37 die "access denied"
38   unless $FS::CurrentUser::CurrentUser->access_right('Generate quotation');
39
40 my $can_disable = $FS::CurrentUser::CurrentUser->access_right('Disable quotation');
41
42 my $conf = new FS::Conf;
43
44 my $default_close_days ||= $conf->config('quotation_disable_after_days');
45
46 </%init>