Server IP : 43.241.58.20 / Your IP : 216.73.216.25 Web Server : Apache/2 System : Linux ns1-1556229.dragonhispeed.com 3.16.0 #1 SMP Fri Mar 29 22:50:14 MSK 2024 x86_64 User : ratsitne ( 1130) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/ratsitne/.trash/files/admin/ |
Upload File : |
<?php include '../config.php'; include 'auth.php'; $page_title = 'ใบกำกับภาษี/ใบเสร็จรับเงิน'; ob_start(); // Handle search $search_keyword = isset($_GET['search_keyword']) ? $_GET['search_keyword'] : ''; $date_filter = isset($_GET['date_filter']) ? $_GET['date_filter'] : ''; // Pagination settings $limit = 10; $page = isset($_GET['page']) ? $_GET['page'] : 1; $offset = ($page - 1) * $limit; // Build query $query = "SELECT i.*, c.company_name FROM invoices i LEFT JOIN customers c ON i.customer_id = c.id WHERE 1=1"; if ($search_keyword) { $query .= " AND (i.document_no LIKE '%$search_keyword%' OR i.customer_name LIKE '%$search_keyword%' OR c.company_name LIKE '%$search_keyword%')"; } if ($date_filter) { $date_parts = explode('/', $date_filter); if (count($date_parts) == 3) { $filter_date = $date_parts[2] . '-' . $date_parts[1] . '-' . $date_parts[0]; $query .= " AND i.document_date = '$filter_date'"; } } $query .= " ORDER BY i.id DESC LIMIT $limit OFFSET $offset"; $result = mysqli_query($conn, $query); // Get total records for pagination $total_query = "SELECT COUNT(*) as total FROM invoices i LEFT JOIN customers c ON i.customer_id = c.id WHERE 1=1"; if ($search_keyword) { $total_query .= " AND (i.document_no LIKE '%$search_keyword%' OR i.customer_name LIKE '%$search_keyword%' OR c.company_name LIKE '%$search_keyword%')"; } if ($date_filter) { $date_parts = explode('/', $date_filter); if (count($date_parts) == 3) { $filter_date = $date_parts[2] . '-' . $date_parts[1] . '-' . $date_parts[0]; $total_query .= " AND i.document_date = '$filter_date'"; } } $total_result = mysqli_query($conn, $total_query); $total_row = mysqli_fetch_assoc($total_result); $total_records = $total_row['total']; $total_pages = ceil($total_records / $limit); ?> <div class="card"> <div class="card-header"> <h3 class="card-title">ใบกำกับภาษี/ใบเสร็จรับเงิน</h3> <div class="card-tools"> <a href="<?php echo $admin_url; ?>/invoice-add.php" class="btn btn-primary">เพิ่มใบกำกับภาษี</a> </div> </div> <div class="card-body"> <?php if (isset($_SESSION['success_message'])): ?> <div class="alert alert-success alert-dismissible fade show"> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> <i class="bi bi-check-circle me-1"></i> <?php echo $_SESSION['success_message']; unset($_SESSION['success_message']); ?> </div> <?php endif; ?> <?php if (isset($_SESSION['error_message'])): ?> <div class="alert alert-danger alert-dismissible fade show"> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> <i class="bi bi-exclamation-triangle me-1"></i> <?php echo $_SESSION['error_message']; unset($_SESSION['error_message']); ?> </div> <?php endif; ?> <form method="GET" class="mb-3"> <div class="row"> <div class="col-md-5"> <input type="text" name="search_keyword" class="form-control" placeholder="ค้นหาเลขที่เอกสาร/ชื่อลูกค้า" value="<?php echo $search_keyword; ?>"> </div> <div class="col-md-3"> <input type="text" name="date_filter" class="form-control datepicker" placeholder="กรองตามวันที่" value="<?php echo $date_filter; ?>"> </div> <div class="col-md-4"> <button type="submit" class="btn btn-primary">ค้นหา</button> <a href="<?php echo $admin_url; ?>/invoice-list.php" class="btn btn-secondary">ล้างค่า</a> </div> </div> </form> <table class="table table-striped"> <thead> <tr> <th>เลขที่เอกสาร</th> <th>ลูกค้า</th> <th>วันที่เอกสาร</th> <th>ครบกำหนด</th> <th>มูลค่ารวม</th> <th>ภาษีมูลค่าเพิ่ม</th> <th>ยอดรวมทั้งสิ้น</th> <th style="width: 220px;"> </th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_assoc($result)): ?> <tr> <td><?php echo $row['document_no']; ?></td> <td><?php echo $row['customer_name']; ?></td> <td><?php echo date('d/m/Y', strtotime($row['document_date'])); ?></td> <td><?php echo $row['due_date'] ? date('d/m/Y', strtotime($row['due_date'])) : '-'; ?></td> <td class="text-end"><?php echo number_format($row['subtotal'], 2); ?></td> <td class="text-end"><?php echo number_format($row['vat'], 2); ?></td> <td class="text-end"><?php echo number_format($row['grand_total'], 2); ?></td> <td> <a href="<?php echo $admin_url . '/invoice-print-html.php?id=' . $row['id']; ?>" class="btn btn-info btn-sm" target="_blank"> <i class="bi bi-printer me-1"></i>พิมพ์ </a> <a href="<?php echo $admin_url . '/invoice-edit.php?id=' . $row['id']; ?>" class="btn btn-warning btn-sm"> <i class="bi bi-pencil-square me-1"></i>แก้ไข </a> <a href="<?php echo $admin_url . '/invoice-delete.php?id=' . $row['id']; ?>" class="btn btn-danger btn-sm" onclick="return confirm('ยืนยันการลบใบกำกับภาษีนี้?');"> <i class="bi bi-trash me-1"></i>ลบ </a> </td> </tr> <?php endwhile; ?> </tbody> </table> </div> <div class="card-footer clearfix"> <ul class="pagination pagination-sm m-0 float-end"> <?php for ($i = 1; $i <= $total_pages; $i++): ?> <li class="page-item <?php echo $i == $page ? 'active' : ''; ?>"> <a class="page-link" href="?page=<?php echo $i; ?>&search_keyword=<?php echo $search_keyword; ?>&date_filter=<?php echo $date_filter; ?>"><?php echo $i; ?></a> </li> <?php endfor; ?> </ul> </div> </div> <?php $content = ob_get_clean(); $js_script = '<script src="assets/js/invoice.js"></script>'; include 'template_master.php'; ?>