@extends('adminlte::page')
@section('content_header')
    <h1> {{request()->session()->get('session_tname')}} View</h1>
@stop
@notifyCss
 @notifyJs
<script src="//code.jquery.com/jquery.js"></script>

<!--for search in combo box auto complete  -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.1/css/bootstrap-select.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.1/js/bootstrap-select.js"></script>
<!---  -->
@section('content')
    
  @if (session('status'))
    <div class="alert alert-success">
       {{ session('status') }}
    </div>
  @endif
            
  @if (session('status1'))
    <div class="alert alert-danger">
      {{ session('status1') }}
    </div>
  @endif          

  @if(($act_flg_status==1) && (!isset($tapalattachedtofile_arr)))
    <button class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#AddModal" {{ $user_comment_flag==0 ? 'disabled=true' : '' }}>Forward</button>
    <br>
    <?php
       if($user_comment_flag==0)
          {
      ?>
        <span class="text-danger pull-right"> * Forward button will be enabled, if alteast one note is entered by the current seat.</span>
        <?php } ?>
        @endif

</br>
</br>
 @include('notify::messages')

  <div class="row">
            <!--row starts-->

            <div class="col-md-12">
               
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                         
                           {{$creation_of_tapal->tapal_no}} &nbsp&nbspCurrent Owner:{{$currentseatotapal}},{{$currentuseroftapal}}&nbsp&nbsp&nbsp&nbsp{{ $creation_of_tapal->confidential == 1 ? 'Confidential' : '' }}
                          @if(isset($tapalattachedtofile_arr))
                            &nbspattached to <b>{{$tapalattachedtofile_arr->file->file_no}}</b>
                        @endif
                        </h3>
                    </div>

                <div class="panel-body">
                      

                            <!-- CSRF Token -->
                             <input type="hidden" name="_token" value="{{csrf_token()}}">

                             <!--Office ID Hidden value-->
                            
                            <input type="hidden" name="tapal_id" value="{{$creation_of_tapal->id}}">
                             

                                <!-- Message body -->
                                <div class="form-group">

                                <!-- <div class="col-md-6">
                                <label >Tapal Number</label>

                                &nbsp {{$creation_of_tapal->tapal_no}}
                                </div>-->
                                <div class="col-md-6">
                                <label >{{request()->session()->get('session_tname')}} Title</label>

                                &nbsp {{$creation_of_tapal->title}}
                                </div>
                                <div class="col-md-6">
                                <label >Description</label>

                                &nbsp {{$creation_of_tapal->tapal_description}}
                                </div>
                                </div>




                                @php
                                $received_from = $creation_of_tapal->received_from;
                                $received_date = $creation_of_tapal->received_date;
                                if($received_date!='')
                                {
                                    $received_date = date('d-m-Y', strtotime($received_date));
                                }
                                if($received_from!='')
                                {
                                @endphp
                                <!-- Message body -->
                                <div class="form-group">

                                <div class="col-md-6">
                                <label >Received From</label>

                                &nbsp {{$creation_of_tapal->received_from}}
                                </div>
                                <div class="col-md-6">

                                <label>Received Date</label>

                                &nbsp {{$received_date}}
                                </div>
                                </div>
                                @php
                                }
                                @endphp
                                                    

                                <div class="form-group">
                                <div class="col-md-6">
                                <label>Mode of Receipt</label>
                                @if($creation_of_tapal->mode_of_receipt==0)
                                &nbsp NA

                                @endif
                                @if($creation_of_tapal->mode_of_receipt==1)
                                &nbsp Fax

                                @endif

                                @if($creation_of_tapal->mode_of_receipt==2)
                                &nbsp Email

                                @endif

                                @if($creation_of_tapal->mode_of_receipt==3)
                                &nbsp By hand

                                @endif

                                @if($creation_of_tapal->mode_of_receipt==4)
                                &nbsp Post    

                                @endif

                                </div>

                                <div class="col-md-6">

                                <label>Priority</label>
                                                     
                                &nbsp {{$priority->priority}}                             
                                </div>
                                </div>


                                <div class="form-group">

                                <div class="col-md-6">
                                <label>Subject Group</label>
                                                   
                                &nbsp {{$subject_group->subject_group}}

                                </div>
                                <div class="col-md-6">

                                <label>Subject</label>

                                &nbsp {{$subject->subject}}

                                </div>
                                </div>
                              

                                 @php
                                $keyword = $creation_of_tapal->keywords;
                                
                                if($keyword=='')
                                {
                                $key="NA";
                                }
                                else
                                {
                                  $key=$creation_of_tapal->keywords;
                                }
                                @endphp
                                <div class="form-group">

                                <div class="col-md-6">
                                <label>Keywords</label>

                                &nbsp {{$key}}
                                </div>


                                <div class="col-md-6">

                                <label>Attachments</label>

                                &nbsp {{$attachmentcount}}
                                </div>
                                </div>


                                <div class="form-group">
                                <div class="col-md-12">
                                <label>Valuables</label>

                                 @php
                                if($creation_of_tapal->valuable=="1")
                                {
                                $config_val="yes";
                                }

                                else
                                {
                                 $config_val="no";
                                } 
                                 echo $config_val;
                                @endphp
                                </div>
                                </div>

                                
                            <input type="hidden" name="_token" value="{{csrf_token()}}">

                             <!--ID Hidden value-->
                            
                              @foreach($values as $comment)

                              @if(($comment->comment_type == 1) && ($comment->seat_id == $seatid_new))


                              <div class="col-md-6">
               
                        <div class="panel panel-danger">
                               <div class="panel-heading" >
                                 {{$comment->seat->seat_name}} noted at {{$comment->created_at->format("d-m-Y H:i:s")}}
                               </div>

                        <div class="panel-body">
                                      
                                     

                                <!-- Message body -->
                                <div class="form-group">  
                                <div class="col-md-6">
                                    {{$comment->comment_description}}
                                </div>
                                </div>

            </div>

