
<?php include('../config/setup.php');

$msg = "";

$supplier = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $action = $_POST['action'];
    if ($action == "delete") {
        $id = $_POST['id'];
        $query = "DELETE FROM `contactus` WHERE sno=$id ";
        $query_result = mysqli_query($conn, $query);
        if ($query_result) {
            $msg = "Services Deleted Successfully";
            $alert = "success";
        } else {
            $msg = "Something went Wrong. Tryagain Later!!!";
            $alert = "danger";
        }
    }
}

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title><?php

            $leename = mysqli_query($config, "select Name,Name_status from lee_master");
            while ($lee = mysqli_fetch_array($leename)) {
                $namestatus = $lee[1];
                if ($namestatus == 1) {
                    echo  $lee[0];
                } else {
                    echo "Need Name";
                }
            }

            ?> </title>
    <meta content='width=device-width, initial-scale=1.0, shrink-to-fit=no' name='viewport' />
    <link rel="icon" href="<?php

                            $inro_logo = mysqli_query($config, "select Logo_Path,logo_status from lee_master");
                            while ($logo = mysqli_fetch_array($inro_logo)) {
                                $logstatus = $logo[1];
                                if ($logstatus == 1) {

                                    $ms = substr($logo[0], 3);
                                    echo "../../img/logo/favicon.ico";
                                } else {
                                    echo "../../img/logo/no_logo.png";
                                }
                            }

                            ?>" type="image/x-icon" />

    <!-- Fonts and icons -->
    <script src="../assets/js/plugin/webfont/webfont.min.js"></script>
    <script>
        WebFont.load({
            google: {
                "families": ["Lato:300,400,700,900"]
            },
            custom: {
                "families": ["Flaticon", "Font Awesome 5 Solid", "Font Awesome 5 Regular", "Font Awesome 5 Brands", "simple-line-icons"],
                urls: ['../assets/css/fonts.min.css']
            },
            active: function() {
                sessionStorage.fonts = true;
            }
        });
    </script>

    <!-- CSS Files -->
    <link rel="stylesheet" href="../assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="../assets/css/atlantis.min.css">
    <!-- CSS Just for demo purpose, don't include it in your project -->
    <link rel="stylesheet" href="../assets/css/demo.css">
    <script src="../assets/angular/angular.min.js"></script>

</head>
<body>
	<div class="wrapper">
		<div class="main-header">
        <?php

if ($msg !== "") { ?>

    <div class="alert alert-<?php echo $alert; ?>" role="alert">

        <?php echo $msg; ?>

    </div>

<?php } ?>

			<!-- Logo Header -->
	 		<?php include('logo.php');?>
			<!-- End Logo Header -->
			<!-- Navbar Header -->
			<?php include('topbar.php');?>
			 <!-- End Navbar -->
		</div>
		<!-- Sidebar -->
		<?php include('sidebar.php');?>
		
		<div class="main-panel">
			<div class="content">
				<div class="page-inner">
					<div class="page-header">
						<h4 class="page-title">New Enquiry</h4> 
					</div>
					<div class="row">
						<div class="col-md-12">
							<div class="card">
								<div class="card-body">
									<div class="table-responsive">
										<table id="basic-datatables" class="display table table-striped table-hover" >
											<thead>
												<tr>
													<th>S.No</th>
													<th>Name</th>
													<th>Email Id</th>
													<th>Phone Number</th> 
													<th>Subject</th>
													<th>Date</th>
													<th>Action</th>
												</tr>
											</thead>
											<tbody>
                                                
                                            <?php

                                            $newsql = "SELECT * FROM enquiry WHERE status = 0";
                                            $newquery = mysqli_query($config, $newsql);
                                            $sno = 1;
                                            while ($rows = mysqli_fetch_array($newquery)) {
                                                $snos = $rows['enquiryId'];
                                                $name = $rows['name'];
                                                $subject = $rows['subject'];
                                                $mobile = $rows['phone'];
                                                $email = $rows['email'];
                                                $message = $rows['message'];
                                                $createdat = $rows['createAt'];
                                                $createdat = date("d-M-Y", strtotime($createdat));
                                       
                                            ?>
                                            <tr>
                                                <td scope="row"><?php echo $sno; ?></td>
                                                <td><?php echo $name; ?></td>
                                                <td><?php echo $subject; ?></td>
                                                <td><?php echo $mobile; ?></td>
                                                <td><?php echo $email; ?></td>
                                                <td><?php echo $createdat; ?></td>
                                                <td>
                                    <a class="btn btn-info btn-xs" href="javascript:void(0);" onclick="openmodal('<?php echo $snos; ?>');">View</a>
                                    <div class="modal fade" id="myModal<?= $snos ?>" role="dialog">
                                        <div class="modal-dialog modal-lg">

                                            <!-- Modal content-->

                                            <div class="modal-content">

                                                <div class="modal-header">

                                                    <h4 class="modal-title">View Message</h4>

                                                    <button type="button" class="close" onclick="window.location.reload();" data-dismiss="modal">&times;</button>

                                                </div>

                                                <div class="modal-body">
                                                    <?= $message ?>
                                                </div>

                                                <div class="modal-footer">

                                                    <button type="button" class="btn btn-default" onclick="window.location.reload();" data-dismiss="modal">Close</button>

                                                </div>

                                            </div>

                                        </div>
                                    </div>

                                    <!-- <form action="newcontactusenquiry.php" method="post" style="display: inline-block;" onsubmit="return confirm('Are you sure you want to delete this?');">
										<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $snos; ?>">
										<input type="hidden" class="form-control" id="action" name="action" value="delete">
										<button type="submit" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>
									</form> -->
                                </td>
                            </tr>
                        <?php
                            $sno = $sno + 1;
                        } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </section>
</div>
<script>
    function openmodal(snos) {

        $('.modal-body').load('modalview.php?sno=' + snos + '&action=contactuschange', function() {

            $('#myModal<?= $snos ?>').modal({
                show: true
            });

        });

    }
</script>



<div class="modal fade" id="myModal" role="dialog">

    <div class="modal-dialog modal-lg">

        <!-- Modal content-->

        <div class="modal-content">

            <div class="modal-header">

                <h4 class="modal-title">Status Change</h4>

                <button type="button" class="close" data-dismiss="modal">&times;</button>

            </div>

            <div class="modal-body">



            </div>

            <div class="modal-footer">

                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

            </div>

        </div>

    </div>

</div>




<script type="text/javascript">
    $(function() {
        $('#example-table').DataTable({
            pageLength: 10
        });
    });
    $(function() {
        //Initialize Select2 Elements
        $('.select2bs4').select2({
            theme: 'bootstrap4'
        })
    });


    // function statusupdate() {
    // 	var orderidmodal = $('#orderidmodal').val();
    // 	var statusmodal = $('#statusmodal').val();
    // 	var action = "orderstatus update";
    // 	if (statusmodal !== "") {
    // 		var r = confirm("Are you sure you want to change the status???");
    // 		if (r == true) {

    // 			$.ajax({
    // 				type: "POST",
    // 				url: "functions.php",
    // 				data: {
    // 					orderid: orderidmodal,
    // 					status: statusmodal,
    // 					action: action
    // 				},
    // 				dataType: "html",
    // 				success: function(html) {
    // 					window.location.reload();
    // 				}
    // 			});
    // 		}
    // 	} else {
    // 		alert("Please Select the Status to update Order");
    // 	}
    // }
</script>
        <!-- Top Statistics -->
    </body>
</html>
