Index: includes/programs.php
===================================================================
--- includes/programs.php	(revision 8873)
+++ includes/programs.php	(working copy)
@@ -124,14 +124,16 @@
                                    "&frac12;", "")) AS starstring,
                          IFNULL(programrating.system, "") AS rater,
                          IFNULL(programrating.rating, "") AS rating,
-                         oldrecorded.recstatus
+                         oldrecorded.recstatus,channel.channum
                   FROM program
                        LEFT JOIN programrating USING (chanid, starttime)
                        LEFT JOIN oldrecorded
-                                 ON LENGTH(IFNULL(oldrecorded.seriesid, "")) > 0
-                                    AND LENGTH(IFNULL(oldrecorded.programid, "")) > 0
-                                    AND oldrecorded.programid = program.programid
-                                    AND oldrecorded.seriesid  = program.seriesid
+                                 ON oldrecorded.programid = program.programid
+                                    AND oldrecorded.seriesid = program.seriesid
+                                    AND (oldrecorded.recstatus = -3
+                                        OR ((LENGTH(IFNULL(oldrecorded.seriesid, "")) > 0
+                                        AND LENGTH(IFNULL(oldrecorded.programid, "")) > 0)))
+                       LEFT JOIN channel ON program.chanid = channel.chanid
                  WHERE';
     // Only loading a single channel worth of information
         if ($chanid > 0)
@@ -166,8 +168,8 @@
             if (!$data['chanid'])
                 continue;
         // This program has already been loaded, and is attached to a recording schedule
-            if ($Scheduled_Recordings[$data['chanid']][$data['starttime_unix']]) {
-                $program =& $Scheduled_Recordings[$data['chanid']][$data['starttime_unix']][0];
+            if ($Scheduled_Recordings[$data['channum']][$data['starttime_unix']]) {
+                $program =& $Scheduled_Recordings[$data['channum']][$data['starttime_unix']][0];
             }
         // Otherwise, create a new instance of the program
             else {
@@ -299,8 +301,6 @@
             #$this->inputid        = $data[19];
             $this->recpriority     = $data[20];
             $this->recstatus       = $data[21];
-            $this->conflicting     = ($this->recstatus == 'Conflict');   # conflicts with another scheduled recording?
-            $this->recording       = ($this->recstatus == 'WillRecord'); # scheduled to record?
             $this->recordid        = $data[22];
             $this->rectype         = $data[23];
             $this->dupin           = $data[24];
@@ -366,8 +366,11 @@
             }
         }
     // Turn recstatus into a word
-        if (isset($this->recstatus) && $GLOBALS['RecStatus_Types'][$this->recstatus])
+        if (isset($this->recstatus) && $GLOBALS['RecStatus_Types'][$this->recstatus]) {
             $this->recstatus = $GLOBALS['RecStatus_Types'][$this->recstatus];
+            $this->conflicting = ($this->recstatus == 'Conflict');   # conflicts with another scheduled recording?
+            $this->recording   = ($this->recstatus == 'WillRecord'); # scheduled to record?
+        }
     // No longer a null column, so check for blank entries
         if ($this->airdate == '0000-00-00')
             $this->airdate = NULL;
Index: includes/channels.php
===================================================================
--- includes/channels.php	(revision 8873)
+++ includes/channels.php	(working copy)
@@ -32,7 +32,7 @@
             $sql = 'SELECT * FROM channel WHERE';
         $sql .= ' channel.visible=1';
     // Group and sort
-        $sql .= ' GROUP BY channel.chanid ORDER BY '
+        $sql .= ' GROUP BY channel.channum ORDER BY '
                 .(sortby_channum ? '' : 'channel.callsign, ')
                 .'(channel.channum + 0), channel.chanid';
     // Query
Index: includes/recording_schedules.php
===================================================================
--- includes/recording_schedules.php	(revision 8873)
+++ includes/recording_schedules.php	(working copy)
@@ -77,9 +77,9 @@
         if ($key === 'offset') {
             list($Num_Conflicts, $Num_Scheduled) = $program;
         }
-    // Normal entry:  $Scheduled_Recordings[chanid][starttime][]
+    // Normal entry:  $Scheduled_Recordings[channum][starttime][]
         else {
-            $Scheduled_Recordings[$program[4]][$program[11]][] =& new Program($program);
+            $Scheduled_Recordings[$program[5]][$program[11]][] =& new Program($program);
         }
     }
 
Index: modules/tv/upcoming.php
===================================================================
--- modules/tv/upcoming.php	(revision 8873)
+++ modules/tv/upcoming.php	(working copy)
@@ -76,16 +76,16 @@
 // Parse the list of scheduled recordings
     global $Scheduled_Recordings;
     $all_shows = array();
-    foreach ($Scheduled_Recordings as $chanid => $shows) {
+    foreach ($Scheduled_Recordings as $channum => $shows) {
     // Now the shows in this channel
         foreach ($shows as $starttime => $show_group) {
-        // Skip things we've already recorded (or missed)
-            if ($starttime <= time() && $show->recstatus != 'Recording')
-                continue;
         // Parse each show group
             foreach ($show_group as $key => $show) {
+            // Skip things we've already recorded (or missed)
+                if ($starttime <= time() && $show->recstatus != 'Recording')
+                    continue;
             // Make sure this is a valid show (ie. skip in-progress recordings and other junk)
-                if (!$chanid || $show->length < 1)
+                if (!$channum || $show->length < 1)
                     continue;
             // Skip scheduled shows?
                 if (in_array($show->recstatus, array('WillRecord', 'ForceRecord'))) {
@@ -107,7 +107,7 @@
                     continue;
                 }
             // Assign a reference to this show to the various arrays
-                $all_shows[] =& $Scheduled_Recordings[$chanid][$starttime][$key];
+                $all_shows[] =& $Scheduled_Recordings[$channum][$starttime][$key];
             }
         }
     }
Index: modules/tv/detail.php
===================================================================
--- modules/tv/detail.php	(revision 8873)
+++ modules/tv/detail.php	(working copy)
@@ -179,7 +179,7 @@
 // Parse the list of scheduled recordings for possible conflicts
     global $Scheduled_Recordings;
     $conflicting_shows = array();
-    foreach ($Scheduled_Recordings as $chanid => $shows) {
+    foreach ($Scheduled_Recordings as $channum => $shows) {
     // Now the shows in this channel
         foreach ($shows as $starttime => $show_group) {
         // Clearly not a match
@@ -191,13 +191,13 @@
                 if ($show->chanid == $program->chanid && $show->starttime == $program->starttime)
                     continue;
             // Make sure this is a valid show (ie. skip in-progress recordings and other junk)
-                if (!$chanid || $show->length < 1)
+                if (!$channum || $show->length < 1)
                     continue;
             // Not a conflict
                 if ($show->endtime < $program->starttime)
                     continue;
             // Assign a reference to this show to the various arrays
-                $conflicting_shows[] =& $Scheduled_Recordings[$chanid][$starttime][$key];
+                $conflicting_shows[] =& $Scheduled_Recordings[$channum][$starttime][$key];
             }
         }
     }