</div><!-- panel panel-primary end-->


</div> <!-- col12 end-->

@elseif($comment->comment_type == 0)

  <div class="col-md-6">
               
                <div class="panel panel-success">
                    <div class="panel-heading">
                           {{$comment->seat->seat_name}} noted at {{$comment->created_at->format("d-m-Y H:i:s")}}
                         </div>

                <div class="panel-body">
                   
                                <!-- Message body -->
                                <div class="form-group">

                                  
                              
                                <div class="col-md-6">
                                    
                                    {{$comment->comment_description}}
                                </div>
                                </div>
                
            </div>

</div><!-- panel panel-primary end-->


</div> <!-- col12 end-->

@elseif(($comment->comment_type == 2) && ($comment->disgard_flag==0))

  <div class="col-md-6">
               
                <div class="panel panel-warning">
                    <div class="panel-heading">
                           {{$comment->seat->seat_name}} noted at {{$comment->created_at->format("d-m-Y H:i:s")}} 
                           <form class="form-horizontal" action="{{ url('postit_comment') }}" method="post" enctype="multipart/form-data">
                             <!-- CSRF Token -->
                             <input type="hidden" name="_token" value="{{csrf_token()}}">

                            <input type="hidden" name="creation_of_tapal" id="creation_of_tapal" value="{{$creation_of_tapal->id}}">
                             <input type="hidden" name="comment_id" id="comment_id" value="{{$comment->id}}">
                             @if($act_flg_status==1)
                           <button type="submit" class="btn btn-default btn-xm">
                            <span class="glyphicon glyphicon-trash"></span> Trash 
                           </button>
                           @endif
                           </form>
                         </div>

                <div class="panel-body">
                   
                                <!-- Message body -->
                                <div class="form-group">

                                <div class="col-md-6">
                                    
                                    {{$comment->comment_description}}
                                </div>
                                </div>
                
            </div>

