#!/mod/bin/jimsh

package require cgi
source /mod/webif/lib/setup
require epg.class
source include/epgcell.jim

cgi_input

set sid [cgi_get sid 0]

mheader

set records [epg dbfetch dump -service $sid -after [clock seconds]]
set tr [lindex $records 0]
$tr get_channel_info

set day 0
puts "
<div class=va style=\"font-size: 1.2em; padding: 0 0 1em 0\">
	[$tr channel_icon 40]
	<span class=va>
		[$tr get channel_num] - [$tr get channel_name]
	</span>
</div>
<ul data-role=listview data-filter=true>
"

foreach e $records {
	$e copy_channel_info $tr

	set st [$e get start]
	set nday [clock format $st -format "%F"]
	if {$day ne $nday} {
		set day $nday
		puts "<li class=stick data-role=list-divider>
		    [clock format $st -format "%a %d %b %Y"]
		    </li>"
	}

	epgcell $e 1
}

puts "</ul>"

mfooter

