@extends('layouts.dashboard')

@section('page_title')
	Complaints
@endsection

@section('page_header_title')
Support Tokens
@endsection



@section('page_body')
	<div class="row row-cards row-deck">
              <div class="col-12">
                <div class="card">
                	  <div class="card-header">
					    
					   
					    

					     <button  class="float-right btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#md_add_support"><i class="fa fa-plus"></i></button> &nbsp;&nbsp;

					     <h3 class="card-title">Create Token</h3>
					  </div>

                	<div class="card-status card-status-left bg-blue"></div>
                  <div class="table-responsive">
                    <table class="table table-hover table-outline table-vcenter text-nowrap card-table cls_datatable">
                      <thead>
                        <tr>
                          
                          <th></th>

                          <th>#</th>
                          <th>Employee Name</th>
                          <th>Priority</th>
                          <th>Status</th>
                          <th>Complaint Date</th>

                          <th><i class="dropdown-icon fa fa-cogs"></i></th>
                        </tr>
                      </thead>
                      <tbody>

                        @if(@count($response)>0)
                        @if($response[0]['user_id']==Auth::user()->id)

                          @php($pass_data = [])
                          @php($count=0)

                          @foreach($response as $rows)



                          @php($employee_name = str_split($rows['employee_name']))

                          @php($title = str_split($rows['title']))

                          @php($description = str_split($rows['description']))

                               @php(
                              $pass_data = array(
                                  'id'      => Crypt::encrypt($rows['id']),
                                  'employee_name'   => $rows['employee_name'],
                                  'priority'        => $rows['priority'],
                                  'title'           => $rows['title'],
                                  'status'          => $rows['status'],
                                  'description'     => $rows['description']

                               
                                )
                            )
                            
                            @if($rows['status'] == 'Resolve')

                        <tr >
                           <td><svg height="20" width="20" style="padding: 0; margin: 0;">
                           <circle cx="10" cy="10" r="5"  fill="green"  style="padding: 0; margin: 0;"/>
                          </svg></td>                          
                          <td>{{$loop->iteration}}</td>
                          <td>
                           {{$rows['employee_name']}}
                           
                          </td>
                          <td>{{$rows['priority']}}</td>                        
                          
                          <td>{{$rows['status']}}</td>


                          <td>{{EF::dateFormat($rows['created_at'])}}</td>
                          <td class="text-center">

                                  <div class="item-action dropdown">
                                    <a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fa fa-list-ul"></i></a>
                                    <div class="dropdown-menu dropdown-menu-right">
                                       <a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fa fa-cogs"></i> Action</a>
                                      <div class="dropdown-divider"></div>
                                      <a href="{{route('support.chat',['id' => Crypt::encrypt($rows['id'])])}}" class="dropdown-item "><i class="dropdown-icon fa fa-comments"></i> Chat</a>
                                      @if($rows['status'] == "Unresolve")
                                      <a onclick="update(event,'{{json_encode($pass_data)}}','form_update_support','md_update_support')" href="javascript:void(0)" class="dropdown-item" data-toggle="modal" data-target="#md_update_support"><i class="dropdown-icon fa fa-edit"></i> Update Complaint </a>
                                      @endif
                                   
                                      @if($rows['status'] != "Resolve")
                                      <a href="{{route('support.delete',['id' => Crypt::encrypt($rows['id'])])}}" class="dropdown-item cls_delete" content="remove complaint"><i class="dropdown-icon fa fa-trash"></i> Remove Complaint</a>
                                     @endif
                                     
                                     
                                    </div>
                                  </div>
                               </td>
                        </tr>
                        @endif
                            @if($rows['status'] != 'Resolve')
                              <tr >
                          <td><svg height="20" width="20" style="padding: 0; margin: 0;">
                           <circle cx="10" cy="10" r="5"  fill="red"  style="padding: 0; margin: 0;"/>
                          </svg></td>

                          <td>{{$loop->iteration}}</td>
                          <td>
                           {{$rows['employee_name']}}
                           
                          </td>
                          <td>{{$rows['priority']}}</td>                        
                          
                          <td>{{$rows['status']}}</td>


                          <td>{{EF::dateFormat($rows['created_at'])}}</td>

                          <td class="text-center" >
                                  <input type="hidden" id="complaintId" value="{{Crypt::encrypt($rows['id'])}}">
                                  <div class="item-action dropdown" >
                                    <a href="javascript:void(0)" data-toggle="dropdown" class="icon" onclick="checkChat(this,'{{++$count}}');" id="{{Crypt::encrypt($rows['id'])}}"><i class="fa fa-list-ul"></i></a>
                                    <div class="dropdown-menu dropdown-menu-right">
                                       <a href="javascript:void(0)" class="dropdown-item" ><i class="dropdown-icon fa fa-cogs"></i> Action</a>
                                      <div class="dropdown-divider"></div>
                                       <a href="{{route('support.chat',['id' => Crypt::encrypt($rows['id'])])}}" class="dropdown-item "><i class="dropdown-icon fa fa-comments"></i> Chat</a>

                                       <div class="checkchat" id="{{$count}}">
                                       @if($rows['status'] == "Unresolve")
                                      <a onclick="update(event,'{{json_encode($pass_data)}}','form_update_support','md_update_support')" href="javascript:void(0)" class="  dropdown-item" data-toggle="modal" data-target="#md_update_support"><i class="dropdown-icon fa fa-edit"></i> Update Complaint </a>
                                      @endif
                                     
                                      @if($rows['status'] != "Resolve")
                                      <a href="{{route('support.delete',['id' => Crypt::encrypt($rows['id'])])}}" class="  dropdown-item cls_delete" content="remove complaint"><i class="dropdown-icon fa fa-trash"></i> Remove Complaint</a>
                                     @endif
                                     
                                     </div>
                                    </div>
                                  </div>
                               </td>
                        </tr>
                            @endif
                      	    @endforeach
                            @endif

                            @endif
                        
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
          </div>
@endsection

@section('page_modal')

  @include('support.modals.add_support')
  @include('support.modals.update_support')

@endsection

@section('page_script')
 @include('scripts.chat')
	
@endsection

  