</div><!-- panel panel-primary end-->


</div>


@endif
 @endforeach
            @if(($act_flg_status==1) && (!isset($tapalattachedtofile_arr)))                  
           <div class="form-position">
              <div class="col-md-12 text-right">
              <button class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#Modal">Attach to New File</button>
              <button class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#Modal1">Attach to Existing File</button>                          
                                        
              </div>
          </div>
          @endif
<table  width="100%">
<tr><td width="90%" align="right">  
@if(($act_flg_status==0) && ($readflag==0))
<form class="form-horizontal" action="{{ url('move_to_inbox') }}" method="post" enctype="multipart/form-data" id="theform"">
                             <!-- CSRF Token -->
<input type="hidden" name="_token" value="{{csrf_token()}}">
<input type="hidden" name="creation_of_tapal" id="creation_of_tapal" value="{{$creation_of_tapal->id}}">
    <div class="form-position">
    <div class="col-md-12 text-right">
    <button type="submit" class="btn btn-responsive btn-info btn-sm">Move to Inbox</button>
    </div>
    </div>
</form>
@endif
</td>
<td width="10%">
 @if(($act_flg_status==0) && ($enablecapture==1) && ($creation_of_tapal->status==0))
<form class="form-horizontal" action="{{ url('capture1') }}" method="post" enctype="multipart/form-data" id="theform"">
                             <!-- CSRF Token -->
<input type="hidden" name="_token" value="{{csrf_token()}}">
<input type="hidden" name="creation_of_tapal" id="creation_of_tapal" value="{{$creation_of_tapal->id}}">
    <div class="form-position">
    <div class="col-md-12 text-right">
    <button type="submit" class="btn btn-responsive btn-success btn-sm">Capture this {{request()->session()->get('session_tname')}}</button>
    </div>
    </div>
</form>
@endif
</td>
</tr>
</table>

         </div>

</div><!-- panel panel-primary end-->


</div> <!-- col12 end-->

@if(($act_flg_status==1) && (!isset($tapalattachedtofile_arr)))

            <div class="col-md-12">
               
                  <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                           Enter Your Comments
                        </h3>
                   </div>

                      <div class="panel-body">
                            
                            <form class="form-horizontal" action="{{ url('tapalcapture_viewpost') }}" method="post" enctype="multipart/form-data" id="theform" onsubmit="return validation();">
                             <!-- CSRF Token -->
                             <input type="hidden" name="_token" value="{{csrf_token()}}">

                            <input type="hidden" name="creation_of_tapalcomment" id="creation_of_tapalcomment" value="{{$creation_of_tapal->id}}">

                               <div class="form-group">
                                    <label class="col-md-3 control-label" for="email">Comment Type<span style="color: red;">*</span></label>
                                    <div class="col-md-9">
                                      <select name="comment_type" id="comment_type" class="form-control">
                                      <option value="">Select One</option>
                                        <option value="0">Public</option>
                                        <option value="1">Private</option>
                                        <option value="2">Yellow Notes</option>  

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


                                 <div class="form-group">
                                    <label class="col-md-3 control-label" for="remarks">Comment Description<span style="color: red;">*</span></label>
                                    <div class="col-md-9">
                                        <textarea class="form-control resize_vertical" id="description" name="description" placeholder="Please enter description here..." rows="3"></textarea>
                                    </div>
                                </div>

                             
                                <!-- Form actions -->
                                <div class="form-position">
                                    <div class="col-md-12 text-right">
                                        <button type="submit" class="btn btn-responsive btn-primary btn-sm" id="btnsubmit" >Save</button>
                                    </div>
                                </div>
                                
                     </form>
                    </div>
                </div>
               

            </div>



            @endif
            <!--md-12 ends-->

            <!-- comment displaying in each box-->
          <script>
                function validation()
                    {
                        
                       if(document.getElementById('comment_type').value=="")
                        {
                            alert(" Please select the Comment type");
                            document.getElementById('comment_type').focus();
                            return false;
                        }

                        if(document.getElementById('description').value=="")
                        {
                            alert(" Please enter the Comment Description");
                            document.getElementById('description').focus();
                            return false;
                        }

                          document.getElementById("btnsubmit").disabled='true';
                          
                        
                    
                        return true;
                    }
          </script> 
