The project is a web calendar/scheduler using php. The idea is that a user can schedule a job that is assigned to specific machine at a specific time and others can see the job schedule and which 'asset' the job is assigned to. The scheduling works, however, I cannot tie the data to header/columns they belong to. It looks like this:
<?php
include_once("HTML/TABLE.PHP");
$data = array( 0=>array(1,'asset1','2013-07-24 10:00:00', '2013-07-24 12:00:00','red',2),
1=>array(2,'asset1','2013-07-24 12:00:00', '2013-07-24 13:00:00','green',3),
2=>array(3,'asset2','2013-07-24 11:00:00', '2013-07-24 12:00:00','blue', 4),
3=>array(4,'asset2','2013-07-24 12:00:00', '2013-07-24 14:00:00','red', 2),
4=>array(5,'asset3','2013-07-24 11:30:00', '2013-07-24 12:00:00','green', 4),
5=>array(6,'asset4','2013-07-24 12:00:00', '2013-07-24 14:00:00','blue', 3),
6=>array(7,'asset1','2013-07-24 11:45:00', '2013-07-24 13:00:00','red', 1),
7=>array(8,'asset4','2013-07-24 13:00:00', '2013-07-24 15:00:00','yellow', 5)
);
$attrs = array( 'class' => 'main',
'id' => 'main_id',
'width' => '100%',
'border' => '1',
'cellspacing' => '0',
'cellpadding' => '0');
$table = new HTML_Table($attrs);
$table->setAutoGrow(true);
$table->setAutoFill('n/a');
$heads = array( array('asset1','asset2','asset3','asset4'));
$i = 1;
foreach($heads as $val)
{
$table->setHeaderContents(0, $i++, $val);
unset($val);
}
$now = date('U');
$offset = ($now % 900);
$now = $now-$offset;
for ($i = 0;$i < 33; $i++)
{
$table->setHeaderContents($i,0, date('g:i',$now));
$now += 900;
}
$cellPosition = 1;
$rowCounter = 1;
for ($i=0;$i < count($data);$i++)
{
$table->setCellAttributes ($rowCounter,$cellPosition,' bgcolor = '. $data[$i][4]. ' rowspan=' . $data[$i][5]);
$table->setCellContents($rowCounter,$cellPosition,"Job# ".$data[$i][0] . " belongs to: " . $data[$i][1]);
$cellPosition++;
$rowCounter =1;
}
echo $table->display();
?>
How can I tie the information to only the column it belongs to?
I have gotten this far, but I get odd results if the first column is true:
$cellPosition = 0;
$rowCounter = 1;
for ($x=0;$x <= count($heads);$x++)
{
for ($i=0;$i < count($data);$i++)
{
if ($data[$i][1] == $table->getCellContents(0,$x))
{
$table->setCellAttributes ($rowCounter,$cellPosition,' bgcolor = '. $data[$i][4]. ' rowspan=' . $data[$i][5]);
$table->setCellContents($rowCounter,$cellPosition,"Job# ".$data[$i][0] . " belongs to: " . $data[$i][1]);
//$cellPosition++;
//echo ;
echo "<br> The current count of x = : ". $x;
echo "<br>" . $table->getCellContents(0,$x) . " Matches " . $table->getCellContents(0,$x) . " at index " . $i;
$rowCounter += $data[$i][5];
}
else
{
$rowCounter = 1;
}
}
$cellPosition++;