<?php include("../Header/Session.php"); ?>
<?php include("../Header/Connection.php"); ?>

<!DOCTYPE html>
<html lang="en">
<?php include ("../Header/head.php"); ?>
<body class="skin-default fixed-layout">

<!-- Main wrapper - style you can find in pages.scss -->
<div id="main-wrapper">    
<?php include ("../Header/header.php"); ?>
<?php include ("../Header/left_menu.php"); ?>
<?php include ("../Header/right_sidebar.php"); ?>

<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>
        
<!-- Page wrapper  -->
<div class="page-wrapper">
<!-- Container fluid  -->
<div class="container-fluid">
<!-- Bread crumb and right sidebar toggle -->
<!--?php include ("../Header/breadcumb.php"); ?-->
<br><br>
<!-- End Bread crumb and right sidebar toggle -->
    
<!-- Start Page Content -->
<!-- ============================================================== -->
<div class="row">
<div class="col-12">

<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
    <?php
    $id = $_GET['id']; 

    $q = "SELECT *
    FROM announcement
    Where id = '$id'                          
    order by id";
    $result = $mysqli->query($q);
    if ($result ->num_rows > 0)
    {
        while($record = $result -> fetch_assoc())
        {    
		    $id = $record['id'];
            $announcement_ref_code = $record['announcement_ref_code']; 
            $announcement_title = $record['announcement_title'];  
            $announcement_image = $record['announcement_image'];  
            $announcement_content = $record['announcement_content'];  
		    $status = $record['status'];
    ?>
    <form  id="postForm" method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data">
        <div class="form-body">
            <h3 class="card-title">Update Announcement</h3>
            <hr>

            <div class="row p-t-20">
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label">Title</label>
                        <input type="text" class="form-control" name="announcement_title" value="<?php echo $announcement_title; ?>" required>
                    </div>
                </div>

                 <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label">Image</label> 
                        <?php if ($announcement_image != "")
                        {
                        ?>
                        | <a href="../Controller/uploads/<?php echo $announcement_image; ?>" download><font color="blue">Download</font></a><br>    
                        <img src="../Controller/uploads/<?php echo $announcement_image; ?>" width="100" height="100"><br><br>
                        <?php
						}
                        ?>
                        <input type="file" class="form-control" name="announcement_image">
                    </div>
                </div> 
               
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">Content</label>
                        <textarea id="summernote1" name="announcement_content"  rows="10"><?php echo $announcement_content; ?></textarea>
                    </div>
                </div>

                <div class="col-md-12">
                    <div class="form-group">
                        <input type="hidden" name="announcement_id" value="<?php echo $id; ?>" required>
                        <input type="hidden" name="announcement_ref_code" value="<?php echo $announcement_ref_code; ?>" required>
                        <button name="Update_Announcement" class="btn btn-success"><i class="fa fa-check"></i> Submit</button>
                        <a href="list_of_announcement_1.php" class="btn btn-success" >Back</a>
                    </div>
                </div>

            </div> 
        </div>                           
    </form>
    <?php 
    }
    }
    ?>
</div>
</div>
</div>
</div>

</div>                      
</div>
</div>
<!-- ============================================================== -->
<!-- End PAge Content -->

</div>
<!-- End Container fluid  -->
</div>
<!-- End Page wrapper  -->

<!-- Footer Start-->
<?php include ("../Footer/footer.php"); ?>
<!-- Footer End-->

</div>
<!-- End Wrapper -->
<!-- All Jquery -->
    

<!-- All Jquery Start-->
<?php include ("../Header/all_jquery.php"); ?>
<!-- All Jquery End-->

<script type="text/javascript">
$(document).ready(function() {
	$('#summernote1').summernote({
      toolbar: [
        // [groupName, [list of button]]
        ['style', ['bold', 'italic', 'underline', 'clear']],
        ['font', ['strikethrough', 'superscript', 'subscript']],
        ['fontsize', ['fontsize']],
        ['color', ['color']],
        ['para', ['ul', 'ol', 'paragraph']],
        ['height', ['300px']],
         ['style', ['style']],
          ['font', ['bold', 'underline', 'clear']],
          ['table', ['table']],
          ['insert', ['link', 'video']],
          ['view', ['fullscreen', 'codeview', 'help']],
          ]
    });
});
function postForm() 
{
	$('textarea[name="announcement_content"]').html($('#summernote1').code());
}
</script>

</body>

</html>