more flexible package suspend/unsuspend fees, #26828
[freeside.git] / httemplate / edit / reason.html
1 <& elements/edit.html,
2   'menubar'=> [ "View all $classname Reasons" => 
3                   $p.'browse/reason.html?class='.$class,
4                 "View $classname Reason Types" =>
5                   $p.'browse/reason_type.html?class='.$class,
6               ],
7   'name'   => ucfirst($classname) . ' Reason',
8   
9   'table'  => 'reason',
10   'labels' => { 
11                 'reasonnum'   => $classname .  ' Reason',
12                 'reason_type' => $classname . ' Reason type',
13                 'reason'      => $classname . ' Reason',
14                 'disabled'    => 'Disabled',
15                 'class'       => '',
16                 'feepart'     => 'Charge a suspension fee',
17                 'fee_on_unsuspend'  => 'When a package is',
18                 'fee_hold'          => 'Delay fee until next bill',
19                 'unused_credit'     => 'Credit unused portion of service',
20                 'unsuspend_pkgpart' => 'Order an unsuspension package',
21                 'unsuspend_hold'    => 'Delay package until next bill',
22               },
23   'fields' => \@fields,
24 &>
25 <%init>
26
27 die "access denied"
28   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
29
30 $cgi->param('class') =~ /^(\w)$/ or die "illegal class";
31 my $class=$1;
32
33 my $classname = ucfirst($FS::reason_type::class_name{$class});
34
35 my (@types) = qsearch( 'reason_type', { 'class' => $class } );
36
37 unless (scalar(@types)) {
38   print $cgi->redirect( "reason_type.html?class=$class" );
39 }
40
41 my @fields = (
42   { 'field' => 'reason_type',
43     'type'  => 'select-table',
44     'table' => 'reason_type',
45     'name_col'  => 'type',
46     'value_col' => 'typenum',
47     'hashref'   => { 'class' => $class },
48     'disable_empty' => 1,
49 #     #then fix tr-select.html
50 #
51 #    'value' => { 'vcolumn' => 'typenum',
52 #                 'ccolumn' => 'type',
53 #             'values'  => \@types,
54 #           },
55 #     # that wasn't so hard...did this do something else that I'm missing?
56   },
57   'reason',
58   { 'field' => 'class',
59     'type'  => 'hidden',
60     'value' => $class,
61   },
62   { 'field' => 'disabled',
63     'type'  => 'checkbox',
64     'value' => 'Y'
65   },
66 );
67
68 if ( $class eq 'S' ) {
69   push @fields,
70     { 'field'     => 'unused_credit',
71       'type'      => 'checkbox',
72       'value'     => 'Y',
73     }, 
74     { 'type' => 'tablebreak-tr-title' },
75     { 'field'     => 'feepart',
76       'type'      => 'select-table',
77       'table'     => 'part_fee',
78       'hashref'   => { disabled => '' },
79       'name_col'  => 'itemdesc',
80       'value_col' => 'feepart',
81       'empty_label' => 'none',
82     },
83     { 'field'     => 'fee_on_unsuspend',
84       'type'      => 'select',
85       'options'   => [ '', 'Y' ],
86       'labels'    => { '' => 'suspended', 'Y' => 'unsuspended' },
87     },
88     { 'field'     => 'fee_hold',
89       'type'      => 'checkbox',
90       'value'     => 'Y',
91     },
92     { 'field'     => 'unsuspend_pkgpart',
93       'type'      => 'select-part_pkg',
94       'hashref'   => { 'disabled' => '',
95                        'freq'     => 0 }, # one-time charges only
96     },
97     { 'field'     => 'unsuspend_hold',
98       'type'      => 'checkbox',
99       'value'     => 'Y',
100     },
101   ;
102 }
103
104 </%init>