<?php $__env->startSection('title', 'Tickets'); ?>
<?php $__env->startSection('content'); ?>
<style>
.admincomments{
    background: #00ba8b !important;
    color: white;
}

/* datatable height decrese*/
.table.dataTable tbody td {
    padding-bottom: 3px !important;
    padding-top: 2px !important;
}
.table th, .table td{
    padding-bottom: 0px !important;
}


.text-danger{
    color: red;
}

/* table action button css*/
.action-table .btn-small {
    padding: 4px;
    font-size: 14px;
}


.asterisk::after {content: "*"; color:red;}



/* jquery form validation errors */
.error{color: red;}

/* comments images avatar */
figure {
  display:inline-block;
  margin:10px;
  max-width:100px;
  vertical-align:top;
}

figure img {
  display:block;
  margin:0 auto;
}

figcaption {
  display:block;
  padding:5px;
  text-align: center;
  max-width: 70px;
}

.bootstrap-tagsinput {
width: 560px;
}

.customefilter, .customeprioritiyfilter {
    width:300px;
    float:right;
}
.dataTables_wrapper .dataTables_filter {
    text-align: left !important;
}
#table_filter input {
    margin: 0;
}

.multiselect, .multiselect-container {
    width: 100% !important;
}

.cke_combo__strinsert, .cke_combo_button, .cke_combo_label {
    width: 150px !important;
}
.cke_combo_text, .cke_combo_open {
    width: 115px !important;
}

/*dropzone*/
.attach-img-tag {
    border: 1px solid #ddd; 
    border-radius: 4px;  
    padding: 5px;
    width: 85%;
    height: 100px;
    margin-top:10px;
}

/* Add a hover effect (blue shadow) */
.attach-img-tag:hover {
    box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
}
.thumbnail-attach .caption {
    padding: 5px;
    text-align:center;
}

.dropzone .dz-message {  margin: 0 !important;}
.dropzone {  min-height: inherit !important;}

/* Lightbox */
#close-lightbox {
    position: fixed;
    top: 20px;
    right: 20px;
    font-size: 40px;
    color: #FFF;
    cursor: pointer
}

#lightbox-image {
    position: fixed;
    top: 50%;
    left: 50%;
    margin: 0;
    max-width: 100%;
    -webkit-transform: translate(-50%, -50%);
    -moz-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%)
}

#lightbox-image-wrapper {
    width: auto;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto
}

#lightbox-wrapper {
    display: none;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .8);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99999
}

#lightbox-wrapper.active {
    display: block
}

.smp-lightbox {
    cursor: pointer;
    cursor: -moz-zoom-in;
    cursor: -webkit-zoom-in;
    cursor: zoom-in
}

.status-notification{
    padding: 4px;
    border-radius: 4px;
    text-align:right;
}

/* Message layout */


ul.messages_layout {
    position: relative;
    margin: 0;
    padding: 0
}
ul.messages_layout li {
    list-style: none;
    position: relative
}
ul.messages_layout li.left {
    padding-left: 100px
}
ul.messages_layout li.right {
    padding-right: 100px
}
ul.messages_layout li.right .avatar {
    right: 0;
    left: auto
}
ul.messages_layout li.right .message_wrap .arrow {
    right: -12px;
    left: auto;
    background-position: 0 -213px;
    height: 15px;
    width: 12px
}
ul.messages_layout li.by_myself .message_wrap {
    border: 1px solid #b3cdf8
}
ul.messages_layout li.by_myself .message_wrap .info a.name {
    color: #4a8cf7
}
ul.messages_layout li a.avatar {
    position: absolute;
    left: 0;
    top: 0;
    padding: 5px
}
ul.messages_layout li a.avatar img {
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px
}
ul.messages_layout li .message_wrap {
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
    position: relative;
    border: 1px solid #e9e9e9;
    padding: 10px;
    border: 1px solid #cbcbcb;
    margin-bottom: 20px;
    background: #fefefe;
    -webkit-box-shadow: rgba(0,0,0,0.1) 0 1px 0px;
    -moz-box-shadow: rgba(0,0,0,0.1) 0 1px 0px;
    box-shadow: rgba(0,0,0,0.1) 0 1px 0px
}
ul.messages_layout li .message_wrap .arrow {
    background-position: 0 -228px;
    height: 15px;
    width: 12px;
    height: 15px;
    width: 12px;
    position: absolute;
    left: -12px;
    top: 13px
}
ul.messages_layout li .message_wrap .info {
    width: 100%;
    text-align: right;
    line-height: 23px;
}
ul.messages_layout li .message_wrap .info .name {
    float: left;
    font-weight: bold;
    color: #483734
}
ul.messages_layout li .message_wrap .info .time {
    font-size: 11px;
    margin-left: 6px
}
ul.messages_layout li .message_wrap .text {
    width: 100%;
    border-bottom: 1px solid #cfcfcf;
    padding-bottom: 5px
}