@if(($act_flg_status==1) && (!isset($tapalattachedtofile_arr)))
            <!-- action box  -->

            <div class="col-md-12">
               
                  <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                           Actions
                        </h3>
                   </div>

                      <div class="panel-body">
                            
                            <form class="form-horizontal" action="{{ url('tapalcapture_actionpost') }}" method="post" enctype="multipart/form-data" id="form" onsubmit="return validation1();">
                             <!-- CSRF Token -->
                             <input type="hidden" name="_token" value="{{csrf_token()}}">

                            <input type="hidden" name="creation_of_action" id="creation_of_action" value="{{$creation_of_tapal->id}}">

                                <div class="form-group">
                                    <label class="col-md-3 control-label" for="email">Action type<span style="color: red;">*</span></label>
                                    <div class="col-md-9">
                                      <select name="action_type" id="action_type" class="form-control">
                                        <option value="0">Select One</option>
                                         @foreach ($actions as $action)
                                        <option value="{{$action->id}}">{{$action->actions}}</option>

                                       @endforeach
  

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


                                 <div class="form-group">
                                    <label class="col-md-3 control-label" for="remarks">Action Description<span style="color: red;">*</span></label>
                                    <div class="col-md-9">
                                        <textarea class="form-control resize_vertical" id="actdescription" name="actdescription" placeholder="Please enter description here..." rows="3"></textarea>
                                    </div>
                                </div>

                              
                                <!-- Form actions -->
                                <div class="form-position">
                                    <div class="col-md-12 text-right">
                                        <button type="submit" class="btn btn-responsive btn-primary btn-sm" id="submit" >Save</button>
                                    </div>
                                </div>
                                
                     </form>
                    </div>
                </div>
               

            </div>
@endif

          <script>
                function validation1()
                    {
                        
                        if(document.getElementById('actions').value=="0")
                        {
                            alert(" Please select the Action type");
                            document.getElementById('actions').focus();
                           
                            return false;
                        }

                        if(document.getElementById('actdescription').value=="")
                        {
                            alert(" Please enter the Action Description");
                            document.getElementById('actdescription').focus();
                            return false;
                        }

                        document.getElementById("submit").disabled='true';

                        
                    
                        return true;
                    }
          </script> 
<!-- Attachements -->
@if(($act_flg_status==1) && (!isset($tapalattachedtofile_arr)))
            <!-- attachment box  -->

            <div class="col-md-12">
               
                  <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                           Attachments
                        </h3>
                   </div>

                      <div class="panel-body">
                            
                            <form class="form-horizontal" action="{{ url('tapalcapture_attachmentpost') }}" method="post" enctype="multipart/form-data" id="form" >
                             <!-- CSRF Token -->
                             <input type="hidden" name="_token" value="{{csrf_token()}}">

                            <input type="hidden" name="creation_of_tapal" id="creation_of_tapal" value="{{$creation_of_tapal->id}}">

                                <div class="form-group">
                                    <label class="col-md-3 control-label" for="name">Attachments</label>
                                    <div class="col-md-9" id="uploaddiv">
                                        <input id="upload1" name="upload1" type="file" class="form-control" onchange="check_extension();" /><br><input type="text" name="filedesc1" id="filedesc1" placeholder="Enter description of file" class="form-control">
                                        <input type="hidden" name="uploadcount" id="uploadcount" value="1">

                                    </div>
                               </div>
                                <!-- Form actions -->
                                <div class="form-group">
                                    <div class="col-md-12 text-right">
                                        <button type="submit" class="btn btn-responsive btn-primary btn-sm" id="submit" >Save</button>
                                    </div>
                                </div>
                                
                     </form>
                    </div>
                </div>
               

            </div>
 @endif
  <script>
   //////check the extension of upload////////////////////////
    function check_extension()
    {
        var file= document.getElementById('upload1').value;
        var reg = /(.*?)\.(jpg|pdf|jpeg|excel|xls|xlsx|doc|docx|odt|word|png)$/;
        if(!file.match(reg))
        {
            alert("Invalid File format. Please upload correct format");
            document.getElementById('upload1').value='';
            document.getElementById('upload1').focus();
            return false;
        }
    }
            </script> 
