summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-04-05 16:46:29 -0700
committerIvan Kohler <ivan@freeside.biz>2014-04-05 16:46:29 -0700
commitac127e9cc71ed1cfebb159095dd59b3507e54e98 (patch)
treec1e741cfbe7a64567202b48e7b4a6725a67f6896 /httemplate/edit
parenta57c537ff9ef2a57de3225fbd49772be4b81e74c (diff)
installers, RT#16584
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/process/sched_item.html32
-rw-r--r--httemplate/edit/sched_item.html49
2 files changed, 81 insertions, 0 deletions
diff --git a/httemplate/edit/process/sched_item.html b/httemplate/edit/process/sched_item.html
new file mode 100644
index 000000000..7731a35b9
--- /dev/null
+++ b/httemplate/edit/process/sched_item.html
@@ -0,0 +1,32 @@
+%if ( $error ) {
+% $cgi->param('error', $error );
+<% $cgi->redirect(popurl(2). "sched_item.html?". $cgi->query_string ) %>
+%} else {
+<% $cgi->redirect(popurl(3). "browse/sched_item.html") %>
+%}
+<%init>
+
+#XXX more specific AccessRight for scheduling
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $itemnum = $cgi->param('itemnum');
+
+my $sched_item = qsearchs('sched_item', { 'itemnum' => $itemnum })
+ or die "unknown itemnum $itemnum";
+
+my @sched_avail = ();
+foreach my $wday (0..6) {
+ if ( $cgi->param("sched_avail$wday") eq 'Y' ) {
+ push @sched_avail, new FS::sched_avail {
+ 'itemnum' => $itemnum,
+ 'wday' => $wday,
+ 'stime' => $cgi->param("sched_avail$wday".'_stime'),
+ 'etime' => $cgi->param("sched_avail$wday".'_etime'),
+ };
+ }
+}
+
+my $error = $sched_item->replace_sched_avail(@sched_avail);
+
+</%init>
diff --git a/httemplate/edit/sched_item.html b/httemplate/edit/sched_item.html
new file mode 100644
index 000000000..7dfe26888
--- /dev/null
+++ b/httemplate/edit/sched_item.html
@@ -0,0 +1,49 @@
+<& elements/edit.html,
+ 'name_singular' => 'Installer schedule', #$sched_item_class->classname. ' schedule',
+ 'table' => 'sched_item',
+ 'viewall_dir' => 'browse',
+ 'no_pkey_display' => 1,
+ 'labels' => { 'name' => 'Name',
+ map { ( "sched_avail$_" => $dow[$_] ) } (0..6),
+ },
+ 'fields' => [
+ { 'field' => 'name',
+ 'type' => 'fixed',
+ },
+ ( map dow_factory($_), (0..6) ),
+ ],
+ 'edit_callback' => $edit_callback,
+&>
+<%init>
+
+#XXX more specific AccessRight for scheduling
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my @dow = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday );
+
+sub dow_factory {
+ my $wday = shift;
+
+ { 'field' => 'sched_avail'. $wday,
+ 'type' => 'select-avail-time-from_to',
+ 'prefix' => 'sched_avail'. $wday. '_',
+ };
+
+}
+
+my $edit_callback = sub {
+ my( $cgi, $sched_item, $fields_listref, $opt_hashref ) = @_;
+ foreach my $sched_avail ( $sched_item->sched_avail ) {
+ if ( $sched_avail->override_date ) {
+ #XXX handle
+ } else {
+ my $param = 'sched_avail'. $sched_avail->wday;
+ $cgi->param($param, 'Y');
+ $cgi->param($param.'_stime', $sched_avail->stime);
+ $cgi->param($param.'_etime', $sched_avail->etime);
+ }
+ }
+};
+
+</%init>