ul.messages_layout .dropdown-menu  li{ width:100%; font-size:11px;}

</style>

            <div class="row">
                <?php if($message = Session::get('success')): ?>
                    <div class="alert alert-success">
                        <p><?php echo e($message); ?></p>
                    </div>
                <?php endif; ?>
                    <h2>#<?php echo e($tickets[0]->id); ?>-<?php echo e($tickets[0]->shortname); ?>  :  <?php echo e($tickets[0]->subject); ?>

                        <a href="<?php echo str_replace('support/', '', $tickets[0]->base_url); ?>shop_index.php?domain=<?php echo e($shopdetails[0]->shop_domain); ?>&secret=<?php echo e($shopdetails[0]->shop_secret); ?>" target="_blank" class="btn pull-right">Login to Shop</a></h2>
                    </h2>
            </div>
            <div class="page-bx">
                <div class="ticket-sidebar item-container">
                    <div class="row">
                        <div class="col-lg-6 col-sm-6">
                                <ul>
                                    <li><strong>App</strong>: <?php echo e($tickets[0]->cname); ?></li>
                                    <li><strong>Status</strong>:
                                        <label class="name" style="display:inline-block;"><span style="color: #441313">Review Request Sent</span> &nbsp;</label>
                                        <select name="sp_main_status" id='sp_main_status' class='com_text' style="display: none;">
                                            <?php $__currentLoopData = $statuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($status->name); ?>" data-id="<?php echo e($status->id); ?>"> <?php echo e($status->name); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                         <select id="time_main_durations" name="time_main_durations" style="display: none;">
                                             <option value="0" data-id="0">Select Duration</option>
                                                <?php $__currentLoopData = $time_durations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $durations): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value="<?php echo e($durations->id); ?>" data-id="<?php echo e($durations->id); ?>"> <?php echo e($durations->name); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                        <a href="javascript:void(0)" class="edit" style="color:#21a9ec;font-size: 17px;"><span class="fa fa-pencil"></span></a>
                                        <a href="javascript:void(0)" class="save" style="display: none;font-size: 20px;"><span class="fa fas fa-check"></span></a>
                                        <a href="javascript:void(0)" class="cancel" style="display: none;color:#bd2b1f;font-size: 20px;"><span class="fa fa-remove"></span></a>
                                    </li>
                                    <li><strong>Priority</strong>:
                                        <label class="pname" style="display:inline-block;"><span style="color: <?php echo e($tickets[0]->pcolor); ?>"><?php echo e($tickets[0]->pname); ?></span> &nbsp;</label>
                                        <select id='text_2' class='pcom_text' style="display: none;">
                                            <?php $__currentLoopData = $priority; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prty): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($prty->name); ?>" data-id="<?php echo e($prty->id); ?>"> <?php echo e($prty->name); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                        <a href="javascript:void(0)" class="pedit" style="color:#21a9ec;font-size: 17px;"><span class="fa fa-pencil"></span></a>
                                        <a href="javascript:void(0)" class="psave" style="display: none;font-size: 20px;"><span class="fa fas fa-check"></span></a>
                                        <a href="javascript:void(0)" class="pcancel" style="display: none;color:#bd2b1f;font-size: 20px;"><span class="fa fa-remove"></span></a>
                                    </li>
                                    <li><strong>Category</strong>: <?php echo e($tickets[0]->subname); ?></li>
                                    <li><strong>Email</strong>: <?php echo e($tickets[0]->email); ?></li>
                                    <li><strong>Created</strong>: <time title="<?php echo e($tickets[0]->created_at); ?>"><?php echo e(Carbon\Carbon::parse($tickets[0]->created_at)->diffForHumans()); ?></time></li>
                                    <li><strong>Last Update</strong>: <time id="updatedt_at" title="<?php echo e($tickets[0]->updated_at); ?>"><?php echo e(Carbon\Carbon::parse($tickets[0]->updated_at)->diffForHumans()); ?></time></li>
                                </ul>
                        </div>
                        <div class="col-lg-6 col-sm-6">
                            <ul>
                                <li><strong>Store ID</strong>: <?php echo e($shopdetails[0]->shop_id); ?></li>
                                <li><strong>Store Name</strong>: <?php echo e($shopdetails[0]->shop_name); ?></li>
                                <li><strong>Store owner's Name</strong>: <?php echo e($shopdetails[0]->shop_owner_name); ?></li>
                                <li><strong>Store owner's email</strong>: <?php echo e($shopdetails[0]->shop_owner_email); ?></li>
                                <li><strong>Custom Domain</strong>: <?php echo e($shopdetails[0]->shop_domain); ?></li>
                                <li><strong>Shopify Domain</strong>: <?php echo e($shopdetails[0]->shop_shopify_domain); ?></li>
                            </ul>
                        </div>
                        <hr/>
                        <div class="col-md-12">
                            <h3>Description:</h3>
                                <?php echo $tickets[0]->content; ?>

                        </div>
                    </div>
                </div>
            </div> 

            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-body">
                            <h3 class="card-title">Comment</h3>
                            <!-- Create the editor container -->
                            <div class="ticket-commentbar">
                                                     <?php if($comments->isEmpty() ): ?>
                    <h3 style="text-align: center;" id="blankcomment">Be the first to comment.</h3>
                <?php endif; ?>
                <ul class="messages_layout">
                        <?php $__currentLoopData = $tickets_notifications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tnotify): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($tnotify->last_comments_id == 0): ?>
                                <?php if($tnotify->status_id != 1): ?>
                                <li class="left">
                                    <div class="message_wrap1 alert alert-info">
                                    <span class="status-notification">Status Set To <b><?php echo e($tnotify->status_name); ?></b>
                                    <?php if($tnotify->time_durations_id != 0): ?>
                                    On <b><?php echo e($tnotify->duration_name); ?></b>
                                    <?php endif; ?>
                                    , Updated By <b><?php echo e($tnotify->uname); ?></b></span></div></li>
                                <?php endif; ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    
                    <?php $__currentLoopData = $comments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cmnt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li class="from_user <?php echo e(($cmnt->commentable_type == 0) ? 'right' : 'left'); ?>"> <a href="#" class="avatar" title="<?php echo e($cmnt->uname); ?>"><figure><img src="<?php echo e(Gravatar::src($cmnt->uemail, 40)); ?>"><figcaption><?php echo e($cmnt->uname); ?></figcaption></figure></a>
                        <div class="message_wrap <?php echo e(($cmnt->support_team_display == 1) ? 'admincomments' : ''); ?>">
                            <div class="text"><?php echo $cmnt->content; ?>

                               <div class="row">
                            <?php $__currentLoopData = $tickets_attachements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $attach): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                               
                                <?php if(($cmnt->id) == ($attach->comment_id)): ?>
                                            <div class="col-md-2">
                                              <div class="thumbnail-attach">
                                            
                                                <?php if(in_array($attach->file_ext, ['png','jpeg','jpg'])): ?>
                                                    <img src="<?php echo e(url('img/atteach')); ?>/<?php echo e($attach->file_name); ?>" class="attach-img-tag" />
                                                <?php else: ?>
                                                    <img src="<?php echo e(url('img')); ?>/default-attachment.png" class="attach-img-tag" />
                                                <?php endif; ?>
                                                  <div class="caption">
                                                    <p><?php echo e($attach->file_name); ?></p>
                                                  </div>
                                            
                                              </div>
                                            </div>
                
                                             <?php endif; ?>
                
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </div>
                            </div>

                            <span class="arrow"></span>
                            <div class="info">
                                <span class="time"><i class=" icon-time"></i> <time title="<?php echo e($cmnt->updated_at); ?>"><?php echo e(Carbon\Carbon::parse($cmnt->updated_at)->diffForHumans()); ?></time> </span>
                            </div>

                        </div>
                    </li>
                        <?php $__currentLoopData = $tickets_notifications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tnotify): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if(($cmnt->id) == ($tnotify->last_comments_id)): ?>
                                <?php if($tnotify->status_id != 1): ?>
                                <li class="left">
                                    <div class="message_wrap1 alert alert-info">
                                    <span class="status-notification">Status Set To <b><?php echo e($tnotify->status_name); ?></b>
                                    <?php if($tnotify->time_durations_id != 0): ?>
                                    On <b><?php echo e($tnotify->duration_name); ?></b>
                                    <?php endif; ?>
                                    , Updated By <b><?php echo e($tnotify->uname); ?></b></span>
                                </div>
                                </li>
                                <?php endif; ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>   


    <div class="row">
        <div class="col-md-12">
            <div class="msgsuccess"></div>
            <h3>Reply:</h3>
            <div class="form-group">
                <input name="ticket_id" id="ticket_id" type="hidden" value="<?php echo e($tickets[0]->id); ?>">
                <input name="user_ids" id="user_ids" type="hidden" value="<?php echo e($tickets[0]->user_id); ?>">
                <textarea class="ckeditor" name="content" cols="30" id="content" placeholder="Describe your issue here in details"></textarea>
                <span class="text-danger contenterror"></span>
            </div>
            <div class="form-group">
                <form action="<?php echo e(url('/updatemultipleimages')); ?>" enctype="multipart/form-data" class="dropzone" id="image-upload"></form>
                <br/>
                <b>Note:</b> You can upload maximum 5 files. File size should not exceed 5MB.
                <ul class="status-container pull-right">
                <strong>Status</strong>:</td><td> <label class="status_name" style="display:inline-block;">
                <span style="color: <?php echo e($tickets[0]->scolor); ?>"><?php echo e($tickets[0]->sname); ?></span> &nbsp;
                </label>

                <select name="sp_status" id='sp_status' class='status_com_text' style="display: none;">
                <?php $__currentLoopData = $statuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($status->name); ?>" data-id="<?php echo e($status->id); ?>"> <?php echo e($status->name); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <select id="time_durations" name="time_durations" style="display: none;">
                <option value="0" data-id="0">Select Duration</option>
                <?php $__currentLoopData = $time_durations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $durations): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($durations->id); ?>" data-id="<?php echo e($durations->id); ?>"> <?php echo e($durations->name); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>           
                <a href="javascript:void(0)" class='status_edit' style="color:#21a9ec;font-size: 17px;">
                <span class="fa fa-pencil"></span>
                </a>
                <a href="javascript:void(0)" class='status_save' style="display: none;font-size: 20px;">
                <span class="fa fa-check"></span>
                </a>
                <a href="javascript:void(0)" class='status_cancel' style="display: none;color:#bd2b1f;font-size: 20px;">
                <span class="fa fa-remove"></span>
                </a>
                </ul>
            </div>
            <div class="form-group">
                <?php if(auth()->guard()->guest()): ?>
                    <input type="hidden" id="commentable_type" name="commentable_type" class="form-control" value="0">
                    <input type="hidden" id="support_team_display" name="support_team_display" value="0" id="support_team_display">
                <?php else: ?>
                    <div class="form-group">
                        <div class="col-lg-12">
                            <label><input type="checkbox" name="support_team_display" value="1" id="support_team_display"> Visible only to Support Team</label>
                        </div>
                    </div>
                    <input type="hidden" name="commentable_type" id="commentable_type" class="form-control" value="1">
                <?php endif; ?>                            
                <button class="btn btn-save" type="submit">Save</button>
                <span id="loading" style="display:none;"><img src="<?php echo e(asset('images')); ?>/loading.gif" height="50" width="100" /></span>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <script src="//ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
    <script src="//sdk.ckeditor.com/vendor/ckeditor/4.11.1/ckeditor.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.0.1/min/dropzone.min.css" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.2.0/min/dropzone.min.js"></script>
     <script src="<?php echo e(asset('js/simple-lightbox.min.js')); ?>"></script>