<!--- end attachment -->
<!-- comment list -->                            

            <input type="hidden" name="_token" value="{{csrf_token()}}">

                             <!--ID Hidden value-->
                            
                              @foreach($values1 as $action)

                              
                               <div class="col-md-12">
               
                <div class="panel panel-info">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                           {{$action->seat->seat_name}}  created a {{$action->action->actions}} on {{$action->created_at->format("d-m-Y H:i:s")}}
                        </h3>
                    </div>

                <div class="panel-body">
                              
                             

                                <!-- Message body -->
                                <div class="form-group">

                                  
                              
                                <div class="col-md-6">
                                    <label></label>
                                    
                                       &nbsp {{$action->action_description}}
                                </div>
                                </div>    
            </div>

</div><!-- panel panel-primary end-->


</div> 

@endforeach
    </div><!--row end-->


@if($attachmentcount)
<div class="row">

 <div class="col-md-12">
               
                  <div class="panel panel-info">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                         Attachments
                        </h3>
                   </div>

                      <div class="panel-body">
                       @foreach($attachments as $attachment)

                        <div class="col-md-10">
                            <div onclick="showdocument('{{$attachment->document_path}}');">{{$userseatattachment->seat->seat_name}} created an attachment <span class="text-info">{{$attachment->document_name}}::View File</span> on {{$attachment->created_at->format("d-m-Y H:i:s")}} </div>
                        </div>

                        <div class="col-md-10" align="center">
                           <iframe src="" id="documentframe" width="700" height="400" style="display: none;"></iframe>
                        </div>

                       @endforeach     
                           
                    </div>
                </div>
               

            </div> 

</div>         

@endif

<script>
    function showdocument(path)
    {
        
        document.getElementById("documentframe").src="../../storage/app/"+path;
        document.getElementById("documentframe").style.display="block";
    }
</script>
   

<div class="modal fade" id="AddModal" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Forward Details</h4>
            </div>

        <div class="panel-body">

             <form action="{{ url('/tapal_forwardpost') }}" method="post" id="tapal_forward" onsubmit="return validateform();">

            <div class="modal-body">
                <div class="box-body">
                     <input type="hidden" name="_token" value="{{ csrf_token() }}">

                            <input type="hidden" name="creation_of_tapal_id" value="{{$creation_of_tapal->id}}">

                                <div class="form-group">
                                <label class="col-md-3 control-label" for="email">Office Name<span style="color: red;">*</span></label>
                                <div class="col-md-9">
                                <select name="officename" id="officename" class="form-control">
                                <option value="0">Select One</option>
                                @foreach ($office as $officename)
                                <option value="{{$officename->id}}">{{$officename->office_name}}</option>
                                @endforeach
                                </select>
                                </div>
                                </div>


                                <div class="form-group">
                                <label class="col-md-3 control-label" for="email">Department<span style="color: red;">*</span></label>
                                <div class="col-md-9">
                                <select name="deptname" id="deptname" class="form-control">
                                <option value="0">Select One</option>
                                </select>
                                </div>
                                </div>

                                <!--section name-->

                                <div class="form-group">
                                <label class="col-md-3 control-label" for="email">Section</label>
                                <div class="col-md-9">
                                <select name="secname" id="secname" class="form-control">
                                <option value="0">Select One</option>
                                </select>
                                </div>
                                </div>

                                <div class="form-group">
                                <div class="col-md-9" id="seatdiv" style="display: none;">
                                <table id="seattable" width="100%" border="1" cellpadding="0" cellspacing="0" align="center"><thead><td>&nbsp;</td><td>Seat</td></thead></table>
                                </div>
                                </div>

                                
                                <div class="form-group">  
                                <label class="col-md-3 control-label" for="name">Type of comments:</label>                          
                                <div class="sub1 col-md-9">
                                <div class="checkbox">
                                <label> <input type="checkbox" name="public" id="public"  value="1">Public</label> <!-- function to hide radio buttons(toggleupload) -->
                                </div>
                                <div class="checkbox">
                                <label> <input type="checkbox" name="yellownote" id="yellownote"  value="1" >Yellow notes</label>
                                </div>
                                </div>
                                </div>


                               
                                 

                 <!--box body close-->               
                </div>
             
                <!--modal body close-->
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-success" id="for">Forward</button>
                
            </div>
            </form>
            <!--panel body close-->
            </div>
        </div>
    </div>
