0
我有一個董事會會議室預訂系統,其中一個人預訂了會議室,並且該公司的員工可以在網上看到預訂。目前,如果一天有一個預訂,它會正確繪製。繪製帶填充插槽的時間表的問題
有幾個會議室,其中任何一個都可以在8:00到17:00之間隨時預訂。
如果有一個會議室預訂,它看起來像這樣:
但還有另一個會議室預約時,在同一天,它看起來像這樣:
我的for循環來創建網格看起來是這樣的:
for($h = 8; $h < 17; $h++) { // hours
for($m = 0; $m < 4; $m++) { // 15 minutes
echo '<tr><td>' . $h . ':' . str_pad(($m*15),2,"0") . '</td>'; //plots the timeslot
foreach($boardrooms as $boardroom) { // array of boardrooms
foreach($boardroomBookings as $booking) { // array of boardroom bookings
if(date('H:i',strtotime($h . ':' . str_pad(($m*15),2,"0"))) >= date('H:i',strtotime($booking['BoardroomBooking']['start_time'])) &&
date('H:i',strtotime($h . ':' . str_pad(($m*15),2,"0"))) < date('H:i',strtotime($booking['BoardroomBooking']['end_time'])) &&
$boardroom['Boardroom']['name'] == $booking['Boardroom']['name']) {
echo '<td rowspan="0" style="background-color:#8cc63f; border-bottom:none">' . $this->Html->link($booking['BoardroomBooking']['name'], array('action' => 'view', $booking['BoardroomBooking']['id'])) . '</td>'; // writes the name into the timeslot
} else {
echo '<td></td>'; // writes an empty block
}
}
}
echo '</tr>'; // closes the row
}
}
我在做什麼錯?
UPDATE
這裏是淡化陣列(僅示出了數據被使用);
$boardrooms = array(
(int) 0 => array(
'Boardroom' => array(
'name' => 'Big Boardroom (Pretoria)'
)
),
(int) 1 => array(
'Boardroom' => array(
'name' => 'Small Boardroom (Pretoria)'
)
),
(int) 2 => array(
'Boardroom' => array(
'name' => 'Medium Boardroom (No Screen) (Pretoria)'
)
),
(int) 3 => array(
'Boardroom' => array(
'name' => 'Big Boardroom (Floor 3) (Pretoria)'
)
),
(int) 4 => array(
'Boardroom' => array(
'name' => 'Big Boardroom (Durban)'
)
),
(int) 5 => array(
'Boardroom' => array(
'name' => 'Big Boardroom (Cape Town)'
)
)
)
$boardroomBookings = array(
(int) 0 => array(
'BoardroomBooking' => array(
'id' => '1206',
'name' => 'asdfasdf',
'boardroom_id' => '1',
'date' => '2013-05-21',
'start_time' => '08:15:00',
'end_time' => '10:00:00'
),
'Boardroom' => array(
'id' => '1',
'name' => 'Big Boardroom (Pretoria)'
)
),
(int) 1 => array(
'BoardroomBooking' => array(
'id' => '1208',
'name' => 'Test 2',
'boardroom_id' => '4',
'date' => '2013-05-21',
'start_time' => '09:00:00',
'end_time' => '12:00:00'
),
'Boardroom' => array(
'id' => '4',
'name' => 'Big Boardroom (Floor 3) (Pretoria)'
)
)
)
你介意提供一個帶有示例數據的數組嗎?那麼我會看看它。 – thpl
@ThomasDavidPlat我已經爲你添加了陣列。 – Albert