<? include("../settings.php"); ?>
<? include("session.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SP Admin Panel</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Include all CSS/JS -->
        <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery-2.1.1.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <!-- End of all CSS/JS -->
    <script src="ckeditor/ckeditor.js"></script>
    <script>
        function frmsubmit(){
            var data = CKEDITOR.instances.email_content.getData();
            $("#email_content").val(data);
            $.ajax({
                type:"POST",
                url:"email_edit_ajax.php",
                data:$("#email").serialize(),//only input
                success: function(response){
                    if (response != "1"){
                        alert(response);
                    }else{
                        alert("Changes saved.");
                        window.history.back();
                    }
                }
            });
        }
        
    </script>

   
   </head>
<body>


<? include("nav_menu.php"); ?>
<?
    $bind = array(
        ":search1" => $_REQUEST['email_id']
    );
    $results = $db->select("tbl_email", "email_id = :search1", $bind);
    $result = $results[0];
?>     
      <div class="well">
<div class="content" bgcolor="#FFFFD0">
<div class="col-12 feature">
<div class="panelCheck">
    <div class="panel-heading">
        <h3 class "panel-title"><strong>Email Details</strong></h3>
    </div>
<div class="panel-body">
<form name="email" id="email" method='POST' action="" enctype="multipart/form-data" class="form-horizontal" role="form">
        <div class='form-group'>
            <label for='email_subject' class='col-lg-2 control-label'>Email Subject</label>
            <div class='col-lg-10 text-left'>
                <input type="text" class="form-control" name="email_subject" required value="<?=$result['email_subject'];?>">
            </div>
        </div>
        <br/><br/>
        <div class='form-group'>
            <label for='registrant_organisation' class='col-lg-2 control-label'>Email Content</label>
            <div class='col-lg-10 text-left'>
                <textarea class="form-control" name="email_content" id="email_content" required rows="20"><?=$result['email_content'];?></textarea>
             </div>
        </div>
    <center>
    <input type="hidden" name="email_id" value="<?php echo $result['email_id']; ?>">
    <input type="button" name="confirm" value="Update" class="btn btn-default" onclick="frmsubmit();">
    <input type="button" value="Close" class="btn btn-default" onclick="window.history.back();">
    </center>
</form>
</div>       

</div>
</div>
</div>
</div>
    
<script type="text/javascript">
CKEDITOR.replace( 'email_content' );
</script>
    
    
</body>
</html>
