<?php
include("db/cn.php");
if(isset($_SESSION['user_name']) && isset($_SESSION['user_role'])&& isset($_SESSION['outlet_name'])
&& isset($_SESSION['outlet_address'])) {
    $userName = $_SESSION['user_name'];
    $userRole = $_SESSION['user_role'];
	$outlet_address = $_SESSION['outlet_address'];
	$outlet_name = $_SESSION['outlet_name'];
}
$customer = $_GET["customer_name"];

if($_POST){
// Retrieving form data using $_POST
$customerCode = $_POST['customerCode'];
$processNo = $_POST['processNo'];
$processDate = $_POST['processDate'];
$cnicNo = $_POST['cnicNo'];
$cellNo = $_POST['cellNo'];
$affidavit = $_POST['affidavit'];
$CcustomerName = $_POST['CcustomerName'];
$soDoWo = $_POST['soDoWo'];
$occupation = $_POST['occupation'];
$businessName = $_POST['businessName'];
$resAddress = $_POST['resAddress'];
$offAddress = $_POST['offAddress'];
$monthlyIncome = $_POST['monthlyIncome'];
$sinceLiving = $_POST['sinceLiving'];
$sinceWorking = $_POST['sinceWorking'];
$houseOwner = $_POST['houseOwner'];
$married = $_POST['married'];
$inquiryOfficer = $_POST['inquiryOfficer'];
$recovery = $_POST['recovery'];
$marketingBy = $_POST['marketingBy'];
$manager = $_POST['manager'];
$chequeType = $_POST['chequeType'];
$noOfCheques = $_POST['noOfCheques'];
$chequeAmount = $_POST['chequeAmount'];
$chequeReturned = $_POST['chequeReturned'];
$company = $_POST['company'];
$department = $_POST['department'];
$designation = $_POST['designation'];
$employeeNo = $_POST['employeeNo'];
$zonalManager = $_POST['zonalManager'];
$regionalManager = $_POST['regionalManager'];
$crcBy = $_POST['crcBy'];
$guarName = $_POST['guarName'];
$guarCnicNo = $_POST['guarCnicNo'];
$guarOccupation = $_POST['guarOccupation'];
$guarValue = $_POST['guarValue'];
$guarRelation = $_POST['guarRelation'];
$guarAddress = $_POST['guarAddress'];
$guarBusinessName = $_POST['guarBusinessName'];
$guarResAddress = $_POST['guarResAddress'];
$guarOffAddress = $_POST['guarOffAddress'];
$guarTelRes = $_POST['guarTelRes'];
$guarTelOff = $_POST['guarTelOff'];
$guarNicIssue = $_POST['guarNicIssue'];
$guarAffidavit = $_POST['guarAffidavit'];

// Insert query
$query = "INSERT INTO lease (
    customerCode, processNo, processDate, cnicNo, cellNo, affidavit, 
    CcustomerName, soDoWo, occupation, businessName, resAddress, 
    offAddress, monthlyIncome, sinceLiving, sinceWorking, houseOwner, 
    married, inquiryOfficer, recovery, marketingBy, manager, chequeType, 
    noOfCheques, chequeAmount, chequeReturned, company, department, 
    designation, employeeNo, zonalManager, regionalManager, crcBy, 
    guarName, guarCnicNo, guarOccupation, guarValue, guarRelation, 
    guarAddress, guarBusinessName, guarResAddress, guarOffAddress, 
    guarTelRes, guarTelOff, guarNicIssue, guarAffidavit) 
VALUES (
    '$customerCode', '$processNo', '$processDate', '$cnicNo', '$cellNo', '$affidavit', 
    '$CcustomerName', '$soDoWo', '$occupation', '$businessName', '$resAddress', 
    '$offAddress', '$monthlyIncome', '$sinceLiving', '$sinceWorking', '$houseOwner', 
    '$married', '$inquiryOfficer', '$recovery', '$marketingBy', '$manager', '$chequeType', 
    '$noOfCheques', '$chequeAmount', '$chequeReturned', '$company', '$department', 
    '$designation', '$employeeNo', '$zonalManager', '$regionalManager', '$crcBy', 
    '$guarName', '$guarCnicNo', '$guarOccupation', '$guarValue', '$guarRelation', 
    '$guarAddress', '$guarBusinessName', '$guarResAddress', '$guarOffAddress', 
    '$guarTelRes', '$guarTelOff', '$guarNicIssue', '$guarAffidavit')";

