<?php
    session_start();
    include "../../db.php";
    date_default_timezone_set('Asia/Kolkata');
      $currentTime = date('jS  F Y');

    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) )
        header("Location: logout.php");
?>
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Write a Blog</title>

  
    <link href="css/sb-admin-2.min.css" rel="stylesheet">
    <link href="css/all.min.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" href="vendor/croppie/croppie.css" />


    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.easing.min.js"></script>
    <script src="js/sb-admin-2.min.js"></script>
    <script src="vendor/croppie/croppie.js"></script>
    <script src="js/custom.js"></script>

    <script src="vendor/ckeditor.js"></script>

    <style>
        .custom-file-label::after {
            height: 8.25rem;
            padding-top: 50px;
        }
        .custom-file-label-edit::after{
            height: 2.25rem;
            padding-top: 5px;
        }
        #uploadimageModal .modal-dialog{
            max-width: 100% !important;
        }
    </style>
</head>
<body>
    <?php include "includes/topbar.php"; ?>
    <div class="">
        <h3 class="text-center mb-4" style="margin-top: 80px"><font color="black">   Mission  & Vission</h3>
        <input type="hidden" name="bref" id="bref" value="<?php echo $bref; ?>">
        <div class="card">
            <div class="card-body">
               
                            <?php
                                $edit_run = mysqli_query($con, "SELECT * FROM users WHERE uid = '$_SESSION[uid]'");
                                $edit_row = mysqli_fetch_assoc($edit_run);
                            ?>
                        <form method="post" enctype="multipart/form-data">
                           
					
								<font color="black">Description</font>
                            <textarea name="content" id="content" class="form-control ckeditor" ><?php echo $edit_row["uvission"]; ?></textarea>

                            							
                            <button type="submit" class="btn btn-success my-4"  name="edit_cat"> <i class="fas fa-cloud-upload-alt"></i> Update </button>
                            <a href="facility.php" class="btn btn-warning my-4"> Cancel </a>																				
                        </form>
                      
                        
            </div>
        </div>
    </div>
</body>
</html>



<script>
     CKEDITOR.replace( 'content', {
        height: 300,
        filebrowserUploadUrl: "upload.php"
    });



   
</script>


<script>
     CKEDITOR.replace( 'content1', {
        height: 300,
        filebrowserUploadUrl: "upload.php"
    });



   
</script>
      
<?php
   if(isset($_POST['edit_cat'])){
        $uvission = $_POST["content"];
       
       
		
       
        $up_sql = "UPDATE users SET uvission = '$uvission'   WHERE uid = '$_SESSION[uid]'";

   

        if(mysqli_query($con, $up_sql)){
            ?>
            <script>window.location = 'vission.php';</script>
            <?php
        }
        else{
            ?>
            <script>
                alert('OOPS !!!!');
                setTimeout(() => {
                    window.location = 'vission.php';
                }, 500);
            </script>
            <?php
        }
    }
?>