function show_records() { $category_ids = isset($_SESSION['filters']['categories']) ? $_SESSION['filters']['categories'] : null; $detail = isset($_SESSION['filters']['detail']) ? $_SESSION['filters']['detail'] : null; $from_date = isset($_SESSION['filters']['from_date']) ? $_SESSION['filters']['from_date'] : null; $to_date = isset($_SESSION['filters']['to_date']) ? $_SESSION['filters']['to_date'] : null; $from_amount = isset($_SESSION['filters']['from_amount']) ? $_SESSION['filters']['from_amount'] : null; $to_amount = isset($_SESSION['filters']['to_amount']) ? $_SESSION['filters']['to_amount'] : null; $description = isset($_SESSION['filters']['description']) ? $_SESSION['filters']['description'] : null; $filter = new CFilter(0, $category_ids, $detail, $from_date, $to_date, $from_amount, $to_amount, $description); CRecordManager::SetFilter($filter); $records = CRecordManager::GetRecords(); if ($records) { ?> <div class="table"> <table class="list"> <tr> <th>Category</th> <th>Detail</th> <th>Time</th> <th>Amount</th> <!-- <th>Description</th> --> <th>Edit</th> <th>Delete</th> </tr> <?php for ($i = 0; $i < count($records); $i++) { $record = $records[$i]; if ($i % 2 == 0) { echo "<tr class='alt'>"; } else { echo "<tr>"; } echo "\t<td>" . $record->GetCategory()->GetName() . "</td>"; echo "\t<td>" . $record->GetDetail() . " </td>"; echo "\t<td>" . date("Y-m-d H:i", $record->GetTime()) . "</td>"; echo "\t<td class='number_cell'>" . $record->GetAmount() . "</td>"; echo "\t<!-- <td>" . $record->GetDescription() . " </td>-->"; echo "\t<td class='image_cell'><a href='edit_record.php?id=" . $record->GetId() . "'><img src='image/edit_btn.png' /></a></td>"; echo "\t<td class='image_cell'><a href='deleting_record.php?id=" . $record->GetId() . "'><img src='image/delete_btn.png' /></a></td>"; echo "<tr/>"; } ?> </table> </div> <!-- End of table --> <?php } else { echo "There is no any record"; } }
function list_detail() { $category_ids = isset($_SESSION['filters']['categories']) ? $_SESSION['filters']['categories'] : null; $detail = isset($_SESSION['filters']['detail']) ? $_SESSION['filters']['detail'] : null; $from_date = isset($_SESSION['filters']['from_date']) ? $_SESSION['filters']['from_date'] : null; $to_date = isset($_SESSION['filters']['to_date']) ? $_SESSION['filters']['to_date'] : null; $from_amount = isset($_SESSION['filters']['from_amount']) ? $_SESSION['filters']['from_amount'] : null; $to_amount = isset($_SESSION['filters']['to_amount']) ? $_SESSION['filters']['to_amount'] : null; $description = isset($_SESSION['filters']['description']) ? $_SESSION['filters']['description'] : null; $filter = new CFilter(0, $category_ids, $detail, $from_date, $to_date, $from_amount, $to_amount, $description); CRecordManager::SetFilter($filter); $records = CRecordManager::GetRecords(); if ($records) { $num = CRecordManager::GetNumberOfRecord(); if ($num < 2) { echo "<p>There is {$num} record</p>"; } else { echo "<p>There are {$num} records</p>"; } $filter = CRecordManager::GetFilter(); if ($filter->IsFiltering()) { $total_money = CStatistic::GetTotalMoney($filter); echo "<p>Total: {$total_money}</p>"; } echo "<table border='1' cellspacing='0'>"; echo "<tr>"; echo "\t<th>ID</th>"; echo "\t<th>Category</th>"; echo "\t<th>Detail</th>"; echo "\t<th>Time</th>"; echo "\t<th>Amount</th>"; echo "\t<th>Description</th>"; echo "\t<th colspan='2'>Action</th>"; echo "</tr>"; foreach ($records as $record) { echo "<tr>"; echo "\t<td>" . $record->GetId() . "</td>"; echo "\t<td>" . $record->GetCategory()->GetName() . "</td>"; echo "\t<td>" . $record->GetDetail() . " </td>"; echo "\t<td>" . date("Y-m-d H:i", $record->GetTime()) . "</td>"; echo "\t<td>" . $record->GetAmount() . "</td>"; echo "\t<td>" . $record->GetDescription() . " </td>"; echo "\t<td><a href='detail.php?action_type=edit&id=" . $record->GetId() . "'>Edit</a></td>"; echo "\t<td><a href='detail.php?action_type=delete&id=" . $record->GetId() . "'>Delete</a></td>"; echo "<tr/>"; } echo "</table>"; } else { echo "There is no any record"; } }