</div>

            <script>
                function validateform()
                    {
                        
                        if(document.getElementById('officename').value=="0")
                        {
                            alert(" Please select the Office");
                            document.getElementById('officename').focus();
                            return false;
                        }

                        document.getElementById("for").disabled='true';

                        
                        return true;
                    }
            </script> 
                       

<script>

         $(document).ready(function($){

          $('#officename').change(function(){
      
        $.get("{{ url('getseatfromoffice')}}",
        { option: $(this).val() },
        function(data) {
             var cnt = data.length;
            $("#seattable tr").remove(); 
          for(i=0;i<cnt;i++)
              {
                document.getElementById("seatdiv").style.display="block";

                var table = document.getElementById("seattable");

                var tr = document.createElement("tr");
                var td = document.createElement("td");
                var txt = document.createElement("input");
                txt.type='checkbox';
                txt.name=data[i]['id'];
                txt.value=1;

                td.appendChild(txt);
                tr.appendChild(td);

                var td = document.createElement("td");
                var txt = document.createTextNode("Seat: "+data[i]['name']);

                td.appendChild(txt);
                tr.appendChild(td);

                table.appendChild(tr);
            
            }
          });

            //section loading
             $.get("{{ url('getofficedept')}}",
            { option: $(this).val() },
            function(data) {
            $('#deptname').empty();
            $('#deptname').append("<option value='0'>Select a Department</option>");
            $.each(data, function(key, element) {
                $('#deptname').append("<option value='" + key +"'>" + element + "</option>");
            });
          });
        
    });

          ///////////////////

    $('#deptname').change(function(){
      
        $.get("{{ url('getseatfromdept')}}",
        { option: $(this).val() },
        function(data) {
            var cnt = data.length;
             $("#seattable tr").remove(); 
            for(i=0;i<cnt;i++)
            {
             
                  document.getElementById("seatdiv").style.display="block";

                  var table = document.getElementById("seattable");

                  var tr = document.createElement("tr");
                  var td = document.createElement("td");
                  var txt = document.createElement("input");
                  txt.type='checkbox';
                  txt.name=data[i]['id'];
                  txt.value=1;

                  td.appendChild(txt);
                  tr.appendChild(td);

                  var td = document.createElement("td");
                  var txt = document.createTextNode("Seat: "+data[i]['name']);

                  td.appendChild(txt);
                  tr.appendChild(td);

                  table.appendChild(tr);
              
              
            }
          });

            //section loading
             $.get("{{ url('getsectiondept')}}",
            { option: $(this).val() },
            function(data) {
            $('#secname').empty();
            $('#secname').append("<option value='0'>Select a Section</option>");
            $.each(data, function(key, element) {
                $('#secname').append("<option value='" + key +"'>" + element + "</option>");
            });
          });
        
    });



        $('#secname').change(function(){
      
        $.get("{{ url('getseat1')}}",
        { option: $(this).val() },
        function(data) {
                 var cnt = data.length;
                $("#seattable tr").remove(); 
                for(i=0;i<cnt;i++)
             {
                document.getElementById("seatdiv").style.display="block";

                var table = document.getElementById("seattable");

                var tr = document.createElement("tr");
                var td = document.createElement("td");
                var txt = document.createElement("input");
                txt.type='checkbox';
                txt.name=data[i]['id'];
                txt.value=1;

                td.appendChild(txt);
                tr.appendChild(td);

                var td = document.createElement("td");
                var txt = document.createTextNode("Seat: "+data[i]['name']);

                td.appendChild(txt);
                tr.appendChild(td);

                table.appendChild(tr);
           }
           
        });
    });


$('#seatname').change(function(){
  document.getElementById("seattable").innerHTML='';
      
        $.get("{{ url('getseattable')}}",
        { option: $(this).val() },
        function(data) {
          //alert(data);
              
            
            document.getElementById("seattable").innerHTML=data;
        });
    });

});

