<?php include('../config/setup.php'); ?>
<?php
if (isset($_POST['changeStatus'])) {

	$id = $_POST['sid'];
	$sql = "UPDATE enquiry SET status=1 WHERE enquiryId = $id ";
	$res = $config->query($sql);
}
?>
<!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">
			<!-- 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>Message</th>
													<th>Date</th>
													<th>Resume</th>
												</tr>
											</thead>
											<tbody>
												<?php
												$pro = 1;
												$sql = "select * from new_enquiry_master WHERE e_status='0' ";
												$res = $config->query($sql);
												while ($enq = $res->fetch_assoc()) {
													 $eid = $enq['e_id'];
												?>
													<tr>
														<td><?php echo $pro; ?></td>
														<td><?= $enq['e_name'] ?></td>
														<td><?= $enq['e_email'] ?></td>
														<td><?= $enq['e_mobile'] ?></td>
														<td><?= $enq['e_subject'] ?></td>
														<td>
															<!-- <button type="button" name="changeStatus" class="btn btn-primary text-white" data-toggle="modal" data-target="#view<?php echo $pro; ?>">
																<i class="fas fa-eye"></i>
															</button> -->
															<a class="btn btn-primary" href="javascript:void(0);" onclick="openmodal('<?php echo $eid; ?>');"><i class="fas fa-eye"></i>View</a>

														</td>
                                                        <td><?= $enq['e_at'] ?></td>
                                                        <td><a href="../../uploads/pdf/<?= $enq['e_pdf'] ?>" class="btn btn-danger"><i class="fas fa-eye"></i></a></td>
													</tr>

                                    <div class="modal fade" id="myModal<?= $eid ?>" 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">
                                                    <?= $enq['e_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>

												<?php $pro++;
												} ?>

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

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

		<!-- End Custom template -->
	</div>
	<!--   Core JS Files   -->
	<script>
    function openmodal(eid) {

        $('.modal-body').load('ajaxmodalview.php?eid=' + eid + '&action=enquirychange', function() {

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

        });

    }
</script>
	<script type="text/javascript" src="richtext.js"></script>
	<script type="text/javascript">
		bkLib.onDomLoaded(function() {
			nicEditors.allTextAreas()
		});
	</script>

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script src="../assets/js/core/jquery.3.2.1.min.js"></script>
	<script src="../assets/js/core/popper.min.js"></script>
	<script src="../assets/js/core/bootstrap.min.js"></script>
	<!-- jQuery UI -->
	<script src="../assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
	<script src="../assets/js/plugin/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js"></script>

	<!-- jQuery Scrollbar -->
	<script src="../assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
	<!-- Datatables -->
	<script src="../assets/js/plugin/datatables/datatables.min.js"></script>
	<!-- Atlantis JS -->
	<script src="../assets/js/atlantis.min.js"></script>
	<!-- Atlantis DEMO methods, don't include it in your project! -->
	<script src="../assets/js/setting-demo2.js"></script>
	<script>
		$(document).ready(function() {
			$('#basic-datatables').DataTable({});




		});
	</script>
	<script>
		$(document).ready(function() {
			$('#image_file').on('change', function() {
				$('#upload_form').ajaxForm({
					target: '#uploaded_images_preview',
					beforeSubmit: function(e) {
						$('.file_uploading').show();
					},
					success: function(e) {
						$('.file_uploading').hide();
					},
					error: function(e) {}
				}).submit();
			});
		});
	</script>
</body>

</html>