Code:
Here's the code...
function my_page()
{
$userinfo = $this->plan->user_info();
$toget = array();
$toshow = '';
$returnpage = '';
if ($userinfo['office'] !== '1') {
redirect('plan');
}
if ($this->uri->segment(3) == 'archived') {
$this->db->where('archived','1');
$pagetitle = '<h2>All Archived Courses</h2>';
$archiveswitch = '<p>'.anchor('plan/admin','Review non-archived courses').'</p>';
} else {
$this->db->where('archived','0');
$pagetitle = '<h2>All Courses</h2>';
$archiveswitch = '<p>'.anchor('plan/admin/archived','Review archived courses').'</p>';
}
$this->db->order_by('service_line ASC, technical_title ASC, ID DESC');
$foundthem = $this->db->get('planning_course');
if ($foundthem->num_rows() > 0) {
foreach ($foundthem->result_array() as $thiscourse) {
$toshow .= '<p><strong>';
$toshow .= $thiscourse['service_line'].$thiscourse['audience'].'_'.$thiscourse['strategy'].'__: ';
$usetitle = $thiscourse['planning_title'];
if ($thiscourse['technical_title'] !== '') { $usetitle = $thiscourse['technical_title']; }
$toshow .= $usetitle;
$toshow .= '</strong><br>';
$this->db->where('course_ID',$thiscourse['ID']);
$this->db->where('removed','0');
$this->db->order_by('on_date ASC');
$founddays = $this->db->get('planning_day');
if ($founddays->num_rows() > 0) {
$datelist = '';
foreach ($founddays->result_array() as $thisday) {
if ($datelist !== '') { $datelist .= ', '; }
$datelist .= '<em>'.$thisday['eventID'].'</em>';
}
$toshow .= $datelist.'<br>';
} else {
$toshow .= '<em>No dates scheduled</em><br>';
}
$people = array();
$this->db->where('course_ID',$thiscourse['ID']);
$this->db->order_by('role ASC');
$foundroles = $this->db->get('planning_role');
if ($foundroles->num_rows() > 0) {
foreach ($foundroles->result_array() as $thisrole) {
$people[$thisrole['role']][] = $thisrole['person_ID'];
}
}
foreach ($people as $role=>$peopleIDs) {
$showpeople = '';
$this->db->where_in('ID',$peopleIDs);
$this->db->order_by('LN ASC, FN ASC, ID ASC');
$foundpeople = $this->db->get('planning_person');
if ($foundpeople->num_rows() > 0) {
foreach ($foundpeople->result_array() as $thisperson) {
if ($showpeople !== '') { $showpeople .= '; '; }
if ($showpeople == '') {
$showpeople .= '<strong>'.strtoupper(substr($role,0,1)).substr($role,1);
if ($foundpeople->num_rows() > 1) { $showpeople .= 's'; }
$showpeople .= ':</strong> ';
}
$showpeople .= $thisperson['email_address'];
}
$showpeople .= '<br>';
}
$toshow .= $showpeople;
}
$toshow .= anchor('plan/course/'.$thiscourse['ID'],'Review this course').'</p>';
}
}
$returnpage .= $pagetitle;
$returnpage .= $archiveswitch;
$returnpage .= $toshow;
return $returnpage;
}