EVOLUTION-NINJA
Edit File: dealerlist.php
<?php echo view('includes/sidebar'); ?> <script type="text/javascript" src="<?php echo base_url('public/assets/js/jquery-3.6.0.min.js'); ?>"></script> <script src="<?php echo base_url('public/assets/toastr/toastr.min.js');?>"></script> <link rel="stylesheet" href="<?php echo base_url('public/assets/toastr/toastr.min.css');?>"> <link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script> <style> .table-responsive{ overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; } #datatable{ width: 100% !important; } #datatable th, #datatable td{ white-space: nowrap; vertical-align: middle; } </style> <section class="home-section"> <div class="home-content"> <!--<i class='bx bx-menu'></i>--> </div> <div class="row m-0"> <div class="col-sm-12"> <h1 class="crt-pjt">Dealer List</h1> </div> </div> <!-- FILTER FORM --> <form method="GET" id="searchForm"> <div class="row m-0"> <div class="constuency_page"> <div class="constuencydetails"> <div class="constuencydetail row"> <div class="col-sm-4"> <label class="form-label inpfieldname">Dealer Name</label> <select id="dealerName" name="name" class="form-control fieldsbox"> <option value="">Select Dealer</option> <?php if(!empty($dealers)): ?> <?php foreach($dealers as $d): ?> <option value="<?= $d['name'] ?>" <?= (isset($_GET['name']) && $_GET['name'] == $d['name']) ? 'selected' : '' ?>> <?= $d['name'] ?> </option> <?php endforeach; ?> <?php endif; ?> </select> </div> </div> </div> </div> <div class="col-sm-6 buttns-cnl"> <button type="submit" class="submit" style="width:200px">Get Report</button> </div> </div> </form> <br><br> <!-- TABLE --> <!--<div class="container-fluid inp-lbl">--> <!-- <table id="datatable" class="display">--> <div class="container-fluid inp-lbl table-responsive"> <table id="datatable" class="display nowrap" style="width:100%"> <thead> <tr> <th>SL NO</th> <th>Dealer Code</th> <th>Name</th> <th>Mobile</th> <th>Email</th> <th>District</th> <th>Address</th> <th>PAN No</th> <th>GST %</th> <th>TAN No</th> <th>Contact Person</th> <th>Contact Person Mobile</th> <th>Action</th> </tr> </thead> <tbody> <?php if(!empty($dealers)): ?> <?php $i=1; foreach($dealers as $d): ?> <tr> <td><?= $i++ ?></td> <td><?= $d['dealer_code'] ?></td> <td><?= $d['name'] ?></td> <td><?= $d['mobile'] ?></td> <td><?= $d['email'] ?></td> <td><?= $d['address'] ?></td> <td><?= $d['district'] ?></td> <td><?= $d['pan_no'] ?></td> <td><?= $d['gst_percent'] ?>%</td> <td><?= $d['tan_no'] ?></td> <td><?= $d['contact_person'] ?></td> <td><?= $d['contact_person_mobile'] ?></td> <td style="display:flex; gap:5px;"> <a href="<?= base_url('dealer-edit/'.$d['id']) ?>" class="btn edit--butt" style="background:blue;color:white;"> Edit </a> <a href="<?= base_url('dealer-delete/'.$d['id']) ?>" class="btn delete--butt" style="background:red;color:white;" onclick="return confirm('Delete this dealer?')"> Delete </a> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </section> <script> $(document).ready(function () { $('#datatable').DataTable({ scrollX: true, autoWidth: false }); // ✅ REMOVE QUERY PARAM AFTER SEARCH (IMPORTANT FIX) if (window.location.search) { window.history.replaceState({}, document.title, window.location.pathname); } let input = $("#dealerName"); let suggestionBox = $("#nameSuggestions"); let dropdownIcon = $("#dropdownIcon"); let history = JSON.parse(localStorage.getItem("dealerSearchHistory")) || []; function renderList(list) { suggestionBox.empty(); if (list.length === 0) { suggestionBox.hide(); return; } list.forEach(name => { let item = $("<div>" + name + "</div>"); item.css({ padding: "8px", cursor: "pointer" }); item.hover( function () { $(this).css("background", "#f1f1f1"); }, function () { $(this).css("background", "#fff"); } ); item.click(function () { input.val(name); suggestionBox.hide(); }); suggestionBox.append(item); }); suggestionBox.show(); } dropdownIcon.click(function () { renderList(history); }); input.on("keyup", function () { let value = $(this).val().toLowerCase(); let filtered = history.filter(item => item.toLowerCase().includes(value)); renderList(filtered); }); $("#searchForm").submit(function () { let value = input.val().trim(); if (value && !history.includes(value)) { history.unshift(value); if (history.length > 10) history.pop(); localStorage.setItem("dealerSearchHistory", JSON.stringify(history)); } }); $(document).click(function (e) { if (!$(e.target).closest("#dealerName, #nameSuggestions, #dropdownIcon").length) { suggestionBox.hide(); } }); }); </script> <!-- ✅ TOASTR FLASH MESSAGE --> <script> <?php if(session()->getFlashdata('msg')): ?> toastr.success("<?= session()->getFlashdata('msg'); ?>"); <?php endif; ?> <?php if(session()->getFlashdata('error')): ?> toastr.error("<?= session()->getFlashdata('error'); ?>"); <?php endif; ?> </script> <?php echo view('includes/footer'); ?>