<?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"); ?>
    <!-- Page wrapper  -->
    <div class="page-wrapper">
    <!-- Container fluid  -->
    <div class="container-fluid">

    <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>

    <!-- 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-lg-12">
    <div class="card">
    <div class="card-body">
    <?php
    $id = $_GET['id'];
                        
    $q = "SELECT *
    FROM support_ticket  
    Where id = '$id'";
    $result = $mysqli-> query($q);
    if ($result -> num_rows > 0)
    {
	    while($record = $result -> fetch_assoc())
	    {          
            $ticket_id = $record['id'];
            $subject = $record['subject'];
            $priority = $record['priority'];
            $category = $record['category'];
            $comment = $record['comment'];
    ?> 
        <div class="form-body">
        <h3 class="card-title">View Ticket</h3>
        <hr>
        <div class="row p-t-20">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="control-label">Subject</label>
                    <input type="text" class="form-control"  name="subject" value="<?php echo $subject; ?>" readonly>
                </div>
            </div>  
        </div>

        <div class="row p-t-20">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="control-label">Priority</label>
                    <select name="priority" class="form-control" readonly >
                        <option value="<?php echo $priority; ?>"><?php echo $priority; ?></option>
                    </select>
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label class="control-label">Category</label>
                    <select name="category" class="form-control" readonly >
                        <option value="<?php echo $category; ?>"><?php echo $category; ?></option>
                    </select>
                </div>
            </div> 
        </div>

        <div class="row p-t-20">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="control-label">Message</label>
                    <textarea id="summernote" name="comment" rows="10" readonly><?php echo $comment; ?></textarea>
                </div>
            </div>  
        </div>
    </div>
    <?php
    }
    }   
    ?>	

    <?php
    $q_support = "SELECT * FROM support_ticket_conversation 
    Where support_ticket_id= '$ticket_id'
    And status='1'
    order by id Asc";
    $result_support = $mysqli-> query($q_support);
    if ($result_support -> num_rows > 0)
    {
	    while($row_support = $result_support -> fetch_assoc())
	    {   
            $support_ticket_id = $row_support['id'];
            $comment = $row_support['comment'];
            $user_level = $row_support['user_level'];
    ?>
    <div class="form-body">
            <div class="row p-t-20">
                <div class="col-md-1">
                    <div class="form-group">
                        <?php if ( $user_level == "1" )
                        {
                        ?>
                              <img src="../Assets/images/sponsor.png" width="75px" height="75px">
                        <?php
						}
                        else
                        {
                        ?>
                              <img src="../Assets/images/man.png" width="85px" height="85px">
                        <?php
						}
                        ?> 
                    </div>
                </div>
                <div class="col-md-9">
                    <div class="form-group">
                        <textarea class="form-control" rows="3" readonly><?php echo $comment; ?></textarea>
                    </div>
                </div>
            </div>
        </div>
    <?php
        }
    }
    ?>

    <form method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data">
        <div class="form-body">
            <div class="row p-t-20">
                <div class="col-md-1">
                    <div class="form-group">
                        <?php if ( $level == "1" )
                        {
                        ?>
                              <img src="../Assets/images/sponsor.png" width="75px" height="75px">
                        <?php
						}
                        else
                        {
                        ?>
                              <img src="../Assets/images/man.png" width="85px" height="85px">
                        <?php
						}
                        ?> 
                    </div>
                </div>
                <div class="col-md-9">
                    <div class="form-group">
                        <textarea name="comment" class="form-control" rows="3"></textarea>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="form-group">
                        <input type="hidden" name="user_level" value="<?php echo $level; ?>">
                        <input type="hidden" name="ref_code" value="<?php echo $ref_code; ?>">
                        <input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
                        <button name="Reply_Ticket" class="btn btn-success"><i class="fa fa-check"></i> Reply</button>
                    </div>
                </div>
            </div>
        </div>
    </form>

    </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 -->
 
    <script type="text/javascript">
    $(document).ready(function() {
    $('#summernote').summernote({
    height: "300px",
    styleWithSpan: false
    });
    });
    function postForm() 
    {
    $('textarea[name="comment"]').html($('#summernote').code());
    }
    </script>

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

    

    </body>

    </html>