X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fsched_item.html;h=372d4fd7e16663e77a2644f034f1d2d1824fd3cd;hp=09435805a6d87c7635dbb9cbcbde9b1d0c078fd9;hb=b71b1576c68bc40ad26592b354feace37a029f0e;hpb=0dfd49189b0ea878e99f1590a2939e55ab02c89c diff --git a/httemplate/browse/sched_item.html b/httemplate/browse/sched_item.html index 09435805a..372d4fd7e 100644 --- a/httemplate/browse/sched_item.html +++ b/httemplate/browse/sched_item.html @@ -1,11 +1,17 @@ <& elements/browse.html, - 'title' => 'Installers', #PL($sched_item_class->classname), + 'title' => 'Installer schedules', #$sched_item_class->classname. ' schedules', 'name_singular' => 'installer', #$sched_item_class->classname 'query' => { 'table' => 'sched_item' }, 'count_query' => 'SELECT COUNT(*) FROM sched_item', - 'header' => [ 'Installer', ], #$sched_item_class->classname - 'fields' => [ 'name' ], - #'links' => [ $link, ], + 'header' => [ 'Installer', #$sched_item_class->classname + @dow, + 'Overrides', + ], + 'fields' => [ 'name', + ( map dow_factory($_), (0..6) ), + $override_sub, + ], + 'links' => [ $link, ], 'disableable' => 1, 'disabled_statuspos' => 1, &> @@ -15,4 +21,62 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +my $link = [ $p.'edit/sched_item.html?', 'itemnum' ]; + +my @dow = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); + +sub dow_factory { + my $wday = shift; + + return sub { + my $sched_item = shift; + + my @sched_avail = qsearch({ + 'table' => 'sched_avail', + 'hashref' => { + 'itemnum' => $sched_item->itemnum, + 'wday' => $wday, #thanks, closure + 'override_date' => '', + }, + 'order_by' => 'ORDER BY stime', + }); + + return 'Not available' unless @sched_avail; + + #data + # align bgcolor colspan rowspan style valign width + # link onclick size data_style + + [ + map { + [ { data=> $_->stime_pretty }, + { data=> '-', }, + { data=> $_->etime_pretty }, + ]; + } + @sched_avail + ]; + + }; + +} + +my $override_sub = sub { + my $sched_item = shift; + + my @sched_avail = qsearch({ + 'table' => 'sched_avail', + 'hashref' => { + 'itemnum' => $sched_item->itemnum, + 'override_date' => { op=>'!=', value=>'' }, + }, + 'order_by' => 'ORDER BY override_date, stime', + }); + + return 'None' unless @sched_avail; + + #XXX print each override date (and day of week) + +}; +