Файловый менеджер - Редактировать - /home/d46091/invoice.ecogenix.in/challan.php
Назад
<?php // Include database connection require_once('includes/connection.php'); // Pagination and Filter Setup $records_per_page = 10; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $offset = ($page - 1) * $records_per_page; // Search Filters $search_condition = []; if (!empty($_GET['challan_no'])) { $challan_no = mysqli_real_escape_string($conn, $_GET['challan_no']); $search_condition[] = "challan_no LIKE '%$challan_no%'"; } if (!empty($_GET['start_date']) && !empty($_GET['end_date'])) { $start_date = mysqli_real_escape_string($conn, $_GET['start_date']); $end_date = mysqli_real_escape_string($conn, $_GET['end_date']); $search_condition[] = "date BETWEEN '$start_date' AND '$end_date'"; } $where_clause = ''; if (!empty($search_condition)) { $where_clause = ' WHERE ' . implode(' AND ', $search_condition) . ' AND status = 1'; } else { $where_clause = ' WHERE status = 1'; } // Count total records $total_query = "SELECT COUNT(*) as total FROM road_challans $where_clause"; $total_result = mysqli_query($conn, $total_query); $total_row = mysqli_fetch_assoc($total_result); $total_records = $total_row['total']; $total_pages = ceil($total_records / $records_per_page); // Get filtered records $query = "SELECT * FROM road_challans $where_clause ORDER BY created_at DESC LIMIT $offset, $records_per_page"; $result = mysqli_query($conn, $query); // Include header require_once('includes/header.php'); ?> <style> .container { max-width: 1200px; margin: 0 auto; background-color: #fff; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h1 { text-align: center; margin-bottom: 30px; color: #333; } .actions { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; } .search-form { display: flex; width: 60%; } /* .search-form input[type="text"] { flex-grow: 1; padding: 8px; border: 1px solid #ddd; border-radius: 4px 0 0 4px; } */ /* .search-form button { padding: 8px 15px; background-color: #4CAF50; color: white; border: none; cursor: pointer; border-radius: 0 4px 4px 0; } */ .add-new { padding: 8px 15px; background-color: #2196F3; color: white; text-decoration: none; border-radius: 4px; } table { width: 100%; border-collapse: collapse; margin-bottom: 20px; } table, th, td { border: 1px solid #ddd; } th { background-color: #f2f2f2; padding: 12px; text-align: left; } td { padding: 10px; } tr:nth-child(even) { background-color: #f9f9f9; } tr:hover { background-color: #f1f1f1; } .action-buttons { display: flex; gap: 5px; } .action-buttons a { padding: 5px 10px; color: white; text-decoration: none; border-radius: 3px; font-size: 12px; } .view-btn { background-color: #2196F3; } .print-btn { background-color: #4CAF50; } .edit-btn { background-color: #FF9800; } .bill-btn { /* color: #000000 !important; */ background-color: #c20000; } /* .s */ .delete-btn { background-color: #F44336; } .pagination { display: flex; justify-content: center; margin-top: 20px; } .pagination a, .pagination span { padding: 8px 16px; text-decoration: none; color: #000; background-color: #f1f1f1; margin: 0 4px; border-radius: 5px; } .pagination a.active, .pagination a:hover { background-color: #4CAF50; color: white; } .no-data { text-align: center; padding: 20px; color: #777; } </style> <div class="content"> <nav class="navbar navbar-expand-lg navbar-light bg-light mb-4"> <div class="container-fluid"> <button id="sidebarToggle" class="btn btn-outline-secondary d-md-none mr-auto"> <span class="navbar-toggler-icon"></span> </button> <a class="navbar-brand d-md-none" href="#">ECOGENIX</a> <div class="d-flex"> <!-- <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> --> <!-- <button class="btn btn-outline-success" type="submit">Search</button> --> </div> </div> </nav> <div class="container"> <h1>All Road Challans</h1> <div class="card" style="overflow-x: auto;"> <div class="row m-3"> <form method="GET" class="search-form"> <div class="col-md-4"> <input class="form-control" type="text" name="challan_no" placeholder="Challan No" value="<?php echo isset($_GET['challan_no']) ? htmlspecialchars($_GET['challan_no']) : ''; ?>"> </div> <div class="col-md-4"> <input class="form-control" type="date" name="start_date" value="<?php echo isset($_GET['start_date']) ? htmlspecialchars($_GET['start_date']) : ''; ?>"> </div> <div class="col-md-4"> <input class="form-control" type="date" name="end_date" value="<?php echo isset($_GET['end_date']) ? htmlspecialchars($_GET['end_date']) : ''; ?>"> </div> <div class="col-md-4"> <button class="btn btn-success" type="submit">Filter</button> <a href="challan.php" class="btn btn-warning">Reset</a> </div> </form> </div> </div> <form id="challanForm" method="GET" action="challan_invoice.php" style="overflow-x: auto;"> <div class="actions"> <a href="add_challan.php" class="add-new">Book New Challan</a> <a href="view_invoices.php" class="add-new">View Invoice</a> <button type="submit" class="btn btn-success">Generate Invoice</button> </div> <?php if (mysqli_num_rows($result) > 0): ?> <table> <thead> <tr> <th> <input type="checkbox" id="selectAll"> </th> <th>Challan No.</th> <th>Challan Date</th> <th>Company Name</th> <th>Customer Name</th> <th>Vehicle No.</th> <th>Purchase Order</th> <th>Created By</th> <th>Genrated Invoice</th> <th>Actions</th> </tr> </thead> <tbody> <?php $colorMap = []; $colors = ['#f8f9fa', '#e3f2fd', '#e8f5e9', '#fff3e0', '#f3e5f5', '#fce4ec', '#ede7f6', '#e0f7fa']; $colorIndex = 0; // First pass to assign colors to each unique (consignorName + name) mysqli_data_seek($result, 0); while ($row = mysqli_fetch_assoc($result)) { $key = $row['consignorName'] . '|' . $row['name']; // ✅ Match both fields if (!isset($colorMap[$key])) { $colorMap[$key] = $colors[$colorIndex % count($colors)]; $colorIndex++; } } mysqli_data_seek($result, 0); ?> <?php while ($row = mysqli_fetch_assoc($result)): ?> <?php $key = $row['consignorName'] . '|' . $row['name']; $bgColor = $colorMap[$key]; ?> <tr style="background-color: <?php echo $bgColor; ?>;" data-name="<?php echo htmlspecialchars($row['name']); ?>" data-company="<?php echo htmlspecialchars($row['consignorName']); ?>"> <td> <input type="checkbox" class="selectItem" name="challans[]" value="<?php echo $row['challan_no']; ?>"> <input type="hidden" name="challan_dates[<?php echo $row['challan_no']; ?>]" value="<?php echo $row['date']; ?>"> <input type="hidden" name="company_name" value="<?php echo $row['consignorName']; ?>"> <input type="hidden" name="customer_name" value="<?php echo $row['name']; ?>"> <input type="hidden" name="vehicle_data[<?php echo $row['challan_no']; ?>]" value="<?php echo $row['vehicle_no']; ?>"> </td> <td><?php echo htmlspecialchars($row['challan_no']); ?></td> <td><?php echo htmlspecialchars($row['date']); ?></td> <td><?php echo htmlspecialchars($row['consignorName']); ?></td> <td><?php echo htmlspecialchars($row['name']); ?></td> <td><?php echo htmlspecialchars($row['vehicle_no']); ?></td> <td><?php echo htmlspecialchars($row['purchase_order_no']); ?></td> <td><?php echo htmlspecialchars($row['created_by']); ?></td> <td><?php echo htmlspecialchars($row['chalan_inv'] ?? 'N/A'); ?></td> <td class="action-buttons"> <a href="print_challan.php?id=<?php echo $row['id']; ?>" class="print-btn">Print Challan</a> <a href="print_sale_invoice.php?id=<?php echo $row['id']; ?>" class="edit-btn">Print Inv</a> <?php if (empty($row['bill_book_vendor'])): ?> <a href="bill_book.php?id=<?php echo $row['id']; ?>" class="bill-btn">Book Cost</a> <?php endif; ?> <a href="update_challan.php?id=<?php echo $row['id']; ?>" class="view-btn">Edit</a> <!-- Delete Button --> <a href="#" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#deleteModal" data-id="<?php echo $row['id']; ?>"> Delete </a> </td> </tr> <?php endwhile; ?> </tbody> </table> <?php endif; ?> </form> <!-- Bootstrap Delete Confirmation Modal --> <div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="deleteModalLabel">Confirm Deletion</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> Are you sure you want to delete this challan? </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> <a id="confirmDeleteBtn" class="btn btn-danger" href="#">Yes, Delete</a> </div> </div> </div> </div> <script> const deleteModal = document.getElementById('deleteModal'); deleteModal.addEventListener('show.bs.modal', function(event) { const button = event.relatedTarget; const id = button.getAttribute('data-id'); const confirmDeleteBtn = deleteModal.querySelector('#confirmDeleteBtn'); confirmDeleteBtn.href = 'delete_challan.php?id=' + id; }); </script> <script> document.getElementById("selectAll").addEventListener("change", function() { const checkboxes = document.querySelectorAll(".selectItem"); checkboxes.forEach(cb => cb.checked = this.checked); }); </script> </div> </div> <?php // Include footer require_once('includes/footer.php'); // Close the database connection mysqli_close($conn); ?> <script> document.getElementById("challanForm").addEventListener("submit", function(e) { const selected = Array.from(document.querySelectorAll(".selectItem:checked")); if (selected.length === 0) { alert("Please select at least one challan to generate an invoice."); e.preventDefault(); return; } let baseCustomer = null; let baseCompany = null; let consistent = true; selected.forEach(cb => { const row = cb.closest("tr"); const customer = row.dataset.name; const company = row.dataset.company; console.log("Checking:", customer, company); // DEBUG if (baseCustomer === null && baseCompany === null) { baseCustomer = customer; baseCompany = company; } else { if (baseCustomer !== customer || baseCompany !== company) { consistent = false; } } }); if (!consistent) { alert("All Selected challans having different customer and company."); e.preventDefault(); // Stop form submission } }); </script>
| ver. 1.4 |
Github
|
.
| PHP 8.1.32 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка