RT#38973: Bill for time worked on ticket resolution [validate queueids]
[freeside.git] / httemplate / edit / rate_tier.html
1 <% include( 'elements/edit.html',
2               'table'         => 'rate_tier',
3               'name_singular' => 'tiering plan',
4               'fields'        => [
5                 'tiername',
6                 #{ field=>'disabled', type=>'checkbox', value=>'Y' },
7                 { 'field'             => 'tierdetailnum',
8                   'type'              => 'rate_tier_detail',
9                   'colspan'           => 2,
10                   'o2m_table'         => 'rate_tier_detail',
11                   'm2_label'          => 'Tier',
12                   'm2_error_callback' => $m2_error_callback,
13                 },
14               ],
15               'labels'        => { 'tiernum'       => 'Plan #',
16                                    'tiername'      => 'Tiering plan',
17                                    'tierdetailnum' => 'Tier',
18                                  },
19               'viewall_dir' => 'browse',
20           )
21 %>
22 <%init>
23
24 die "access denied"
25   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
26
27 my $m2_error_callback = sub {
28   my($cgi, $object) = @_;
29
30   #process_o2m fields in process/rate_tier.html
31   my @fields = qw( min_quan min_charge );
32   my @gfields = ( '', map "_$_", @fields );
33
34   map {
35         if ( /^tierdetailnum(\d+)$/ ) {
36           my $num = $1;
37           if ( grep $cgi->param("tierdetailnum$num$_"), @gfields ) {
38             my $x = new FS::rate_tier_detail {
39               'tierdetailnum' => scalar($cgi->param("tierdetailnum$num")),
40               map { $_ => scalar($cgi->param("tierdetailnum${num}_$_")) }
41                   @fields,
42             };
43             $x;
44           } else {
45             ();
46           }
47         } else {
48           ();
49         }
50       }
51       $cgi->param;
52 };
53
54 </%init>