
@extends( isClient() ? 'layouts.app' : 'layouts.admin')
@push('css')
    <link href="{{ asset('css/support/support.css') }}" rel="stylesheet">
@endpush

@section('content')

 @php
   $support = $supports->first();
   $max_file_size = 5 * 1024;
 @endphp

    <div class="row" id="support-panel">
        <div class="col-xs-12 col-sm-12 column col-sm-offset-0">
            <div class="panel panel-default panel-frm">

                <div class="panel-heading">
                    <div class="row" style="padding-left: 20px;padding-right: 15px">
                        <h3 class="pull-left">Client Support</h3>
                        @if($support->status == config('constant.SUPPORT_STATUS.Open') && (isSupport() || isAdmin()))
                            <button class="btn btn2 pull-right" onclick="reminder_btn_click({{$support->id}},'{{route('process.ajax')}}')" >Reminder</button>
                        @endif
                    </div>
                </div>
                <div class="panel-body">
                    <div class="clearfix"></div>
                    <div class="x_content">
                        <div class="col-md-12">
                            <form method="post" action="{{route('insert.client.support')}}" id="client_support_form"
                                  autocomplete="off"
                                  enctype=multipart/form-data
                                  class="input-form-section">
                                @csrf
                                <input type="hidden" name="id" value="{{$support->id}}">
                                <input type="hidden" name="support_title" value="{{$support->title}}">
                                <h4> Title : {{$support->title}} </h4>
                                <div class="row">
                                    <div class="form-group">
                                        <textarea id="supporttxt" name="support_text" placeholder="Please write what is your problem or needs">  </textarea>
{{--                                        <textarea rows="4" cols="50"  class="form-control"  id="support_text" name="support_text" placeholder="Please write what is your problem or needs" ></textarea>--}}
                                    </div>
                                </div>
                                <div class="row">
                                    <h4> Add attachment (if needed)</h4>
                                    <input id="doc_file" type="file" class="form-control"
                                           name="doc_file"
                                           onchange="return common_helper.fileValidation(this,{{$max_file_size}})"
                                           accept="image/jpeg,image/gif,image/png,image/x-eps,application/pdf,application/zip">
                                    <span class="text-bold"><strong>(Max. file size {{sizeFilter($max_file_size)}} and File Type jpeg, jpg, png, x-eps,pdf,zip)</strong></span>

                                </div>
                                <div class="row">
                                    @if($support->status == config('constant.SUPPORT_STATUS.Open'))
                                        <button type="submit" class="btn btn2 pull-right" >Send</button>
                                    @endif
                                </div>
                            </form>
                        </div>
                    </div>
                    <hr/>

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

        <div class="row">

            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel msger-chat">
                    @if(!empty($supports))
                        @foreach ($supports as  $obj)
                            @php
                                $isadmin = getSupportIsAdmin($obj);
                            @endphp
                            @if($obj->srsender_id == auth()->user()->id)
                                <div class="msg left-msg">
                                    <div class="msg-img"
                                         style="background-image: url('{{asset('images/user.png')}}')">
                                    </div>
                                    <div class="msg-bubble">
                                        <div class="msg-info">
                                            <div class="msg-info-name">{{$obj->first_name}}</div>
                                            <div class="msg-info-time">{{getStringToDateTime($obj->sr_create)}}</div>
                                        </div>

                                        <div class="msg-text">
                                            @php echo $obj->message; @endphp
                                        </div>
                                        @if(!empty($obj->attachment_path))
                                            <a href="{{ getSupportFile($obj->id.'/'.$obj->attachment_path) }}" target="_blank">Attachment</a>
                                        @endif
                                    </div>
                                </div>


                            @elseif($isadmin)

                                <div class="msg left-msg">
                                    <div class="msg-img"
                                         style="background-image: url('{{asset('images/user.png')}}')">
                                    </div>
                                    <div class="msg-bubble">
                                        <div class="msg-info">
                                            <div class="msg-info-name">{{$obj->first_name}}</div>
                                            <div class="msg-info-time">{{getStringToDateTime($obj->sr_create)}}</div>
                                        </div>

                                        <div class="msg-text">
                                            @php echo $obj->message; @endphp
                                        </div>
                                        @if(!empty($obj->attachment_path))
                                            <a href="{{ getSupportFile($obj->id.'/'.$obj->attachment_path) }}" target="_blank">Attachment</a>
                                        @endif
                                    </div>
                                </div>

                            @else
                                <div class="msg right-msg">
                                    <div class="msg-img"
                                         style="background-image: url('{{asset('images/user.png')}}')">
                                    </div>

                                    <div class="msg-bubble">
                                        <div class="msg-info">
                                            <div class="msg-info-name">{{$obj->first_name}}</div>
                                            @if(isAdmin() || isEmployee())
                                                <div class="msg-info-name">{{$obj->email}}</div>
                                            @endif
                                            <div class="msg-info-time">{{getStringToDateTime($obj->sr_create)}}</div>
                                        </div>

                                        <div class="msg-text">
                                            @php echo $obj->message; @endphp
                                        </div>
                                        @if(!empty($obj->attachment_path))
                                            <a href="{{ getSupportFile($obj->id.'/'.$obj->attachment_path) }}" target="_blank">Attachment</a>
                                        @endif
                                    </div>
                                </div>
                            @endif

                        @endforeach
                    @endif

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

 @endsection

@push('script')
    <script src="{{asset('/')}}js/support/support.js?v=1.0.1"></script>
@endpush