</script>




<div class="modal fade" id="Modal" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Attach to New File</h4>
            </div>
            <div class="panel-body">
              <form action="{{ url('/file_createpost') }}" method="post" id="newfile" onsubmit="return validatefile();">
                <div class="modal-body">
                  <div class="box-body">
                    
                      <input type="hidden" name="_token" value="{{ csrf_token() }}">
                      <input type="hidden" name="tapal_id" value="{{$creation_of_tapal->id}}">
                      <div class="form-group">
                      <label class="col-md-3 control-label" for="name">File Number</label>
                      <div class="col-md-9">{{$fileprint}}
                      <input id="fileno" name="fileno" type="hidden" class="form-control" value="{{$fileprint}}"></div>
                      </div>
                 </div>

                      <div class="form-group">
                      <label class="col-md-3 control-label" for="name">File Title<span style="color: red;">*</span></label>
                      <div class="col-md-9">
                      <input id="title" name="title" type="text" class="form-control" ></div>
                      </div>
                 
                      <div class="form-group">
                      <label class="col-md-3 control-label" for="remarks">Description<span style="color: red;">*</span></label>
                      <div class="col-md-9">
                      <textarea class="form-control resize_vertical" id="filedescription" name="filedescription" placeholder="Please enter description here..." rows="3"></textarea>
                      </div>
                      </div>

                      <div class="form-group">
                      <label class="col-md-3 control-label" for="addr">Reference<span style="color: red;">*</span></label>
                      <div class="col-md-9">
                      <input id="referencenumber" name="referencenumber" class="form-control">
                      </div>
                      </div>  

                      <div class="form-group">
                      <label class="col-md-3 control-label" for="email">Priority<span style="color: red;">*</span></label>
                      <div class="col-md-9">
                      <select name="priority" id="priority" class="form-control">
                      <option value="0">Select One</option>
                      @foreach ($priorityfile as $prioritys)
                      <option value="{{$prioritys->id}}">{{$prioritys->priority}}</option>
                      @endforeach
                      </select>
                      </div>
                      </div>

                      <div class="form-group">  
                      <label class="col-md-3 control-label" for="name">&nbsp;</label>                          
                      <div class="sub1 col-md-9">
                      <div class="checkbox">
                      <label> <input type="checkbox" name="confidential" id="confidential"  value="1">Confidential</label> <!-- function to hide radio buttons(toggleupload) -->
                      </div>
                      </div>
                      </div>


                      <div class="form-group">
                      <label class="col-md-3 control-label" for="email">File Group<span style="color: red;">*</span></label>
                      <div class="col-md-9">
                      <select name="file_group" id="file_group" class="form-control">
                      <option value="0">Select One</option>
                      @foreach ($file_groups as $file_grp)
                      <option value="{{$file_grp->id}}">{{$file_grp->file_group}}</option>
                      @endforeach
                      </select>
                      </div>
                      </div>

          </div>

                      <div class="form-group">
                      <div class="modal-footer">
                      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                      <button type="submit" class="btn btn-success" id="nwfile"  >Save</button>
                      </div>
                      </div>

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

