 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark"><?php echo $title ?></h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item active"><a href="#"><?php echo ucwords(str_replace("_", " ", $this->uri->segment(2))); ?></a></li>
             

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
  <?php
    $errors = $this->session->userdata('errors');
    if (isset($errors)) {
        ?>
        <script>
            swal ( "Oops" ,  "<?php echo $errors ?>" ,  "error" )
        </script>
        <?php echo $errors ?>
        <?php
        $this->session->unset_userdata('errors');
    }
    $error = $this->session->userdata('error');
    if (isset($error)) {
        ?>
         <script>
            swal ( "Oops" ,  "<?php echo $error ?>" ,  "error" )
        </script>
        <?php
        $this->session->unset_userdata('error');
    }
    $success = $this->session->userdata('success');
    if (isset($success)) {
        ?>
         <script>
            swal({
          title: "Done!",
          text: "<?php echo $success ?>",
          icon: "success",
        });
        </script>
        <?php
        $this->session->unset_userdata('success');
    }
    ?>
    <!-- Main content -->
    
    <section class="content">

      <!-- Default box -->
      <div class="card">
        <div class="card-header">
          <h5 class="card-title">Ticket ID - <?php echo $support_ticket->ticket_id ?>&nbsp; 
            <?php if($support_ticket->status == 0): ?>
              <span class="badge badge-warning">Open</span>
            <?php elseif ($support_ticket->status == 1):?>
              <span class="badge badge-primary">In-Process</span>
            <?php elseif ($support_ticket->status == 2):?>
              <span class="badge badge-success">Close</span>
            <?php elseif ($support_ticket->status == 3):?>
              <span class="badge badge-danger">Reject</span>
            <?php endif; ?></h5>
            <?php if(is_user() || is_fran()): ?>
              <a href="<?php echo base_url() ?>admin/support/raise_ticket" class="btn btn-info" style="float: right;"><i class="fa fa-eye" aria-hidden="true"></i>&nbsp;&nbsp;View All Ticket</a>
            <?php else: ?>
              <a href="<?php echo base_url() ?>admin/support_ticket" class="btn btn-info" style="float: right;"><i class="fa fa-eye" aria-hidden="true"></i>&nbsp;&nbsp;View All Ticket</a>
            <?php endif; ?>
        </div>
        <?php if($support_ticket->status == 0 || $support_ticket->status == 1): ?>
          <div class="card-body">
            <div class="row">
              
                <div class="col-md-12">
                  <?php echo form_open_multipart('admin/support_ticket/reply_ticket'); ?>
                   <div class="form-group">
                      <label for="message-text" class="col-form-label">Details Description: <span style="color: red">*</span></label>
                      <textarea class="form-control" rows="7" required="" placeholder="Enter Details Description" name="description"></textarea>
                    </div>

                    <div class="form-group">
                      <label for="recipient-name" class="col-form-label">Upload Image:</label>
                      <input type="file" class="form-control" id="recipient-name" placeholder="Enter Ticket Subject" name="image">
                      <input type="hidden" name="user_id" value="<?php echo user()->id ?>">
                      <?php if(is_user() || is_fran()): ?>
                        <input type="hidden" name="who_from" value="1">
                      <?php else: ?>
                        <input type="hidden" name="who_from" value="2">
                      <?php endif; ?>
                      <input type="hidden" name="ticket_id" value="<?php echo $support_ticket->rand_id ?>">
                    </div>
                </div>
                  
                <div class="col-md-12">
                  <div class="form-group">
                     <button name="submit" style="float: right" type="submit" class="btn btn-success">Reply</button>
                  </div>
                </div>
                 <?php echo form_close() ?>
                <!-- /.col -->
              </div>
          </div>
        <?php endif;?>
      </div>

      <div class="card">
        <div class="card-header">
          <h3 class="card-title">Conversion Details</h3>
        </div>
        <div class="card-body justify-content-center">
          <div class="row justify-content-center">
            <div class="col-md-8 ">
              <div class="direct-chat-messages">
                <?php foreach ($all_support_ticket_comment as $key => $value_admin):
                  $user = $this->user_model->get_user_by_id($value_admin->user_id);?>
                  <?php if($value_admin->who_from == 2): ?>
                    <div class="row">
                      <div class="col-md-12">
                        <div class="direct-chat-msg">
                          <div class="direct-chat-infos clearfix">
                            <span class="direct-chat-name float-left"><?php echo $user->name ?> (<?php if(!empty($user->designation)){echo $user->designation;}else{echo 'Administrator';} ?>)</span>
                            <span class="direct-chat-timestamp float-right"><?php echo date('d-M-y h:i A', strtotime($value_admin->datetime)); ?></span>
                          </div>
                            <!-- /.direct-chat-infos -->
                          <img class="direct-chat-img" src="<?php echo base_url() ?><?php echo $user->image ?>" alt="message user image">
                            <!-- /.direct-chat-img -->
                          <div class="direct-chat-text">
                              <div class="row">
                              <?php if($value_admin->image): ?>
                                <div class="col-sm-3">
                                     <img src="<?php echo base_url() ?><?php echo $value_admin->image ?>" height="70px;">
                                </div>
                              <?php endif;?>
                              <div class="col-sm-<?php if($value_admin->image){echo '9';}else{echo '12';}?>">
                                  <?php echo $value_admin->comment ?>
                              </div>
                            </div>
                          </div>
                            <!-- /.direct-chat-text -->
                        </div> 
                        <div class="">

                        </div> 
                      </div>
                    </div>
                  <?php endif; ?>
                  <?php if($value_admin->who_from == 1): ?>
                    <div class="row">
                      <div class="col-md-12">
                        <div class="direct-chat-msg right">
                          <div class="direct-chat-infos clearfix">
                            <span class="direct-chat-name float-right"><?php echo $user->name ?> (<?php echo $user->role ?>)</span>
                            <span class="direct-chat-timestamp float-left"><?php echo date('d-M-y h:i A', strtotime($value_admin->datetime)); ?></span>
                          </div>
                            <!-- /.direct-chat-infos -->
                          <img class="direct-chat-img" src="<?php echo base_url() ?><?php echo $user->image ?>" alt="message user image">
                            <!-- /.direct-chat-img -->
                          <div class="direct-chat-text">
                            <div class="row">
                              <?php if($value_admin->image): ?>
                                <div class="col-sm-3">
                                     <img src="<?php echo base_url() ?><?php echo $value_admin->image ?>" height="70px;">
                                </div>
                              <?php endif;?>
                              <div class="col-sm-<?php if($value_admin->image){echo '9';}else{echo '12';}?>">
                                  <?php echo $value_admin->comment ?>
                              </div>
                            </div>
                          </div>
                            <!-- /.direct-chat-text -->
                        </div>  
                      </div>
                    </div>
                  <?php endif; ?>
                <?php endforeach; ?>
              </div>
            </div>
          </div>

        </div>
        
      </div>
      <!-- /.card -->

    </section>