// Execute query and check for errors
if ($connection->query($query) === TRUE) {
    echo "New lease record created successfully!";
} else {
    echo "Error: " . $query . "<br>" . $connection->error;
}

// Close connection

}
?>
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Lease Form</title>
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="css/custom_css.css" />
  
</head>

<style>
     .form-control {
            height: 30px;
			font-size:14px;
            
           
             /* Adjust as needed */
        }
 #product-container-wrapper {
    max-height: 700px; /* Adjust the maximum height as needed */
    overflow-y: auto; /* Enable vertical scroll when content overflows */
}
/* Custom styles for sidebar */
 #table-container-wrapper {
    max-height: 500px; /* Adjust the maximum height as needed */
    overflow-y: auto; /* Enable vertical scroll when content overflows */
}
@media (max-width: 880px) {
    .col-4 {
        width: 33.33% !important;
    }
    .fa-wifi {
        display: none !important;
    }
    .col-6 {
        width: 50% !important;
    }
}

@media (min-width: 880px) {
    .sidebar {
        width: 100%;
        /* Change sidebar width to 100% on mobile */
        max-width: 120px; /* Set maximum width for the sidebar */
    }
}

@media (min-width: 880px) {
    .main-content {
        margin-left: ; /* Width of the sidebar */
    }
}

/* Added new class to control overlay */
.overlay {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999;
    display: none; /* Initially hidden */
}
    /* Custom styles for sidebar */
    .sidebar {
        width: 100px;
        background: linear-gradient(360deg, #060606, #503F2E);
        position: fixed;
        bottom: 0;
        top: 60px;
        transition: transform 0.3s ease-in-out;
        transform: translateX(0);
        z-index: 1;
        height: 100%;
        border-radius: 0px;
		   transition: transform 0.3s ease-in-out, width 0.3s ease-in-out;
    }

    .sidebar.hide {
        transform: translateX(-100px);
        /* Move sidebar out of the viewport when it is hidden */
    }

    .sidebar .nav-item {
        padding: 10px 0;
        text-align: center;
        position: relative;
        font-size: 12px;
    }

    .sidebar .nav-link {
        color: #fff;
        position: relative;
        /* Ensure icon and text are positioned relative to the nav link */
        z-index: 2;
        /* Ensure the text and icon are above the hover background */
    }

    .sidebar .nav-link i {
        margin-bottom: 5px;
        /* Adjust the margin of the icon */
    }

    /* Custom styles for hover effect */
    .sidebar .nav-item:hover:after {
        background-color: #fff;
        content: '';
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
        /* Ensure the hover background is below the text and icon */
    }

    .sidebar .nav-item:hover .nav-link {
        color: #0A5064;
    }

    /* Custom styles for divider */
    .sidebar .nav-item:after {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 1px;
        background-color: #fff;
        transition: height 0.3s ease-in-out;
        /* Transition effect for smooth animation */
    }

    /* Custom styles for header */
    .header {
        background: linear-gradient(270deg, #060606, #503F2E);
        color: #fff;
        padding: 10px;
        position: fixed;
        top: 0;
        width: 100%;
        z-index: 2;
        height: 69px;
        box-shadow: #FFF 2px 0px 0px 0px;
        /* Ensure header appears above sidebar */
    }

    .header .navbar-toggler {
        color: #fff;
    }

    .header .navbar-toggler-icon {
        color: #fff;
        /* Set the color of the toggle button to white */
    }

    .header .navbar-toggler.white {
        color: #fff !important;
        /* Ensure the toggle button is white */
    }

    .header .navbar-brand {
        color: #fff;
        /* Set navbar brand text color to white */
    }

    .header .nav-item .nav-link {
        color: #fff;
        /* Set nav link text color to white */
    }

.main-content {
    margin-top: 50px; /* Height of fixed header */
    margin-left: 100px; /* Initially, set margin-left to 0 */
    padding-top: 30px; /* Height of fixed header */
    transition: margin-left 0.3s ease-in-out; /* Add transition for smoother animation */
}


    /* Custom styles for search bar */
    .search-container {
        display: flex;
        align-items: center;
       width:100%;
        margin: 2px auto;
        float:left;
	}

/* Updated hide class to apply to the overlay */
.sidebar.hide, .overlay.hide {
    transform: translateX(-100%);
}

    .search-input {
        width: 100%;
        padding: 10px 30px 10px 10px;
        /* Adjust padding to accommodate the icon */
        border: 1px solid #ccc;
        border-radius: 20px;
        font-size: 16px;
    }

    .search-icon {
        position: relative;
        left: -25px;
        /* Adjust the position of the icon */
        color: #aaa;
    }

    .search-icon i {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
    }

    .btn-dark {
        background: #503F2E;
        color: #fff;
        border: 1px solid #503F2E;
    }

    .btn-dark:hover {
        background: #fff;
        color: #503F2E;
        border: 1px solid #503F2E;
    }

    .bg-dark2 {
        background: #8A1218;
        color: #fff;
    }

    .modal-content {
        animation: modal-animation 0.5s;
    }

    @keyframes modal-animation {
        from {
            opacity: 0;
            transform: scale(0.8);
        }

        to {
            opacity: 1;
            transform: scale(1);
        }
    }

	
		
		        #searchResults {
            position: absolute;
            background-color: #f9f9f9;
            border: 1px solid #ddd;
            max-height: 200px;
            overflow-y: auto;
            width: 85%;
            display: none;
        }
        #searchResults div {
            padding: 10px;
            cursor: pointer;
        }
        #searchResults div:hover {
            background-color: #f1f1f1;
        }
		label{font-size:13px; font-weight:600;}
	input{
	 height:25px;	
		}
