<?php load_partial('header'); ?>
<div class="container">
<?php
// Get passed records from controller
$records = $data['records'];
$bizname = $records[0]['bizname'];
?>
<h2><?php echo $bizname; ?></h2>
<table>
    <tr>
        <th>类别</th>
        <th>金额</th>
        <th>描述</th>
        <th>时间</th>
    </tr>
    <?php foreach ($records as $record): ?>
        <tr>
            <td><?= $record['category'] == 'income' ? '收入' : ($record['category'] == 'expense' ? '支出' : $record['category']) ?></td>
            <td><?= $record['amount'] ?></td>
            <td><?= $record['description'] ?></td>
            <td><?= $record['date'] ?></td>
        </tr>
    <?php endforeach; ?>
</table>
<!-- Pagination -->
<div class="pagination">
    <?php if($data['currentPage'] > 1): ?>
        <a href="?controller=Record&action=showRecords&business_id=<?php echo $business_id; ?>&page=<?php echo $data['currentPage']-1; ?>">向前</a>
    <?php endif; ?>

    <?php if($data['currentPage'] < $data['totalPages']): ?>
        <a href="?controller=Record&action=showRecords&business_id=<?php echo $business_id; ?>&page=<?php echo $data['currentPage']+1; ?>">向后</a>
    <?php endif; ?>
</div>
<div class="date-filter">
    <form action="?controller=Record&action=getRecordsByDate&business_id=<?php echo $business_id; ?>" method="POST">
        <label for="date">日期:</label>
        <input type="date" id="date" name="date">
        <input type="submit" value="筛选">
    </form>
</div>
</div>
<?php load_partial('footer'); ?>