<script>
function validatefile()
    {
        
        if(document.getElementById('title').value=="")
        {
            alert(" Please enter the File Title");
            document.getElementById('title').focus();
           
            return false;
        }

        if(document.getElementById('filedescription').value=="")
        {
            alert(" Please enter the File Description");
            document.getElementById('filedescription').focus();
            return false;
        }

        if(document.getElementById('referencenumber').value=="")
        {
            alert(" Please enter the Reference number");
            document.getElementById('referencenumber').focus();
            return false;
        }

        if(document.getElementById('priority').value=="0")
        {
            alert(" Please select the priority");
            document.getElementById('priority').focus();
            return false;
        }

        if(document.getElementById('file_group').value=="0")
        {
            alert(" Please select the File group");
            document.getElementById('file_group').focus();
            return false;
        }

        document.getElementById("nwfile").disabled='true';

      
        return true;
    }
</script> 



<div class="modal fade" id="Modal1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Attach to Existing File</h4>
            </div>

        <div class="panel-body">

             <form action="{{ url('/file_existpost') }}" method="post" id="existfile" onsubmit="return validatefile1();">

            <div class="modal-body">
                <div class="box-body">
                     <input type="hidden" name="_token" value="{{ csrf_token() }}">

                            <input type="hidden" name="tapal_id" value="{{$creation_of_tapal->id}}">

                               <div class="form-group">
                                    <label class="col-md-3 control-label" for="email">File Group<span style="color: red;">*</span></label>
                                    <div class="col-md-9">
                                     <select name="filegroup" id="filegroup" class="form-control">
                                        <option value="0">Select One</option>
                                       @foreach ($file_groups as $filegrp)
                                        <option value="{{$filegrp->id}}">{{$filegrp->file_group}}</option>

                                       @endforeach

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

                                  <div class="form-group">
                                    <label class="col-md-3 control-label" for="email">File<span style="color: red;">*</span></label>
                                    <div class="col-md-9">
                                     <select name="fileinhand" id="fileinhand" class="form-control selectpicker" data-live-search="true">
                                        <option value="0">Select One</option>
                                       

                                      </select>
                                      </div>
                                </div>
                                    
                                <!-- Message body -->
                               
                                  
                                </div>

                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-success" id="exfile" onclick=" " >Save</button>
                
            </div>
            </form>
            </div>
        </div>
    </div>
</div>

<script>
function validatefile1()
    {
        
        
       

        if(document.getElementById('filegroup').value=="0")
        {
            alert(" Please select the File group");
            document.getElementById('filegroup').focus();
            return false;
        }
        if(document.getElementById('fileinhand').value=="0")
        {
            alert(" Please enter the File");
            document.getElementById('fileinhand').focus();
           
            return false;
        }

        document.getElementById("exfile").disabled='true';

      
    
        return true;
    }
</script> 
                         
                       

<script>

$(document).ready(function($){
   
$('#filegroup').change(function(){
        $.get("{{ url('getfile')}}",
        { option: $(this).val() },
        function(data) {
           
            $('#fileinhand').empty();
            $('#fileinhand').append("<option value='0'>Select a file</option>");
            $.each(data, function(key,element) {
                $('#fileinhand').append("<option value='" + element.file.id +"'>" + element.file.file_no + "--"+ element.file.title+ "</option>");
            });

             $('#fileinhand').selectpicker('refresh');

            });


        });

        });





////////autocomplete/////////////////////////
/* $('#filegroup').autocomplete({
      source : '{{ url('getfile')}}',
      minlenght:1,
      autoFocus:true,
      select:function(e,ui){
        alert(ui);
      }
    });*/
</script>


@stop
