summaryrefslogtreecommitdiff
path: root/httemplate/edit/reason.html
blob: 331db4439d5b19ec48b51c3d21939c42eef0d04c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<& elements/edit.html,
  'menubar'=> [ "View all $classname Reasons" => 
                  $p.'browse/reason.html?class='.$class,
                "View $classname Reason Types" =>
                  $p.'browse/reason_type.html?class='.$class,
              ],
  'name'   => ucfirst($classname) . ' Reason',
  
  'table'  => 'reason',
  'labels' => { 
                'reasonnum'   => $classname .  ' Reason',
                'reason_type' => $classname . ' Reason type',
                'reason'      => $classname . ' Reason',
 	        'disabled'    => 'Disabled',
                'class'       => '',
                'feepart'     => 'Charge a suspension fee',
                'fee_on_unsuspend'  => 'When a package is',
                'fee_hold'          => 'Delay fee until next bill',
                'unused_credit'     => 'Credit unused portion of service',
                'unsuspend_pkgpart' => 'Order an unsuspension package',
                'unsuspend_hold'    => 'Delay package until next bill',
              },
  'fields' => \@fields,
&>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

$cgi->param('class') =~ /^(\w)$/ or die "illegal class";
my $class=$1;

my $classname = ucfirst($FS::reason_type::class_name{$class});

my (@types) = qsearch( 'reason_type', { 'class' => $class } );

unless (scalar(@types)) {
  print $cgi->redirect( "reason_type.html?class=$class" );
}

my @fields = (
  { 'field' => 'reason_type',
    'type'  => 'select-table',
    'table' => 'reason_type',
    'name_col'  => 'type',
    'value_col' => 'typenum',
    'hashref'   => { 'class' => $class },
    'disable_empty' => 1,
#     #then fix tr-select.html
#
#    'value' => { 'vcolumn' => 'typenum',
#                 'ccolumn' => 'type',
#   	      'values'  => \@types,
#   	    },
#     # that wasn't so hard...did this do something else that I'm missing?
  },
  'reason',
  { 'field' => 'class',
    'type'  => 'hidden',
    'value' => $class,
  },
  { 'field' => 'disabled',
    'type'  => 'checkbox',
    'value' => 'Y'
  },
);

if ( $class eq 'S' or $class eq 'C' ) {
  push @fields,
    { 'field'     => 'unused_credit',
      'type'      => 'checkbox',
      'value'     => 'Y',
    };
}
if ( $class eq 'S' ) {
    { 'type' => 'tablebreak-tr-title' },
    { 'field'     => 'feepart',
      'type'      => 'select-table',
      'table'     => 'part_fee',
      'hashref'   => { disabled => '' },
      'name_col'  => 'itemdesc',
      'value_col' => 'feepart',
      'empty_label' => 'none',
    },
    { 'field'     => 'fee_on_unsuspend',
      'type'      => 'select',
      'options'   => [ '', 'Y' ],
      'labels'    => { '' => 'suspended', 'Y' => 'unsuspended' },
    },
    { 'field'     => 'fee_hold',
      'type'      => 'checkbox',
      'value'     => 'Y',
    },
    { 'field'     => 'unsuspend_pkgpart',
      'type'      => 'select-part_pkg',
      'hashref'   => { 'disabled' => '',
                       'freq'     => 0 }, # one-time charges only
    },
    { 'field'     => 'unsuspend_hold',
      'type'      => 'checkbox',
      'value'     => 'Y',
    },
  ;
}

</%init>