<script type="text/javascript">
$("#time_durations").hide();
$("#sp_status").on( 'change', function (event) {
    event.preventDefault();
    var appFilter = $("#sp_status option:selected").attr('data-id'); 
    //alert(appFilter);
        if(appFilter == 4 || appFilter == 5)
        {
            $("#time_durations").show();
        }
        else
        {
            $("#time_durations").hide();
        }                   
} );

$("#time_main_durations").hide();
$("#sp_main_status").on( 'change', function (event) {
    event.preventDefault();
    var appFilter = $("#sp_main_status option:selected").attr('data-id');  
    //alert(appFilter);
        if(appFilter == 4 || appFilter == 5)
        {
            $("#time_main_durations").show();
        }
        else
        {
            $("#time_main_durations").hide();
        }                   
} );

Dropzone.options.imageUpload = {
    maxFilesize:5,
    maxFiles: 5,
};
Dropzone.autoDiscover = false;

var myDropzone = $(".dropzone").dropzone({
 addRemoveLinks: true,
    params: {
        _token: '<?php echo e(csrf_token()); ?>',
        ticket_id : $('#ticket_id').val()
    },
    success: function(file, response){
        file.attachment_id = response;
    },
 removedfile: function(file) {
  var name = file.name; 
   
  $.ajax({
   type: 'POST',
   url: '<?php echo e(url('/updatemultipleimages')); ?>',
   data: {name: name,request: 2,_token: '<?php echo e(csrf_token()); ?>',atach_id:file.attachment_id},
   sucess: function(data){
    console.log('success: ' + data);
   }
  });
  var _ref;
  return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
 }
});
    
            //ajax form submit with commented

        function time_ago(time) {

            switch (typeof time) {
                case 'number':
                    break;
                case 'string':
                    time = +new Date(time);
                    break;
                case 'object':
                    if (time.constructor === Date) time = time.getTime();
                    break;
                default:
                    time = +new Date();
            }
            var time_formats = [
                [60, 'seconds', 1], // 60
                [120, '1 minute ago', '1 minute from now'], // 60*2
                [3600, 'minutes', 60], // 60*60, 60
                [7200, '1 hour ago', '1 hour from now'], // 60*60*2
                [86400, 'hours', 3600], // 60*60*24, 60*60
                [172800, 'Yesterday', 'Tomorrow'], // 60*60*24*2
                [604800, 'days', 86400], // 60*60*24*7, 60*60*24
                [1209600, 'Last week', 'Next week'], // 60*60*24*7*4*2
                [2419200, 'weeks', 604800], // 60*60*24*7*4, 60*60*24*7
                [4838400, 'Last month', 'Next month'], // 60*60*24*7*4*2
                [29030400, 'months', 2419200], // 60*60*24*7*4*12, 60*60*24*7*4
                [58060800, 'Last year', 'Next year'], // 60*60*24*7*4*12*2
                [2903040000, 'years', 29030400], // 60*60*24*7*4*12*100, 60*60*24*7*4*12
                [5806080000, 'Last century', 'Next century'], // 60*60*24*7*4*12*100*2
                [58060800000, 'centuries', 2903040000] // 60*60*24*7*4*12*100*20, 60*60*24*7*4*12*100
            ];
            var seconds = (+new Date() - time) / 1000,
                token = 'ago',
                list_choice = 1;

            if (seconds == 0) {
                return 'Just now'
            }
            if (seconds < 0) {
                seconds = Math.abs(seconds);
                token = 'from now';
                list_choice = 2;
            }
            var i = 0,
                format;
            while (format = time_formats[i++])
                if (seconds < format[0]) {
                    if (typeof format[2] == 'string')
                        return format[list_choice];
                    else
                        return Math.floor(seconds / format[2]) + ' ' + format[1] + ' ' + token;
                }
            return time;
        }

        $(document).ready(function()
        {
            $(".attach-img-tag").simpleLightBox();
        
            $( ".btn-save" ).click(function() {
                for (instance in CKEDITOR.instances) {
                    CKEDITOR.instances[instance].updateElement();
                }

                if($('#content').val() == '')
                {
                    $(".contenterror").text("Enter Describe your issue here in details");
                }
                else{
                    
                    

            $(".btn-save").hide();
            $("#loading").show();
            

                    var form_data = new FormData();                  // Creating object of FormData class
                    
                   <?php if(Auth::user()): ?>
                        form_data.append("user_id", <?php echo e(Auth::user()->id); ?>);
                   <?php else: ?>
                        form_data.append("user_id", $('#user_ids').val());
                   <?php endif; ?>
                   
                    form_data.append("content", $('#content').val());
                    form_data.append("commentable_type", $('#commentable_type').val());
                    form_data.append("ticket_id", $('#ticket_id').val());
                    if($('#support_team_display').prop("checked") == true){
            
                        form_data.append("support_team_display", 1);
                        var superadmin = "admincomments";
                    }
                    else if($('#support_team_display').prop("checked") == false){
                        form_data.append("support_team_display", 0);
                        var superadmin = "123";
                    }
                    
                    form_data.append("_token", '<?php echo e(csrf_token()); ?>');


                    $.ajax({
                        type:"POST",
                        dataType:"json",
                        url:"<?php echo e(url('ticketcomments')); ?>",
                        cache: false,
                        contentType: false,
                        processData: false,
                        data: form_data,
                        success: function (data) {
                            
                            $('.dropzone')[0].dropzone.files.forEach(function(file) { 
                              file.previewElement.remove(); 
                            });

                            $('.dropzone').removeClass('dz-started');
                            
                            $('#content').val('');
                            $('#imagevalue').val('');
                            $(".contenterror").text("");
                            $(".imagevalueerror").text("");
                            $("#loading").hide();
                            $(".btn-save").show();
                            $("#blankcomment").hide();
                            CKEDITOR.instances.content.setData( '' );
                            $('#support_team_display').attr('checked',false);
                            if(data.comment[0].commentable_type == 0){
                                var side = "right";
                                var useradminicon="user";
                            }
                            else {
                                var side = "left";
                                var useradminicon="admin";
                            }
                            var updated_at= data.comment[0].updated_at;
                            var updated_final_at= time_ago(new Date(Date.now()));
                            var username = data.comment[0].uname;
                            var gravatar_img = "<?php echo e(Gravatar::src('admin@simprosys.net', 40)); ?>";
                            

                            var total_attach_files = data.tickets_attachements.length;
                            var total_attachements_str = '';
                            var ar_ext = ['jpg', 'gif', 'png', 'jpeg']; 
                            total_attachements_str += "<div class='row'>";
                             for(var i=0;i<total_attach_files;i++)
                             {
                                if (ar_ext.indexOf(data.tickets_attachements[i].file_ext) === -1) {
                                    total_attachements_str +="<div class='col-md-2'><div class='thumbnail-attach'><img src='<?php echo e(url('img')); ?>/default-attachment.png' class='attach-img-tag smp-lightbox'><div class='caption'><p>"+data.tickets_attachements[i].file_name+"</p></div></div></div>";

                                }
                                else {
                                 total_attachements_str +="<div class='col-md-2'><div class='thumbnail-attach'><img src='<?php echo e(url('img/atteach')); ?>/"+data.tickets_attachements[i].file_name+"' class='attach-img-tag smp-lightbox'><div class='caption'><p>"+data.tickets_attachements[i].file_name+"</p></div></div></div>";
                                }
                             }
                            total_attachements_str += "</div>";
                            
                            
                            $('time[id="updatedt_at"]').text(updated_final_at);
                            $(".messages_layout").append('<li class="from_user ' + side + '"> <a href="#" class="avatar" title="' + username + '"><figure><img src="'+ gravatar_img +'" /><figcaption>' + username + '</figcaption></figure></a> <div class="message_wrap"><div class="text">'+data.comment[0].content + total_attachements_str +'</div><span class="arrow"></span> <div class="info"><span class="time"><i class="icon-time"></i><time title="'+ updated_at +'"> '+ updated_final_at +' </time></span> </div> </div></li>');
                           // $(".messages_layout").append('<li class="from_user ' + side + '"> <a href="#" class="avatar" title="' + username + '"><img src="<?php echo e(asset('img')); ?>/'+ useradminicon +'.png" height="25" width="25" /></a> <div class="message_wrap"><div class="text">'+data.comment[0].content+'</div><span class="arrow"></span> <div class="info"> <span class="time"><i class="icon-time"></i><time title="'+ updated_at +'"> '+ updated_final_at +' </time></span> </div> </div></li>');
                            $(".message_wrap").last().addClass(superadmin);
                            $(".msgsuccess").html('<div class="alert alert-success msgsuccessdata">Comment has been added successfully</div>');
                           $(".attach-img-tag").simpleLightBox();
                            $(".attach-img-tag").addClass("smp-lightbox");
                            setTimeout(function() {
                                $(".msgsuccessdata").hide();
                            }, 3000);
                        },
                        error: function (data) {
                            console.log('Error:', data);
                            var obj = {
                            };
                        }
                    });
                }
            });
        });
    
        $(document).ready(function()
        {

            $('.com_text').click(function()
            {
                var com_text = $(this).attr('id');
            });

            $('.pcom_text').click(function()
            {
                var pcom_text = $(this).attr('id');
            });

            //Edit
            $('.edit').click(function()
            {
                $(this).hide();
                var itemWrapper = $(this).closest('.item-container'),
                    currentItemLabel = itemWrapper.find('.name').text().trim();

                itemWrapper.find('.name').hide();
                itemWrapper.find('.save,.cancel').show();
                itemWrapper.find('.com_text').val(currentItemLabel);
                itemWrapper.find('.com_text').show();
            });

            $('.pedit').click(function()
            {
                $(this).hide();
                var itemWrapper = $(this).closest('.item-container'),
                    currentItemLabel = itemWrapper.find('.pname').text().trim();

                itemWrapper.find('.pname').hide();
                itemWrapper.find('.psave,.pcancel').show();
                itemWrapper.find('.pcom_text').val(currentItemLabel);
                itemWrapper.find('.pcom_text').show();
            });

            //Cancel
            $('.cancel').click(function()
            {
                $(this).hide();
                var itemWrapper = $(this).closest('.item-container');

                itemWrapper.find('.name,.edit').show();
                itemWrapper.find('.save').hide();
                itemWrapper.find('.com_text').hide();
                itemWrapper.find('.com_text').val('');
                $("#time_main_durations").hide();

            });

            $('.pcancel').click(function()
            {
                $(this).hide();
                var itemWrapper = $(this).closest('.item-container');

                itemWrapper.find('.pname,.pedit').show();
                itemWrapper.find('.psave').hide();
                itemWrapper.find('.pcom_text').hide();
                itemWrapper.find('.pcom_text').val('');

            });

            //Save
            $('.save').click(function()
            {
                var itemWrapper = $(this).closest('.item-container');
                var sname = itemWrapper.find('.com_text').val().trim();
                var ticket_id = $("input[name=ticket_id]").val();
                var status_id = itemWrapper.find('.com_text').find(':selected').attr('data-id');
                var dataobj = {};
                // dataobj.sid = $(this).attr('data-id');
                dataobj.status_id = status_id.trim();
                dataobj.sname = sname.trim();
                dataobj.ticket_id = ticket_id.trim();
                
                dataobj.time_durations = $('#time_main_durations option:selected').val();
                dataobj.user_id = $('#user_ids').val();
                
                dataobj._token = '<?php echo e(csrf_token()); ?>';
                // alert(JSON.stringify(dataobj));
                // Your Ajax Code Here
                // Then run this on success to handle updating
                $.ajax(
                    {
                        type:"POST",
                        dataType:"json",
                        url:"<?php echo e(url('/updateStatus')); ?>",
                        cache: false,
                        data: dataobj,
                        success:function(response)
                        {

                            $(".name").css("color", response['color'][0].color);
                            itemWrapper.find
                            itemWrapper.find('.name').html(sname.trim());
                            itemWrapper.find('.name,.edit').show();
                            itemWrapper.find('.save,.cancel').hide();
                            itemWrapper.find('.com_text').hide();
                            itemWrapper.find('.com_text').val('');
                                                        itemWrapper.find('#time_main_durations').val('');
                            $("#time_main_durations").hide();

                            
                            var notifymessages = "";
                            if(response['notification'][0].time_durations_id != 0)
                            {
                                notifymessages += "On <b>"+response['notification'][0].duration_name+"</b>";
                            }
                            $(".messages_layout").append('<li class="left"><div class="message_wrap1 alert alert-info"><span class="status-notification">Status Set To <b>'+response['notification'][0].status_name+'</b>On <b>'+notifymessages+'</b>, Updated By <b>'+response['notification'][0].uname+'</b></span></div></li>');
                        }
                    });



            });

            //Save
            $('.psave').click(function()
            {

                var itemWrapper = $(this).closest('.item-container');
                var pname = itemWrapper.find('.pcom_text').val().trim();
                var ticket_id = $("input[name=ticket_id]").val();
                var priority_id = itemWrapper.find('.pcom_text').find(':selected').attr('data-id')
                var dataobj = {};
                // dataobj.sid = $(this).attr('data-id');
                dataobj.priority_id = priority_id.trim();
                dataobj.pname = pname.trim();
                dataobj.ticket_id = ticket_id.trim();
                dataobj._token = '<?php echo e(csrf_token()); ?>';
                //  alert(JSON.stringify(dataobj));

                // Your Ajax Code Here
                // Then run this on success to handle updating
                $.ajax(
                    {
                        type:"POST",
                        dataType:"json",
                        url:"<?php echo e(url('/updatepriorities')); ?>",
                        cache: false,
                        data: dataobj,
                        success:function(response)
                        {

                            // ver rescolor = response['color'][0].color;

                            $(".pname").css("color", response['color'][0].color);

                            itemWrapper.find
                            itemWrapper.find('.pname').html(pname.trim());
                            itemWrapper.find('.pname,.pedit').show();
                            itemWrapper.find('.psave,.pcancel').hide();
                            itemWrapper.find('.pcom_text').hide();
                            itemWrapper.find('.pcom_text').val('');
                            $("#time_main_durations").hide();
                        }
                    });
            });
            
                        $('.status_com_text').click(function()
            {
                var status_com_text = $(this).attr('id');
            });


            //Edit
            $('.status_edit').click(function()
            {
                $(this).hide();
                var itemWrapper = $(this).closest('.status-container'),
                    currentItemLabel = itemWrapper.find('.status_name').text().trim();

                itemWrapper.find('.status_name').hide();
                itemWrapper.find('.status_save,.status_cancel').show();
                itemWrapper.find('.status_com_text').val(currentItemLabel);
                itemWrapper.find('.status_com_text').show();
            });
 
            //Cancel
            $('.status_cancel').click(function()
            {
                $(this).hide();
                var itemWrapper = $(this).closest('.status-container');

                itemWrapper.find('.status_name,.status_edit').show();
                itemWrapper.find('.status_save').hide();
                itemWrapper.find('.status_com_text').hide();
                itemWrapper.find('.status_com_text').val('');
                $("#time_durations").hide();

            });
            //Save
            $('.status_save').click(function()
            {
                var itemWrapper = $(this).closest('.status-container');
                var sname = itemWrapper.find('.status_com_text').val().trim();
                var ticket_id = $("input[name=ticket_id]").val();
                var status_id = itemWrapper.find('.status_com_text').find(':selected').attr('data-id')
                var dataobj = {};
                // dataobj.sid = $(this).attr('data-id');
                dataobj.status_id = status_id.trim();
                dataobj.sname = sname.trim();
                dataobj.ticket_id = ticket_id.trim();

                dataobj.time_durations = $('#time_durations option:selected').val();
                dataobj.user_id = $('#user_ids').val();

                dataobj._token = '<?php echo e(csrf_token()); ?>';
                // alert(JSON.stringify(dataobj));
                // Your Ajax Code Here
                // Then run this on success to handle updating
                $.ajax(
                    {
                        type:"POST",
                        dataType:"json",
                        url:"<?php echo e(url('/updateStatus')); ?>",
                        cache: false,
                        data: dataobj,
                        success:function(response)
                        {
                            console.log(response);
                            $(".status_name").css("color", response['color'][0].color);
                            itemWrapper.find
                            itemWrapper.find('.status_name').html(sname.trim());
                            itemWrapper.find('.status_name,.status_edit').show();
                            itemWrapper.find('.status_save,.status_cancel').hide();
                            itemWrapper.find('.status_com_text').hide();
                            itemWrapper.find('.status_com_text').val('');
                            itemWrapper.find('#time_durations').val('');
                            $("#time_durations").hide();

                            var notifymessages = "";
                            if(response['notification'][0].time_durations_id != 0)
                            {
                                notifymessages += "On <b>"+response['notification'][0].duration_name+"</b>";
                            }
                            $(".messages_layout").append('<li class="left"><div class="message_wrap1 alert alert-info"><span class="status-notification">Status Set To <b>'+response['notification'][0].status_name+'</b>On <b>'+notifymessages+'</b>, Updated By <b>'+response['notification'][0].uname+'</b></span></div></li>');
                        }
                    });



            });

            
 
               //deal with copying the ckeditor text into the actual textarea
        CKEDITOR.on('instanceReady', function () {
        $.each(CKEDITOR.instances, function (instance) {
            CKEDITOR.instances[instance].document.on("keyup", CK_jQ);
            CKEDITOR.instances[instance].document.on("paste", CK_jQ);
            CKEDITOR.instances[instance].document.on("keypress", CK_jQ);
            CKEDITOR.instances[instance].document.on("blur", CK_jQ);
            CKEDITOR.instances[instance].document.on("change", CK_jQ);
        });
        });
        
        function CK_jQ() {
        for (instance in CKEDITOR.instances) {
            CKEDITOR.instances[instance].updateElement();
        }
        }
        
        CKEDITOR.config.toolbar = [
            ['Bold','Italic','Underline','myCombo']

        ] ;
            
        CKEDITOR.replace( 'content', {
                extraPlugins: 'autogrow',
                toolbarGroups: [
                    { name: 'mode' },
                    { name: 'basicstyles' },
                    { name: 'styles' }        
               ],
                on: {        
                    pluginsLoaded: function() {
                        var editor = this,
                            config = editor.config;
                        
                        function parseSpan( color ) {
                           // return '<span style="color:' + color + '">' + color + '</span>';
                           //console.log(color);
                           return color;
                        }
                        function htmlDecode(input){
                          var e = document.createElement('div');
                          e.innerHTML = input;
                          return e.childNodes[0].nodeValue;
                        } 
                        
                        var acfRules = 'span{color}';
                     
                        editor.ui.addRichCombo( 'myCombo', {
                            label: 'Canned responses',
                            title: 'Canned responses',
                            toolbar: 'styles',
                            
                            allowedContent: acfRules,
                            
                            requiredContent: acfRules,
               
                            panel: {
                                css: [ CKEDITOR.skin.getPath( 'editor' ) ].concat( config.contentsCss ),
                                multiSelect: false
                            },
                
                            init: function() {
                                this.startGroup( 'Canned responses' );
                                
            
            
                                var items = JSON.parse(htmlDecode('<?php echo e($cannedresponses); ?>'));   
                                 
            
                                //var items =[{"title":"This is a test responses","content":"<p>This is a test responses<\/p>"},{"title":"second canned response","content":"<p>second canned response<\/p>"},{"title":"simple new responsed","content":"<p>simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed&nbsp;simple new responsed<\/p>"}];
                                //console.log(items);
                                for ( var i = 0; i < items.length; i++ ) {
                                    var item = items[ i ];
                                    var content  = item.content.replace(/\n|\r/g, "");
                                    this.add(content, parseSpan( item.title), item.title );
                                }
                            },
            
                            onClick: function( value ) {
                                editor.focus();
                            
                                editor.fire( 'saveSnapshot' );
                               
                                editor.insertHtml( parseSpan( value ) );                    
                                
                                editor.fire( 'saveSnapshot' );
                            },
                            onRender: function() {
                            },
                            onOpen: function() {
                            },
                            refresh: function() {
                                if ( !editor.activeFilter.check( acfRules ) )
                                    this.setState( CKEDITOR.TRISTATE_DISABLED );
                            }
                        } );            
                    }
                }
            } );    
            
            
        });



        $("#form").validate({
            rules: {
                content: {
                    required: true,
                    minlength: 10
                }
            },
            messages: {
                content: {
                required: "Enter Describe your issue here in details",
                    minlength: "Minimum password length is 10"
            }
        },
            submitHandler: function(form) {
                form.submit();
            }
        });
        


    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.default', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>