7731a35b997c525d9d9e015b2d79c8edcd31e4de
[freeside.git] / httemplate / edit / process / sched_item.html
1 %if ( $error ) {
2 %  $cgi->param('error', $error );
3 <% $cgi->redirect(popurl(2). "sched_item.html?". $cgi->query_string ) %>
4 %} else {
5 <% $cgi->redirect(popurl(3). "browse/sched_item.html") %>
6 %}
7 <%init>
8
9 #XXX more specific AccessRight for scheduling
10 die "access denied"
11   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
12
13 my $itemnum = $cgi->param('itemnum');
14
15 my $sched_item = qsearchs('sched_item', { 'itemnum' => $itemnum })
16   or die "unknown itemnum $itemnum";
17
18 my @sched_avail = ();
19 foreach my $wday (0..6) {
20   if ( $cgi->param("sched_avail$wday") eq 'Y' ) {
21     push @sched_avail, new FS::sched_avail {
22       'itemnum' => $itemnum,
23       'wday'    => $wday,
24       'stime'   => $cgi->param("sched_avail$wday".'_stime'),
25       'etime'   => $cgi->param("sched_avail$wday".'_etime'),
26     };
27   }
28 }
29
30 my $error = $sched_item->replace_sched_avail(@sched_avail);
31
32 </%init>