<?php
  include 'header.php';
  
	if (isset($_POST['delete'])) {
		$image = $_POST['image'];
		$tnumb = $_POST['tnumb'];
		$delete = mysqli_query($link, "DELETE FROM tracking WHERE tracking_number = '$tnumb' ");
		if ($tnumb) {
      mysqli_query($link, "DELETE FROM track_update WHERE track_num = '$tnumb' ");
      unlink("../uploads/".$image);
			echo "<script>alert('Deleted Successfully');window.location.href = 'dashboard.php' </script>";
			
		}
	}
?>

<style>
  .btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

/* Primary Button */
.btn-primary {
    background-color: #007bff;
    color: #fff;
    border: none;
}

.btn-primary:hover {
    background-color: #0056b3;
}

/* Danger Button */
.btn-danger {
    background-color: #dc3545;
    color: #fff;
    border: none;
}

.btn-danger:hover {
    background-color: #a71d2a;
}

/* Info Button */
.btn-info {
    background-color: #17a2b8;
    color: #fff;
    border: none;
}

.btn-info:hover {
    background-color: #117a8b;
}

/* Secondary Button */
.btn-secondary {
    background-color: #6c757d;
    color: #fff;
    border: none;
}

.btn-secondary:hover {
    background-color: #545b62;
}

/* Warning Button */
.btn-warning {
    background-color: #ffc107;
    color: #212529;
    border: none;
}

.btn-warning:hover {
    background-color: #d39e00;
}

/* General Button Styling */
.btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

