<?php
session_start();
if(isset($_SESSION['loggedin']))
{
	include('connection.php');
	$logid=$_SESSION['loggedin'];
	$res=mysqli_query($con,"select * from admin where id='$logid'");
	$row=mysqli_fetch_assoc($res);
	
	if(isset($_POST['save']))
{
$photo=$_POST["photo"];	
$des=$_POST["des"];
date_default_timezone_set("Asia/Calcutta");
$date=date('Y-m-d H:i:s');
$sql="insert into about(des,photo,created_at)values('$des','$photo','$date')"; 
$result=mysqli_query($con,$sql);
if(mysqli_affected_rows($con)==1)
{
	header("location:about.php?status=true");
}
else{
	echo "<script>alert('sorry! unable to insert..');</script>";
}

}
	
?>


  <!-- Navbar -->
<?php include('header.php');?>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
<?php include('sidebar.php');?>

  <!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
         
          
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
	 <section class="content">
   <!--   <div class="row">
        <div class="col-md-6">
          <div class="card card-primary">
             <div class="card-header">
                <h3 class="card-title"><b>About Us</b></h3>
              </div>
           
			<form method="post" method="post" enctype="multipart/form-data">
            <div class="card-body">
                    <label for="exampleInputPassword1">Image</label>
                    <input type="file" name="photo" class="form-control" id="exampleInputPassword1" placeholder="Enter No of Seats" required>
                  </div>
		   <div class="card-body">
			 <label for="exampleInputPassword1">Description</label>
              <textarea id="summernote" name="des" placeholder="Text Here">
              Text Here
              </textarea>
            </div>
			
				    <div class="card-footer" style="text-align:right">
                  <button type="submit" name="save" class="btn btn-primary">Submit</button>
                </div>
           </form>
          </div>
        </div>
      
      </div>
      <!-- ./row -->
     
      <!-- ./row -->
    </section>
	
    <section class="content">
      <div class="container-fluid">
	 
	  <div class="row">
	    <div class="col-12">       
            <div class="card">
              <div class="card-header" style="background-color:rgb(27 125 151);color:white;">
                <h3 class="card-title"><b>Earl Meyers (Broker/Owner) List</b></h3>
              </div>
              <!-- /.card-header -->
              <div class="card-body" >
                <table id="example2" class="table table-bordered table-striped">
                  <thead>
                  <tr>
                    <th>Sr. No.</th>
					<th>DRE#</th> 
					<th>About Owner</th> 
					
                    <th>Action</th>
                  </tr>
                  </thead>
                  <tbody>
                       <?php

	$sql="select * from about";
	$result11=mysqli_query($con,$sql);

if(mysqli_num_rows($result11))
						{
							  
									$i=1;
									while($rows11=mysqli_fetch_assoc($result11))
									{
										?> 
                  <tr>
                    <td><?php echo $i;?></td>
				    <td><?php echo $rows11['photo'];?></td>
					<td><?php echo $rows11['des'];?></td>
					<td>
					<button type="button" class="btn btn-info"><a href="about_update.php?bid=<?php echo $rows11['id']?>">
                          <i class="fas fa-edit" style="color:white"></i>
                        </button>
                      <!--<button type="button" class="btn btn-danger"><a onclick="deleteRecord('<?php echo $rows11['id'];?>')" href="javascript:void(0)">-->
                      <!--    <i class="fas fa-trash" style="color:white"></i>-->
                      <!--  </button>-->
					</td>
                  </tr>
                  	<?php
									$i++;
									
									}
								?>
								
							<?php
							
						}
						else
						{
						?>
						<div style=" padding:15px; margin-top:10px;">
				        
				        <h4 style="text-align:center;color:red;"><b>Sorry ! No result found..!</b></h4>
						 </div>
						 <?php
						}
			?>
                  </tbody>             
                </table>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
	  </div>
	  </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
   <script>
					function deleteRecord(id)
					{
						var x=confirm("do you want to Delete?")
						if(x==true)
						{
							window.location="about_delete.php?did="+id;
						}
						
					}
	</script>
	
	<script src="plugins/summernote/summernote-bs4.min.js"></script>
	
	<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>

	<script>
  $(function () {
    // Summernote
    $('#summernote').summernote()

    // CodeMirror
    CodeMirror.fromTextArea(document.getElementById("codeMirrorDemo"), {
      mode: "htmlmixed",
      theme: "monokai"
    });
  })
</script>
 <?php include('footer.php');?>
<?php
}
else
{
	header("location:login.php");
}
?>