</style>

<body>

<?php
if(isset($msg)){
	
	echo $msg;
	}
?>
<?php include("common/hd.php"); ?>
<!-- Sidebar -->
<?php include("common/sd.php"); ?>
<div class="main-content">
<div class="container-fluid">
<div class="row">
<div class="col-sm-7">
<h3 style="color:#212529;"> Lease Form</h3>
<a href="addproductinq.php"><button type="button" class="btn btn-dark "><i class="fa fa-arrow-left fa-1x"></i></button></a>
</div>
<div class="col-sm-3">
</div>
<div class="col-sm-2" style="background:#503F2E; padding:5px; border-radius:10px;color:#fff;">
<label>&nbsp;&nbsp;Customer Name </label><br />
<center><label style="font-size:21px; text-transform:capitalize;" class="text-center"><?php echo $customer; ?></label></center>

</div>
</div>

</div>

<br />
<?php 
$inquiry = mysqli_query($connection,"select * from inquiry where customer_name = '$customer'");
$inq = mysqli_fetch_array($inquiry);

?>
    <div class="container-fluid " >
        <form action="nlease.php?customer_name=<?php echo $customer; ?>" method="post" enctype="multipart/form-data" style="padding:40px;box-shadow: 0 0 20px rgba(80, 63, 46, 0.75);border-radius:20px;border:2px solid #503F2E;">
            <!-- Header Section -->
            <label style="background:#503F2E;color:#fff; padding:12px; font-size:16px; border-radius:12px;">Lease Process Detail</label><br />
            <div class="row " >
                <div class="col-md-2">
                    <label for="customerCode" class="form-label">Customer Code</label>
                    <input type="text" class="form-control" id="customerCode" name="customerCode" value="<?php echo $inq["id"]; ?>">
                </div>
                <div class="col-md-3">
                    <label for="processNo" class="form-label">Process No</label>
                    <input type="text" class="form-control" id="processNo" name="processNo" value="<?php echo $inq["process_no"]; ?>">
                </div>
                <div class="col-md-3">
                    <label for="processDate" class="form-label">Process Date</label>
                    <input type="date" class="form-control" id="processDate" name="processDate" value="<?php echo $inq["process_date"]; ?>">
                </div>
                <div class="col-md-4">
                    <label for="cnicNo" class="form-label">CNIC No</label>
                    <input type="text" class="form-control" id="cnicNo" name="cnicNo" value="<?php echo $inq["cnic"]; ?>">
                </div>
            </div>

            <div class="row mb-2" >
                
                <div class="col-md-4">
                    <label for="cellNo" class="form-label">Cell No</label>
                    <input type="text" class="form-control" id="cellNo" name="cellNo" value="<?php echo $inq["cell"]; ?>">
                </div>
                <div class="col-md-4">
                    <label for="affidavit" class="form-label">Affidavit</label>
                    <select class="form-control" id="affidavit" name="affidavit" >
                    <option value="Select">Select</option>
                        <option value="yes" >Yes</option>
                        <option value="no">No</option>
                    </select>
                </div>
            </div><br />

            <!-- Customer and Address Information -->
            <label style="background:#503F2E;color:#fff; padding:12px; font-size:16px; border-radius:12px;">Customer & Address Detail</label><br />
            <div class="row mb-2">
            <div class="col-md-3">
                    <label for="CcustomerName" class="form-label">Customer Name</label>
                    <input type="text" class="form-control"  value="<?php echo $inq["customer_name"]; ?>" name="CcustomerName" >
                </div>
             
                <div class="col-md-3">
                    <label for="soDoWo" class="form-label">S/O / D/O / W/O</label>
                    <input type="text" class="form-control" id="soDoWo" value="<?php echo $inq["father_husband_name"];?>" name="soDoWo" >
                </div>
                <div class="col-md-3">
                    <label for="occupation" class="form-label">Occupation</label>
                    <input type="text" class="form-control" id="occupation" value="<?php echo $inq["occupation"]; ?>" name="occupation" >
                </div>
                <div class="col-md-3">
                    <label for="businessName" class="form-label">Business Name</label>
                    <input type="text" class="form-control" id="businessName" value="" name="businessName">
                </div>
            </div>

            <div class="row mb-2">
                <div class="col-md-6">
                    <label for="resAddress" class="form-label">Residence Address</label>
                    <input class="form-control" id="resAddress" rows="2" name="resAddress"
                     value="<?php echo $inq["res_address"];?>" style="height:80px;" >
                </div>
                <div class="col-md-6">
                    <label for="offAddress" class="form-label">Office Address</label>
                    <input class="form-control" id="offAddress" rows="2" name="offAddress" value="<?php echo $inq["off_address"];?>"  style="height:80px;">
                </div>
            </div><br />

            <!-- Income and Living Details -->
            <label style="background:#503F2E;color:#fff; padding:12px; font-size:16px; border-radius:12px;">Income and Living Details</label><br />
            <div class="row mb-2">
            
                <div class="col-md-2">
                    <label for="monthlyIncome" class="form-label">Monthly Income</label>
                    <input type="number" class="form-control" id="monthlyIncome" value="" name="monthlyIncome">
                </div>
                <div class="col-md-2">
                    <label for="sinceLiving" class="form-label">Since Living</label>
                    <input type="text" class="form-control" id="sinceLiving" value="" name="sinceLiving">
                </div>
                <div class="col-md-2">
                    <label for="sinceWorking" class="form-label">Since Working</label>
                    <input type="text" class="form-control" id="sinceWorking" value="" name="sinceWorking">
                </div>
                <div class="col-md-2">
                    <label for="houseOwner" class="form-label">House Owner</label>
                    <select class="form-control" id="houseOwner" name="houseOwner">
                     <option>Select</option>
                        <option value="yes" >Yes</option>
                        <option value="no">No</option>
                    </select>
                </div>
                <div class="col-md-4">
                    <label for="married" class="form-label">Married</label>
                    <select class="form-control" id="married" name="married">
                    <option>Select</option>
                        <option value="yes" >Yes</option>
                        <option value="no">No</option>
                    </select>
                </div>
            </div>
