RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / sched_item.html
1 <& elements/edit.html,
2      'name_singular'   => 'Installer schedule', #$sched_item_class->classname. ' schedule',
3      'table'           => 'sched_item',
4      'viewall_dir'     => 'browse',
5      'no_pkey_display' => 1,
6      'labels'          => { 'name' => 'Name',
7                             map { ( "sched_avail$_" => $dow[$_] ) } (0..6),
8                           },
9      'fields'          => [
10                             { 'field' => 'name',
11                               'type'  => 'fixed',
12                             },
13                             ( map dow_factory($_), (0..6) ),
14                           ],
15      'edit_callback'   => $edit_callback,
16 &>
17 <%init>
18
19 #XXX more specific AccessRight for scheduling
20 die "access denied"
21   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
22
23 my @dow = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday );
24
25 sub dow_factory {
26   my $wday  = shift;
27
28   { 'field'     => 'sched_avail'. $wday,
29     'type'      => 'select-avail-time-from_to',
30     'prefix'    => 'sched_avail'. $wday. '_',
31   };
32
33 }
34
35 my $edit_callback = sub {
36   my( $cgi, $sched_item, $fields_listref, $opt_hashref ) = @_;
37   foreach my $sched_avail ( $sched_item->sched_avail ) {
38     if ( $sched_avail->override_date ) {
39       #XXX handle
40     } else {
41       my $param = 'sched_avail'. $sched_avail->wday;
42       $cgi->param($param, 'Y');
43       $cgi->param($param.'_stime', $sched_avail->stime);
44       $cgi->param($param.'_etime', $sched_avail->etime);
45     }
46   }
47 };
48
49 </%init>