Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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                 'unsuspend_pkgpart' => 'Unsuspension fee',
17                 'unsuspend_hold'    => 'Delay until next bill',
18                 'unused_credit'     => 'Credit unused portion of service',
19               },
20   'fields' => \@fields,
21 &>
22 <%init>
23
24 die "access denied"
25   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
26
27 $cgi->param('class') =~ /^(\w)$/ or die "illegal class";
28 my $class=$1;
29
30 my $classname = ucfirst($FS::reason_type::class_name{$class});
31
32 my (@types) = qsearch( 'reason_type', { 'class' => $class } );
33
34 unless (scalar(@types)) {
35   print $cgi->redirect( "reason_type.html?class=$class" );
36 }
37
38 my @fields = (
39   { 'field' => 'reason_type',
40     'type'  => 'select-table',
41     'table' => 'reason_type',
42     'name_col'  => 'type',
43     'value_col' => 'typenum',
44     'hashref'   => { 'class' => $class },
45     'disable_empty' => 1,
46 #     #then fix tr-select.html
47 #
48 #    'value' => { 'vcolumn' => 'typenum',
49 #                 'ccolumn' => 'type',
50 #             'values'  => \@types,
51 #           },
52 #     # that wasn't so hard...did this do something else that I'm missing?
53   },
54   'reason',
55   { 'field' => 'class',
56     'type'  => 'hidden',
57     'value' => $class,
58   },
59   { 'field' => 'disabled',
60     'type'  => 'checkbox',
61     'value' => 'Y'
62   },
63 );
64
65 if ( $class eq 'S' ) {
66   push @fields,
67     { 'field'     => 'unsuspend_pkgpart',
68       'type'      => 'select-part_pkg',
69       'hashref'   => { 'disabled' => '',
70                        'freq'     => 0 }, # one-time charges only
71     },
72     { 'field'     => 'unsuspend_hold',
73       'type'      => 'checkbox',
74       'value'     => 'Y',
75     },
76     { 'field'     => 'unused_credit',
77       'type'      => 'checkbox',
78       'value'     => 'Y',
79     }, 
80   ;
81 }
82
83 </%init>