<br />
 <label style="background:#503F2E;color:#fff; padding:12px; font-size:16px; border-radius:12px;">Inquiry and Management</label><br />
            <!-- Inquiry and Management Information -->
            <div class="row mb-2">
                <div class="col-md-4">
                    <label for="inquiryOfficer" class="form-label">Inquiry Officer</label>
                    <input type="text" class="form-control" id="inquiryOfficer" name="inquiryOfficer" value="<?php echo $inq["inquiry_officer"]; ?>">
                </div>
                <div class="col-md-4">
                    <label for="recovery" class="form-label">Recovery</label>
                    <input type="text" class="form-control" id="recovery" name="recovery">
                </div>
                <div class="col-md-4">
                    <label for="marketingBy" class="form-label">Marketing By</label>
                    <input type="text" class="form-control" id="marketingBy" value="<?php echo $inq["marketing_officer"]; ?>" name="marketingBy" >
                </div>
            </div>

            <div class="row mb-2">
                <div class="col-md-4">
                    <label for="manager" class="form-label">Manager</label>
                    <input type="text" class="form-control" id="manager" value="" name="manager">
                </div>
                <div class="col-md-4" style="padding:7px; background:#503F2E; color:#fff; border-radius:10px;">
                    <label for="zonalManager" class="form-label">Zonal Manager</label>
                    <input type="text" class="form-control" id="zonalManager">
                </div>
                <div class="col-md-4" style="padding:7px; background:#503F2E; color:#fff; border-radius:10px;">
                    <label for="regionalManager" class="form-label">Regional Manager</label>
                    <input type="text" class="form-control" id="regionalManager">
                </div>
            </div>
