new reservations screen

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@234 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-07-05 00:19:02 +00:00
parent e712f38bb1
commit 5f6c7a843c
2 changed files with 155 additions and 51 deletions

View File

@ -1,46 +1,33 @@
#!/mod/bin/jimsh
package require sqlite3
source /mod/var/mongoose/lib/setup
require altrow
require altrow rsv.class progressbar
set db [sqlite3.open /var/lib/humaxtv/rsv.db]
$db query {attach database '/var/lib/humaxtv/channel.db' as channel}
set events [rsv list]
set res [$db query {
select *, channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn,
case when ersvtype > 3 then 1 else 0 end as sort
from tbl_reservation
left join channel.TBL_SVC
on main.TBL_RESERVATION.hSvc = channel.TBL_SVC.hSvc
order by sort, nsttime
}]
puts {
<table class=borders>
<tr>
<th colspan=3>Channel</th>
<th>Programme</th>
<th>Start Time</th>
<th>Duration</th>
<th>Mode</th>
<th>Event/Series ID</th>
<th>Events</th>
</tr>
}
puts "<table class=borders>"
puts "<tr>"
#puts "<th>Slot</th>"
puts "<th colspan=2>Programme</th>"
puts "<th>Duration</th>"
puts "<th colspan=2>Channel</th>"
puts "<th>Date/Time</th>"
puts "<th>Mode</th>"
puts "<th>Event/Series ID</th>"
puts "</tr>"
foreach r $res {
set name [string range $r(szevtname) 1 end]
if {[string first "i7" $name] == 0} {
set name [string range $name 2 end]
set b "*"
} else {
set b ""
}
foreach event $events {
$event cleanstrings
set name [$event get szevtname]
altrow
set rsvicon ""
set alta ""
switch $r(ersvtype) {
switch [$event get ersvtype] {
1 { set rsvicon "175_1_00_Reservation_Watch.png" }
2 { set rsvicon "175_1_00_Reservation_Watch.png" }
3 { set rsvicon "175_1_11_Reservation_Record.png" }
@ -48,16 +35,16 @@ foreach r $res {
6 { set rsvicon "745_1_11_Video_1REC.png"; set alta "Sleep" }
7 { set rsvicon "345_6_08_ST_Ad_Hoc.png"
set alta "Auto Update" }
default { set alta "Unknown type $r(ersvtype)" }
default { set alta "Unknown type [$event get ersvtype]" }
}
if {$name == ""} { set name "-- $alta --" }
set series 0
if {$r(ucRecKind) == 4} {
if {[$event get ucRecKind] == 4} {
set RKIcon "175_1_11_Series_Record.png"
set series 1
} else {
switch $r(erepeat) {
switch [$event get erepeat] {
1 {set RKIcon "521_1_00_RP_Daily_C.png"}
2 {set RKIcon "521_1_00_RP_Weekly_C.png"}
3 {set RKIcon "521_1_00_RP_Weekdays_C.png"}
@ -67,38 +54,81 @@ foreach r $res {
}
if {$rsvicon ne ""} {
set rsvicon "<img src='images/$rsvicon' height=15>
set rsvicon "<img src='images/$rsvicon' height=20>
}
if {$RKIcon ne ""} {
set RKIcon "<img src='images/$RKIcon' height=15>
set RKIcon "<img src='images/$RKIcon' height=20>
}
# puts "<td>{$r(ulslot)}</td>"
puts "<td>$b</td><td>$name</td>"
puts "<td>[clock format $r(nduration) -format %T]</td>"
puts "<td>$r(usLcn)</td>"
puts "<td>[string range $r(szSvcName) 1 end]</td>"
if { $r(nsttime) < [clock seconds] } {
puts "<td class=blood>"
if {[$event get usLcn] ne ""} {
puts "
<td>[$event get usLcn]</td>
<td>
<img src=\"/img/channels/[$event get szSvcName].png\"
width=50>
</td>
<td nowrap>[$event get szSvcName]</td>
"
} else {
puts "<td>"
puts "<td colspan=3>&nbsp;<br><br></td>"
}
puts "[clock format $r(nsttime) -format {%c %Z}]</td>"
puts "<td>$rsvicon $RKIcon</td>"
puts "<td>"
set crid [join [lrange [split $r(szCRID) "/"] 1 end]]
puts "<td nowrap>$name</td>"
set s [$event get nsttime]
set d [$event get nduration]
set e $($s + $d)
set n [clock seconds]
if { $n > $e } {
puts "<td class=blood nowrap class=va>"
} else {
puts "<td nowrap class=va>"
}
puts "[clock format $s -format {%c %Z}]"
if {$d > 0 && $n > $s && $n < $e} {
puts "<br>"
set perc [expr [expr $n - $s] * 100 / $d]
puts "<img class=va src=/images/745_1_11_Video_1REC.png>"
puts [progressbar $perc]
}
puts "</td>"
puts "<td>[clock format [$event get nduration] -format %T]</td>"
puts "<td nowrap>$rsvicon $RKIcon</td>"
puts "<td nowrap>"
set crid [join [lrange [split [$event get szCRID] /] 1 end]]
if {$crid != ""} {
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
if $series { puts -nonewline "s" }
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
$r(szCRID)"
[$event get szCRID]"
puts "</a>"
}
puts "</td>"
puts "<td nowrap>"
set flag 0
foreach ev [split [$event get szEventToRecord] "|"] {
if {$ev eq ""} { continue }
set ev [string range $ev 1 end]
if {$flag} { puts "<br>" }
incr flag
set crid [join [lrange [split $ev /] 1 end]]
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
$ev"
puts "</a>"
}
puts "</td>"
puts "</tr>"
}
puts "</table>"
puts "<font class=footnote>Click on the CRID to view episodes.</font>"
$db close

74
var/mongoose/lib/rsv.class Executable file
View File

@ -0,0 +1,74 @@
source /mod/var/mongoose/lib/setup
if {![exists -proc class ]} { package require oo }
if {![exists -proc sqlite3.open ]} { package require sqlite3 }
if {![exists -proc settings ]} { require settings.class }
set rsvdb [sqlite3.open /var/lib/humaxtv/rsv.db]
$rsvdb query {attach database '/var/lib/humaxtv/channel.db' as channel}
class rsv {
ulslot 0
ersvtype 0
hsvc 0
nsttime 0
szsttime 0
nduration 0
erepeat 0
usevtid 0
szevtname {}
ulPreOffset 0
ulPostOffset 0
ulProgramId 0
ulSeriesId 0
ucVolume 0
ucInputMode 0
usChNum 0
ucRecKind 0
ucCRIDType 0
szCRID {}
szFPBRecPath {}
szRecordedProgCrid {}
szEventToRecord {}
aulEventToRecordInfo {}
bRecomRsv 0
usLastRecordedEvtId 0
eReady 0
szSvcName {}
usLcn 0
sort 0
}
rsv method cleanstrings {} {
set szevtname [string range $szevtname 1 end]
if {[string first "i7" $szevtname] == 0} {
set szevtname [string range $szevtname 2 end]
}
set szSvcName [string range $szSvcName 1 end]
}
proc {rsv list} {} {
catch { $::rsvdb query {.mode tcl} }
set res [$::rsvdb query {
select tbl_reservation.*,
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn,
case when ersvtype > 3 then 1 else 0 end as sort
from tbl_reservation
left join channel.TBL_SVC
on main.TBL_RESERVATION.hSvc = channel.TBL_SVC.hSvc
order by sort, nsttime
}]
set records {}
foreach rec $res {
lappend records [rsv new $rec]
}
return $records
}
proc {rsv cleanup} {} {
catch {$::rsvdb close}
}