</style>

    <!-- NFTmax Dashboard -->
    <section class="nftmax-adashboard nftmax-show">
      <div class="container-fulid">
        <div class="row">
          <div class="nftmax-adashboard-left">


              <div class="col-lg-12">
                <h4>TRACKERS</h4>
                <div class="tabel-main">
                  <table id="expendable-data-table" class="table display nowrap">
                    <thead>
                    <tr>
                          <th>#</th>
                          <th>Image</th>
                          <th>Tracking Number</th>
                          <th>Status</th>
                          <th>Date Added</th>
                          <th>Edit</th>
                          <th>Delete</th>
                          <th>Copy</th>
                          <th>View Details</th>
                          <th>View Updates</th>
                        </tr>
                    </thead>

                    <tbody>
                        
                        <?php 
                        $i = 0;
                        	$tr = mysqli_query($link, "SELECT * FROM tracking ");
                        	if (mysqli_num_rows($tr) > 0 ) {
                        		while ($row = mysqli_fetch_assoc($tr)) {
                        			$i++
                         ?>
                         <form method="post" action="dashboard.php">
                         	<input type="hidden" name="tnumb" value="<?php echo $row['tracking_number'] ?>">
                         <tr>
                         	<td><?php echo $i; ?></td>
                         	<td><img style="height: 90px;width: 90px;" src="../uploads/<?php echo $row['image'] ?>" ></td>
                          <td><b><?php echo $row['tracking_number'] ?></b></td>
                         	<td><b><?php echo $row['status'] ?></b></td>
                         	<td><b><?php echo $row['date'] ?></b></td>
                           <td><a style="background-color: blue;" href="edit-tracking.php?num=<?php echo $row['tracking_number'] ?>" class="btn btn-primary">Update</a></td>
        <td><button style="background-color: red;" type="submit" name="delete" onclick="return confirm('Do you really want to delete this?')" class="btn btn-danger">Delete</button></td>
        <td><button style="background-color: green;" type="button" onclick="copyContent()" class="btn btn-info">Copy Tracking Number</button></td>
        <td><a style="background-color: #ffc107;" class="btn btn-secondary" href="view-details.php?num=<?php echo $row['tracking_number'] ?>">View Details</a></td>
        <td><a style="background-color:rgb(81, 7, 255);" class="btn btn-warning" href="view-updates.php?num=<?php echo $row['tracking_number'] ?>">View Updates</a></td>
    </tr>
                         </tr>
                         <input type="hidden" id="tn<?php echo $row['id'] ?>" value="<?php echo $row['tracking_number'] ?>">
                         <input type="hidden" name="image" value="<?php echo $row['image'] ?>">
                         </form>
                            <script>
                              let text = document.getElementById('tn<?php echo $row['id'] ?>').value;
                              const copyContent = async () => {
                                try {
                                  await navigator.clipboard.writeText(text);
                                  alert("Copied the tracking number: " + text);
                                } catch (err) {
                                  // console.error('Failed to copy: ', err);
                                }
                              }
                            </script>
                     <?php }} ?>

                      </tbody>
                  </table>

                </div>
              </div>
            </div>
          </div>

          
        </div>
      </div>
    </section>
    <!-- End NFTmax Dashboard -->
  </div>

  <script src="assets/js/jquery-3.6.3.min.js"></script>
  <script src="assets/js/slick.min.js"></script>
  <script src="assets/js/bootstrap.bundle.min.js"></script>
  <script src="assets/js/custom.js"></script>


  <script>
    //Theme controll 
    let darkMode = false
    if (darkMode) {
      document.getElementById("dark-icon").style.setProperty("display", "block")
      document.getElementById("light-icon").style.setProperty("display", "none")
      document.getElementsByClassName("logo")[0].style.setProperty("display", "none")
      document.getElementsByClassName("logo-dark")[0].style.setProperty("display", "block")
    } else {
      document.getElementById("dark-icon").style.setProperty("display", "none")
      document.getElementById("light-icon").style.setProperty("display", "block")
      document.getElementsByClassName("logo")[0].style.setProperty("display", "block")
      document.getElementsByClassName("logo-dark")[0].style.setProperty("display", "none")
    }

    document.getElementById("theme-controll").addEventListener("click", event => {
      darkMode = !darkMode
      const main = document.querySelector("html")

      if (darkMode) {

        document.documentElement.style.setProperty("--headding-color", "#fff")
        document.documentElement.style.setProperty("--paragraph-color", "#E2E8F0")
        document.documentElement.style.setProperty("--primary-color", "#b8e2f2")
        document.documentElement.style.setProperty("--warning-color", "#FACC15")
        document.documentElement.style.setProperty("--alerts-color", "#FF4747")
        document.documentElement.style.setProperty("--other-color", "#FF784B")
        document.documentElement.style.setProperty("--grey-color", "#2A313C")
        document.documentElement.style.setProperty("--grey-color-border", "#edf2f7")
        document.documentElement.style.setProperty("--body-bg-color", "#23262B")
        document.documentElement.style.setProperty("--bg-color", "#1D1E24")
        document.documentElement.style.setProperty("--greyscale-3", "#191B1F")
        document.documentElement.style.setProperty("--greyscale-4", "#293644")
        document.documentElement.style.setProperty("--greyscale-200", "rgba(226, 232, 240, 0.7)")
        document.documentElement.style.setProperty("--greyscale-1", "#2A313C")
        document.documentElement.style.setProperty("--bg-color-2", "#23262B")

        document.getElementById("dark-icon").style.setProperty("display", "block")
        document.getElementById("light-icon").style.setProperty("display", "none")
        document.getElementsByClassName("logo")[0].style.setProperty("display", "none")
        document.getElementsByClassName("logo-dark")[0].style.setProperty("display", "block")
      } else {

        document.documentElement.style.setProperty("--headding-color", "#111827")
        document.documentElement.style.setProperty("--paragraph-color", "#747681")
        document.documentElement.style.setProperty("--primary-color", "#b8e2f2")
        document.documentElement.style.setProperty("--warning-color", "#FACC15")
        document.documentElement.style.setProperty("--alerts-color", "#FF4747")
        document.documentElement.style.setProperty("--other-color", "#FF784B")
        document.documentElement.style.setProperty("--grey-color", "#F7FAFC")
        document.documentElement.style.setProperty("--grey-color-border", "#edf2f7")
        document.documentElement.style.setProperty("--bg-color", "#FAFAFA")
        document.documentElement.style.setProperty("--body-bg-color", "#F6F6F6")
        document.documentElement.style.setProperty("--greyscale-200", "rgba(42, 49, 60, 0.7)")
        document.documentElement.style.setProperty("--greyscale-1", "#EDF2F7")
        document.documentElement.style.setProperty("--greyscale-3", "#EEEFF2")
        document.documentElement.style.setProperty("--greyscale-4", "#CBD5E0")
        document.documentElement.style.setProperty("--bg-color-2", "#f7fafc")
        document.getElementById("dark-icon").style.setProperty("display", "none")
        document.getElementById("light-icon").style.setProperty("display", "block")
        document.getElementsByClassName("logo")[0].style.setProperty("display", "block")
        document.getElementsByClassName("logo-dark")[0].style.setProperty("display", "none")
      }
    })
  </script>
</body>


<!-- Mirrored from quomodosoft.com/html/bankcohtml/transaction.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 04 Jan 2025 01:45:12 GMT -->
</html>