<br />
 <label style="background:#503F2E;color:#fff; padding:12px; font-size:16px; border-radius:12px;">Cheque and Company </label><br />
            <!-- Cheque and Company Information -->
            <div class="row mb-2">
                <div class="col-md-3">
                    <label for="chequeType" class="form-label">Cheque Type</label>
                    <input type="text" class="form-control" id="chequeType" value="" name="chequeType">
                </div>
                <div class="col-md-3">
                    <label for="noOfCheques" class="form-label">No of Cheques</label>
                    <input type="number" class="form-control" id="noOfCheques" value="" name="noOfCheques">
                </div>
                <div class="col-md-3">
                    <label for="chequeAmount" class="form-label">Cheque Amount</label>
                    <input type="number" class="form-control" id="chequeAmount" value="" name="chequeAmount">
                </div>
                <div class="col-md-3">
                    <label for="chequeReturned" class="form-label">Cheque Returned</label>
                    <select class="form-control" id="chequeReturned" name="chequeReturned">
                    <option>Select</option>
                        <option value="no" >No</option>
                        <option value="yes">Yes</option>
                    </select>
                </div>
            </div>

            <div class="row mb-2">
                <div class="col-md-6">
                    <label for="company" class="form-label">Company</label>
                    <input type="text" class="form-control" id="company" name="company">
                </div>
                <div class="col-md-3">
                    <label for="department" class="form-label">Department</label>
                    <input type="text" class="form-control" id="department" name="department">
                </div>
                <div class="col-md-3">
                    <label for="designation" class="form-label">Designation</label>
                    <input type="text" class="form-control" id="designation" name="designation">
                </div>
            </div>

            <div class="row mb-2">
                <div class="col-md-3">
                    <label for="employeeNo" class="form-label">Employee No</label>
                    <input type="text" class="form-control" id="employeeNo" name="employeeNo">
                </div>
                <div class="col-md-3" style="padding:7px; background:#503F2E; color:#fff; border-radius:10px;">
                    <label for="zonalManager" class="form-label">Zonal Manager</label>
                    <input type="text" class="form-control" id="zonalManager" name="zonalManager">
                </div>
                <div class="col-md-3" style="padding:7px; background:#503F2E; color:#fff; border-radius:10px;">
                    <label for="regionalManager" class="form-label">Regional Manager</label>
                    <input type="text" class="form-control" id="regionalManager" name="regionalManager">
                </div>
                <div class="col-md-3">
                    <label for="crcBy" class="form-label">CRC By</label>
                    <input type="text" class="form-control" id="crcBy" name="crcBy">
                </div>
            </div>
 <label style="background:#503F2E;color:#fff; padding:12px; font-size:16px; border-radius:12px;">Guarantor Information </label><br />
            <!-- Guarantor Information -->
            <div class="row mb-2">
                <div class="col-md-4">
                    <label for="guarName" class="form-label">Guarantor Name</label>
                    <input type="text" class="form-control" id="guarName" name="guarName">
                </div>
                <div class="col-md-4">
                    <label for="guarCnicNo" class="form-label">Guarantor CNIC No</label>
                    <input type="text" class="form-control" id="guarCnicNo" name="guarCnicNo">
                </div>
                <div class="col-md-4">
                    <label for="guarOccupation" class="form-label">Guarantor Occupation</label>
                    <input type="text" class="form-control" id="guarOccupation" name="guarOccupation">
                </div>
            </div>

            <div class="row mb-2">
                <div class="col-md-4">
                    <label for="guarValue" class="form-label">Guarantee Value</label>
                    <input type="text" class="form-control" id="guarValue" name="guarValue">
                </div>
                <div class="col-md-4">
                    <label for="guarRelation" class="form-label">Relation with Customer</label>
                    <input type="text" class="form-control" id="guarRelation" name="guarRelation">
                </div>
                <div class="col-md-4">
                    <label for="guarAddress" class="form-label">Guarantor Address</label>
                    <input type="text" class="form-control" id="guarAddress" name="guarAddress">
                </div>
            </div>

            <div class="row mb-2">
                <div class="col-md-4">
                    <label for="guarBusinessName" class="form-label">Guarantor Business Name</label>
                    <input type="text" class="form-control" id="guarBusinessName" name="guarBusinessName">
                </div>
                <div class="col-md-4">
                    <label for="guarResAddress" class="form-label">Guarantor Residence Address</label>
                    <textarea class="form-control" id="guarResAddress" rows="2" name="guarResAddress"></textarea>
                </div>
                <div class="col-md-4">
                    <label for="guarOffAddress" class="form-label">Guarantor Office Address</label>
                    <textarea class="form-control" id="guarOffAddress" rows="2" name="guarOffAddress"></textarea>
                </div>
            </div>

            <div class="row mb-2">
                <div class="col-md-4">
                    <label for="guarTelRes" class="form-label">Guarantor Tel (Residence)</label>
                    <input type="text" class="form-control" id="guarTelRes" name="guarTelRes">
                </div>
                <div class="col-md-4">
                    <label for="guarTelOff" class="form-label">Guarantor Tel (Office)</label>
                    <input type="text" class="form-control" id="guarTelOff" name="guarTelOff">
                </div>
                <div class="col-md-4">
                    <label for="guarNicIssue" class="form-label">Guarantor CNIC Issue Date</label>
                    <input type="date" class="form-control" id="guarNicIssue" name="guarNicIssue">
                </div>
            </div>

            <div class="row mb-2">
                <div class="col-md-4">
                    <label for="guarAffidavit" class="form-label">Guarantor Affidavit</label>
                    <input type="text" class="form-control" id="guarAffidavit" name="guarAffidavit">
                </div>
            </div>

            <!-- Submit Button -->
            <div class="row">
            <div class="col-sm-3"></div>
                <div class="col-sm-6 text-center ">
                    <button type="submit" class="btn btn-dark " style="width:100%;">Submit</button>
                </div>
                <div class="col-sm-3"></div>
            </div>
        </form>
        <br /><br />
    </div>
