<?php $this->load->view('site/layout'); ?>

<?php $this->load->view('site/navbar'); ?>
<style>
    .reply p{
        font-size: 20px;
    }
</style>
<div class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor" id="kt_content">

    <!-- begin:: Content Head -->
    <div class="kt-subheader  kt-grid__item" id="kt_subheader">
        <div class="kt-container  kt-container--fluid ">
            <div class="kt-subheader__main">
                <h3 class="kt-subheader__title"><a href="<?php echo base_url() ?>Dashboard/"><?php echo $this->lang->line('dashboard'); ?></a></h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <span class="kt-subheader__desc"><a href="<?= base_url('support/tickets') ?>"><?php echo $this->lang->line('support') ?></a></span>
            </div>

        </div>
    </div>

    <div class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor" id="kt_content">

        <!-- begin:: Content Head -->
        <div class="kt-subheader  kt-grid__item" id="kt_subheader">
            <div class="kt-container  kt-container--fluid ">
                <div class="kt-subheader__main">
                    <h3 class="kt-subheader__title"><a href="<?php echo base_url() ?>Dashboard/"><?php echo $this->lang->line('dashboard'); ?></a></h3>
                    <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                    <span class="kt-subheader__desc"><?php echo $this->lang->line('ticket'); ?></span>
                </div>

            </div>
        </div>
    </div>
    <?php if ($this->session->flashdata('msg')): ?>
        <div class="alert alert-success alert-dismissible">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4><i class="icon fa-warning"></i> Success!</h4>
            <?= $this->session->flashdata('msg') ?>
        </div>
    <?php endif; ?> 
    <div class="kt-portlet kt-portlet--mobile">
        <div class="kt-portlet__head kt-portlet__head--lg">
            <div class="kt-portlet__head-label">
                <span class="kt-portlet__head-icon">
                  <!-- <i class="kt-font-brand flaticon2-line-chart"></i> -->
                </span>
                <h3 class="kt-portlet__head-title">
                    <?php echo $this->lang->line('show'); ?> <?php echo $this->lang->line('ticket'); ?>
                </h3>
            </div>

        </div>
        <div class="kt-portlet__body">

            <!--begin: Datatable -->
            <table class="table table-striped- table-bordered table-hover" id="kt_table_1">
                <tbody>
                    <tr>

                        <th  colspan="4"><?php echo $this->lang->line('data') ?></th>

                    </tr>

                    <tr>
                        <th><?php echo $this->lang->line('title') ?></th>
                        <td><?= $ticket->title; ?></td>
                        <th><?php echo $this->lang->line('student') ?></th>
                        <td><?= $ticket->client_name; ?></td>
                    </tr>

                    <tr>
                        <th><?= $this->lang->line('department') ?></th>
                        <td><?= $this->session->userdata('language') == 'english' ? $ticket->dept_name_eng : $ticket->dept_name_ar ?></td>
                        <th><?php echo $this->lang->line('the_type') ?></th>
                        <td><?= get_type($ticket->type) ?> </td>
                    </tr>

                    <tr>
                        <th><?php echo $this->lang->line('priority') ?></th>
                        <td><?= get_priority($ticket->priority) ?> </td>
                        <th><?php echo $this->lang->line('status') ?></th>
                        <td><?= get_status($ticket->status); ?> </td>

                    </tr>
                    <tr>
                        <th><?php echo $this->lang->line('added_by') ?></th>
                        <td><?= $ticket->created_name ?></td>
                    </tr>
                    <tr>
                        <th><?php echo $this->lang->line('the-description') ?></th>
                        <td colspan="3"><?= $ticket->desc ?> </td>
                    </tr>

                </tbody>
            </table>

            <br/>
            <br/>
            <hr/>
            <div class="reply">
                <?php foreach ($replies as $reply) { ?>
                    <h4><?= $reply->created_name ?></h4>
                    <span><?= $reply->created_at ?></span>
                    <p><?= $reply->reply ?></p>
                    <hr/>
                <?php } ?>
                <?php if (isset($msg) || validation_errors() !== ''): ?>
                    <div class="alert alert-warning alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <h4><i class="icon fa-warning"></i> Alert!</h4>
                        <?= validation_errors(); ?>
                        <?= isset($msg) ? $msg : ''; ?>
                    </div>
                <?php endif; ?> 
                <?php if (get_ap('supp_add_reply', $this->operator_id)) { ?>
                    <form class="kt-form kt-form--label-right" method="post" action="">
                        <div class="form-group row">
                            <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('add_reply') ?></label>
                            <div class="col-10">
                                <textarea name="reply" rows="7" class="form-control"></textarea>
                            </div>
                        </div>
                        <div class="kt-portlet__foot">
                            <div class="kt-form__actions">
                                <div class="row">
                                    <div class="col-2">
                                    </div>
                                    <div class="col-10">
                                        <button type="submit" class="btn btn-primary"><?= $this->lang->line('add') ?></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                <?php } ?>
            </div>
            <hr/>
            <div class="">
                <div class="kt-form__actions">
                    <?php //if (get_ap('supp_edit_ticket', $this->operator_id)) { ?>
                        <!--<a title="Edit"  href="<?= base_url('support/' . $this->thispage . '/edit/' . $ticket->id) ?>"><button type="reset" class="btn btn-primary"><i class="la la-edit"></i><?php echo $this->lang->line('edit') ?></button></a>-->
                    <?php //} ?>
                    <?php //if (get_ap('supp_del_ticket', $this->operator_id)) { ?>
                        <!--<a title="delete" href="" onclick="alert_box(<?php echo $ticket->id ?>)"><button type="reset" class="btn btn-danger"><i class="la la-trash"></i><?php echo $this->lang->line('delete') ?></button></a>--> 
                    <?php //} ?>                                                                                                                                                                                
                    <!--  <button type="reset" class="btn btn-primary">Submit</button><button type="reset" class="btn btn-secondary">Cancel</button> -->
                </div>
            </div>
            <!--end: Datatable -->
        </div>
    </div><!-- /.row -->
    <script src="<?php echo base_url() ?>public/plugins/global/plugins.bundle.js" type="text/javascript"></script>
    <script src="<?php echo base_url() ?>public/js/scripts.bundle.js" type="text/javascript"></script>

    <!--end::Global Theme Bundle -->

    <!--begin::Page Vendors(used by this page) -->
    <script src="<?php echo base_url() ?>public/plugins/custom/datatables/datatables.bundle.js" type="text/javascript"></script>

    <!--end::Page Vendors -->

    <!--begin::Page Scripts(used by this page) -->
    <script src="<?php echo base_url() ?>public/js/pages/crud/datatables/basic/basic.js" type="text/javascript"></script>
    <script>function alert_box(id) {
            var result = confirm("Are You Confirm!")
            if (result) {
                window.location.href = "<?= base_url('support/' . $this->thispage . '/del/') ?>" + id;

            }

        }</script>