HEX
Server: LiteSpeed
System: Linux s1321.sgp1.mysecurecloudhost.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: usas (2047)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: /home/usas/swastikenterprises.usas.in/Admin/task.php
<?php
include 'include/header.php';

?>
<h1 class=" mt-4 mb-3">All Tasks</h1>
<div class="row">
  <div class="col-lg-6 col-md-6 col-sm-12"></div>
  <div class="col-lg-6 col-md-6 col-sm-12 text-right mb-3 cust-sheet">
    <form action="task_search.php" method = "GET">
      <input type="text" name="search_value" placeholder="Type to search..." style="width:200px;height: 35px;padding: 0px 10px;">
      <button type="submit" class="btn btn-danger">Search</button>
    </form>
  </div>
</div>
<?php
include 'Database/config.php';

$limit = 20;
if (isset($_GET['page'])) {
  $page = $_GET['page'];
  $serial = ($page - 1) * $limit + 1;
}else{
  $page = 1;
  $serial = 1;
}

$offset = ($page - 1) * $limit;

$sql = "SELECT task.id AS task_id, technician.*, task.*,customer1.cust_name AS cust_name1,
            customer2.cust_name AS cust_name2,customer3.cust_name AS cust_name3,
            customer4.cust_name AS cust_name4,
            customer5.cust_name AS cust_name5,
            customer6.cust_name AS cust_name6,
            customer7.cust_name AS cust_name7,
            customer8.cust_name AS cust_name8,
            customer9.cust_name AS cust_name9,
            customer10.cust_name AS cust_name10
        FROM `task`
        LEFT JOIN technician ON technician.id = task.t_id 
        LEFT JOIN customers AS customer1 ON customer1.cust_id = task.cust_id1
        LEFT JOIN customers AS customer2 ON customer2.cust_id = task.cust_id2
        LEFT JOIN customers AS customer3 ON customer3.cust_id = task.cust_id3
        LEFT JOIN customers AS customer4 ON customer4.cust_id = task.cust_id4
        LEFT JOIN customers AS customer5 ON customer5.cust_id = task.cust_id5
        LEFT JOIN customers AS customer6 ON customer6.cust_id = task.cust_id6
        LEFT JOIN customers AS customer7 ON customer7.cust_id = task.cust_id7
        LEFT JOIN customers AS customer8 ON customer8.cust_id = task.cust_id8
        LEFT JOIN customers AS customer9 ON customer9.cust_id = task.cust_id9
        LEFT JOIN customers AS customer10 ON customer10.cust_id = task.cust_id10 ORDER BY task_id DESC
        LIMIT {$offset},{$limit}";