</div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
 <script>
 
document.addEventListener("DOMContentLoaded", function () {
    var sidebar = document.getElementById("sidebar");
    var overlay = document.createElement("div");
    overlay.classList.add("overlay");
    document.body.appendChild(overlay);

    function toggleSidebar() {
        sidebar.classList.toggle("hide");
        overlay.classList.toggle("hide");

        var mainContent = document.querySelector(".main-content");
        if (sidebar.classList.contains("hide")) {
            mainContent.style.marginLeft = "0";
        } else {
            mainContent.style.marginLeft = "100px"; // Width of the sidebar
        }
    }

    overlay.addEventListener("click", function () {
        toggleSidebar();
    });

    // Add toggle functionality to navbar toggler
    var navbarToggler = document.querySelector(".navbar-toggler");
    navbarToggler.addEventListener("click", function () {
        toggleSidebar();
    });

    // Automatically hide sidebar on all screen sizes
    // sidebar.classList.add("hide");
    // overlay.classList.add("hide");
    
    // Add class to body to prevent scrolling when sidebar is open
    // document.body.classList.add("noscroll");

    // Check if screen size is larger than a certain threshold (e.g., 768px for desktop screens)
    function checkScreenSize() {
        if (window.innerWidth > 768) {
            sidebar.classList.remove("hide");
            overlay.classList.remove("hide");
        } else {
            sidebar.classList.add("hide");
            overlay.classList.add("hide");
        }
    }

    // Check screen size on initial load and whenever the window is resized
    checkScreenSize();
    window.addEventListener("resize", checkScreenSize);
});
    // Function to toggle submenu
    function toggleSubMenu(element) {
        $(element).next('.sub-menu').slideToggle();
    }
</script>

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
</body>
</html>
