I have a code for an agenda and have one problem with one item....the FINALPANEL part of the array.
The array for the room names is here:
// SEMINAR ROOM ARRAY
$_seminarroom=array(
0 => "Room Name 1",
1 => "Room Name 2",
2 => "Room Name 3",
3 => "Room Name 4"
);
The array for the speakers and agenda is like this. The important item is "FINALPANEL"
0 means NO
1 Means Yes ---> then the person's name, title and company is placed on the final panel (Day at 3:30)
// SPEAKER ARRAY
$_sp=array();
// 8:30 AM
// KEYNOTE SPEAKER
$_sp[]=array(
"breakbefore" => 'l|8:00|8:30|Coffee and Opening',
"session_theme" => '',
"breakout" => 0,
"FinalPanel" => 1,
"Name" => Speaker's Name,
"Title" => "Executive Vice President",
"Company" => "The Big Company",
"Logo" => "",
"Topic" => "$ToBeAnnounced",
etc etc etc
It doesn't work:
My Test Site shows the incorrect output (LOOK at DAY 2 - 3:30 PM). The correct output is Here -(LOOK at DAY 2 - 3:30 PM).
Functions are here:
//FUNCTIONS.php file
// add a break in theprogram, e.g., lunch, tea, dinner
function add_break($breakinfo, $colmult)
{
// get the break info out:
$info = explode('|', $breakinfo);
$title = '';
if(! array_key_exists(3, $info))
{
switch($info[0])
{
case 'b':
$title = '== Break ==';
break;
case 'l':
$title = '== lunch ==';
break;
case 'e':
$title = '== Evening Activities ==';
break;
}
}
else
{
$title = $info[3];
}
return "
<td colspan=\"".$colmult."\">
<ul class='break'><li>".$info[1]." - ".$info[2]."</li>
<li>".$title."</li>
</ul>
</td>
";
}
// Creates the breakout sessions
function get_breakout($colspan, $day, $time)
{
global $breakouts, $breakout;
if(array_key_exists($day, $breakouts) and array_key_exists($time, $breakouts[$day]))
{
$retval = "
<tr>
<td colspan=\"".$colspan."\">
<p class=\"title\">".$breakouts[$day][$time]."</p>";
foreach($breakout[$breakouts[$day][$time]] as $speaker)
{
$retval .="
<p>".$time."<br />
<b>Speaker Name:</b> ".$speaker['Name']."<br />
<b>Speaker Title:</b> ".$speaker['Title']."<br />
<b>Speaker Company:</b> ".$speaker['Company']."<br />
<b>Speaker Minutes:</b> ".$speaker['Minutes']."</p>
";
}
$retval .= "</td></tr>";
return $retval;
}
else
{
return '';
}
}
function create_row($template, $time, $info, $maxroomcount, $colmult)
{
global $_seminarroom, $ToBeAnnounced, $poplink;
$colwidth=floor((1/$maxroomcount)*100);
$retval = '';
$thisroomcount = count($info);
switch($template)
{
case 1: // the template for a row when 1 colum is required
// break;
case 2:
$colspan = $colmult / $thisroomcount;
Foreach($info as $room => $speakers)
{
$retval.= "
<td width=\"".$colwidth."%\" colspan=\"".$colspan."\">";
$i = 0;
foreach($speakers as $speaker)
{
if($i == 0)
{
$retval .= "
<p>".$time."<br />";
$i =1;
if($speaker['Popup'] == '')
{
$retval .= $poplink."tba.html\">".$speaker['Topic']."</a></p>";
}
else
{
$retval .= $poplink.$speaker['Popup'].".html\">".$speaker['Topic']."</a></p>";
}
}
$retval .= "
<b>Speaker Name:</b> ".$speaker['Name']."<br />
<b>Speaker Title:</b> ".$speaker['Title']."<br />
<b>Speaker Company:</b> ".$speaker['Company']."<br />
<b>Speaker Minutes:</b> ".$speaker['Minutes']."<br />
";
}
if($thisroomcount < $maxroomcount)
{
$retval .= "<p>Location: ".$_seminarroom[$room]."</p>";
}
$retval.= "
</td>";
}
$retval = "<tr>".$retval."</tr>";
break;
case 3:
$retval = create_row(2, $time, $info, 3, $colmult);
break;
case 4:
$retval = create_row(2, $time, $info, 4, $colmult);
break;
}
return $retval;
}
function create_room_header($template, $info, $maxroomcount, $colmult)
{
global $_seminarroom;
$colwidth=floor((1/$maxroomcount)*100);
$retval = '';
$thisroomcount = count($info);
switch($template)
{
case 1: // the template for a row when 1 colum is required
break;
case 2:
$colspan = $colmult / $thisroomcount;
Foreach($info as $room => $speakers)
{
$retval.= "
<td width=\"".$colwidth."%\" colspan=\"".$colspan."\">
<p class=\"title\">".$_seminarroom[$room]."
<br /> ".$speakers[0]['session_theme']."</p>
</td>";
}
$retval = "<tr>".$retval."</tr>";
break;
case 3:
$retval = create_room_header(2, $info, 3, $colmult);
break;
case 4:
$retval = create_room_header(2, $info, 4, $colmult);
break;
}
return $retval;
}
The output file is here: Somewhere in here is where I suspect the problem is:
// OUTPUT FILE
// Initialize variables
$spinfo = array();
$finalevent = array();
$breakouts = array();
$breakout = array();
$lastbreakout = '';
$daycount = 0;
$roomcount = array();
$colmult = array();
$roomsused = array();
foreach($_sp as $key => $info)
{
if($info['breakout'] == 1)
{
if(!array_key_exists($info['session_theme'], $breakout))
{
if($lastbreakout <> '')
{
$breakouts[$boday][$botime]= $lastbreakout;
}
$breakout[$info['session_theme']] = array();
}
$boday = $info['Day'];
$botime = $info['Time'];
$lastbreakout = $info['session_theme'];
$breakout[$info['session_theme']][] = $info;
}
else
{
// Is the speaker in the final event?
if($info['FinalPanel'] == 1)
{
$finalevent[] = $info;
}
// Is it a new day?
if(! array_key_exists($info['Day'], $spinfo))
{
$spinfo[$info['Day']] = array();
}
// Is it a new time?
if(! array_key_exists($info['Time'], $spinfo[$info['Day']]))
{
$spinfo[$info['Day']][$info['Time']] = array();
}
// Is it a new room?
if(! array_key_exists($info['Room'], $spinfo[$info['Day']][$info['Time']]))
{
$spinfo[$info['Day']][$info['Time']][$info['Room']] = array();
}
// Store info in [day][time][room] structure
$spinfo[$info['Day']][$info['Time']][$info['Room']][] = $info;
}
}
// Make sure that also the last breakout event is included
if($lastbreakout <> '')
{
$breakouts[$boday][$botime]= $lastbreakout;
}
// calculate the room use and stuff
foreach($spinfo as $day => $info)
{
$roomsused[$day] = array();
$daycount++;
$roomcount[$day] = 0;
foreach($info as $time=>$room)
{
$taken = array_keys($room);
foreach($taken as $key)
{
$roomsused[$day][$key]=$key;
}
// For each day, store the maximum number of rooms required
$roomcount[$day] = (count($room) > $roomcount[$day]) ? count($room) : $roomcount[$day];
}
$colmult[$day] = ($roomcount[$day] > 2) ? $roomcount[$day]*($roomcount[$day]-1) : $roomcount[$day];
}
// =============================
// Start generaing output
// =============================
echo $styles;
foreach($spinfo as $day => $info)
{
$lasttheme = '';
$percentage = floor(1/$roomcount[$day])*100;
$percentage.='%';
echo "
<h1 class=\"green\"> Day ".$day." Agenda</h1>
<table class='table1_style'>
";
foreach($info as $time=>$rooms)
{
if($rooms[0][0]['breakbefore'] <> '')
{
echo add_break($rooms[0][0]['breakbefore'], $colmult[$day]);
}
if($lasttheme <> $rooms[0][0]['session_theme'])
{
echo create_room_header($roomcount[$day], $rooms, $roomcount[$day], $colmult[$day]);
$lasttheme = $rooms[0][0]['session_theme'];
}
echo create_row($roomcount[$day], $time, $rooms, $roomcount[$day], $colmult[$day]);
echo get_breakout($roomcount[$day],$day, $time);
}
echo "</table>";
}
Help on this is very much appreciated.
Thanks
Marc