$serial = 1;
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) >0) {
  

?>
<div class="row">
  <div class="table-responsive" style="overflow-x:auto;">
  <table class="table table-striped table-dark table-bordered">
  <thead>
    <tr>
      <th scope="col" style="font-size:12px;">#</th>
      <th scope="col" style="font-size:12px;">Tech Name</th>
      <!--<th scope="col" style="font-size:12px;">Email</th>-->
      <th scope="col" style="font-size:12px;">Task1</th>
      <th scope="col" style="font-size:12px;">Task2</th>
      <!--<th scope="col" style="font-size:12px;">Service</th>-->
      <th scope="col" style="font-size:12px;">Task3</th>
      <th scope="col" style="font-size:12px;">Task4</th>
      <th scope="col" style="font-size:12px;">Task5</th>
      <th scope="col" style="font-size:12px;">Task6</th>
      <th scope="col" style="font-size:12px;">Task7</th>
      <th scope="col" style="font-size:12px;">Task8</th>
      <th scope="col" style="font-size:12px;">Task9</th>
      <th scope="col" style="font-size:12px;">Task10</th>
      <th scope="col" style="font-size:12px;" class="bg-danger">Task Date</th>
      <!--<th scope="col" style="font-size:12px;">View</th>-->
      <th scope="col" style="font-size:12px;">Edit</th>
      <th scope="col" style="font-size:12px;">Print</th>
    </tr>
  </thead>
  <tbody>
    <?php
    while ($row = mysqli_fetch_assoc($result)) {

    ?>
    <tr>
      <th style="font-size:12px;"><?php echo $serial++;?></th>
      <td style="font-size:12px;"><?php echo $row['username'];?></td>
      <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name1'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph1'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address1'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product1'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname1'];?></h6>
         <?php
        if ($row['task1']) {
           echo "<h6 class='text-white'>Job : " . $row['task1'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>
      </td>
     <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name2'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph2'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address2'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product2'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname2'];?></h6>

         <?php
        if ($row['task2']) {
           echo "<h6 class='text-white'>Job : " . $row['task2'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>
      </td>
      <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name3'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph3'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address3'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product3'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname3'];?></h6>
         <?php
        if ($row['task3']) {
           echo "<h6 class='text-white'>Job : " . $row['task3'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>
      </td>
      <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name4'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph4'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address4'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product4'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname4'];?></h6>
         <?php
        if ($row['task4']) {
           echo "<h6 class='text-white'>Job : " . $row['task4'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>
       </td>
       <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name5'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph5'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address5'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product5'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname5'];?></h6>
         <?php
        if ($row['task5']) {
           echo "<h6 class='text-white'>Job : " . $row['task5'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>

      </td>
      <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name6'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph6'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address6'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product6'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname6'];?></h6>
         <?php
        if ($row['task6']) {
           echo "<h6 class='text-white'>Job : " . $row['task6'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>

      </td>
       <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name7'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph7'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address7'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product7'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname7'];?></h6>
         <?php
        if ($row['task7']) {
           echo "<h6 class='text-white'>Job : " . $row['task7'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>

      </td>
       <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name8'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph8'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address8'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product8'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname8'];?></h6>
         <?php
        if ($row['task8']) {
           echo "<h6 class='text-white'>Job : " . $row['task8'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>

      </td>
       <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name9'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph9'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address9'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product9'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname9'];?></h6>
         <?php
        if ($row['task9']) {
           echo "<h6 class='text-white'>Job : " . $row['task9'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>

      </td>
       <td style="font-size:12px;">
        <h6 class="text-white">Cust Name : <?php echo $row['cust_name10'];?></h6>
         <h6 class="text-white">Cust No : <?php echo $row['cust_ph10'];?></h6>
         <h6 class="text-white">Cust Address : <?php echo $row['cust_address10'];?></h6>
         <h6 class="text-white">Product : <?php echo $row['cust_product10'];?></h6>
         <h6 class="text-white">Product Name : <?php echo $row['cust_productname10'];?></h6>
         <?php
        if ($row['task10']) {
           echo "<h6 class='text-white'>Job : " . $row['task10'] . "<h6>";
        }else{
          echo "<h6 class='text-white'>Job : - <h6>";
        }
        ?>

      </td>
      <td  style="font-size:12px;"><?php echo $row['date'];?></td>
     <td style="font-size:12px;">
  <?php
    $check_sql = "SELECT id FROM task_deliver 
                  WHERE tech_id = '{$row['t_id']}' 
                  AND task1_date = '{$row['date']}' 
                  LIMIT 1";
    $check_result = mysqli_query($conn, $check_sql);

    if (mysqli_num_rows($check_result) == 0) {
        // show edit icon only if NOT submitted
  ?>
      <a href="update-task.php?id=<?php echo $row['task_id']; ?>" style="color:#fff;">
        <i class="fa fa-edit"></i>
      </a>
  <?php
    }else {
        // Submitted → show "Cannot be edited"
        echo '<i class="fa fa-lock" aria-hidden="true"></i>';
    }
  ?>
</td>




      <td  style="font-size:12px;cursor:pointer;"><i class="fa fa-print" onclick="window.print()"></i></td>
    </tr>
    <?php       
    }
    ?>

  </tbody>
</table>
</div>
</div>

<?php } ?>

<!--Updated Code-->
<?php
$sql1 = "SELECT * FROM task";
$result1 = mysqli_query($conn, $sql1) or die('query failed');
if (mysqli_num_rows($result1) > 0) {
  $total_records = mysqli_num_rows($result1);
  
  $total_pages = ceil($total_records / $limit);
  echo '<ul class="pagination mt-3">';

  if ($page > 1) {
    echo '<li><a class="page-link" href="task.php?page='.($page - 1).'">Prev</a></li>';
  }

  for ($i = 1; $i <= $total_pages; $i++) { 
    $active = ($i == $page) ? "active" : "";
    echo '<li class="page-item '.$active.'"><a class="page-link" href="task.php?page='.$i.'">'.$i.'</a></li>';
  }

  if ($total_pages > $page) {
    echo '<li><a class="page-link" href="task.php?page='.($page + 1).'">Next</a></li>';
  }

  echo "</ul>";
}

?>

<!--Updated Code End-->

  <!--<ul class="pagination admin-pagination">
    <li class="page-item">
      <a class="page-link" href="#" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
        <span class="sr-only">Previous</span>
      </a>
    </li>
    <li class="page-item"><a class="page-link" href="#">1</a></li>
    <li class="page-item"><a class="page-link" href="#">2</a></li>
    <li class="page-item"><a class="page-link" href="#">3</a></li>
    <li class="page-item">
      <a class="page-link" href="#" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
        <span class="sr-only">Next</span>
      </a>
    </li>
  </ul>-->

<?php
include 'include/footer.php';

?>