@extends('main')

@section('css')
<link href="{{ asset('/css/bootstrapValidator.min.css')}}" rel="stylesheet">
@endsection
@section('content')
<section class="main_content">
    <div class="container">
    <ol class="breadcrumb cust-breadcrumb">
              <li><a href="{{url('/')}}">Home</a></li>
               <li><a href="{{url('/search')}}">search</a></li>
              <li class="active">Share Request</li>
            </ol>
                <div class="row">
          <div class="col-md-12">
          @if (Session::get('error_msg'))
              <div class="alert alert-danger clearfix">
                 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                   <span aria-hidden="true">&times;</span>
                 </button>
                  {{Session::get('error_msg')}}
              </div>
          @endif
          @if (Session::get('succ_msg'))
              <div class="alert alert-success clearfix">
                 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                   <span aria-hidden="true">&times;</span>
                 </button>
                  {{Session::get('succ_msg')}}
              </div>
          @endif
          </div>
        </div>
      <div class="row talent_home">
        @include("left_menu")
        <div class="col-md-9 col-sm-9"> 
          <h1 class="heading mtop-0">Share Request</h1>
          <div class="clearfix"></div>
       
          <div class="row talent_data search_result search-result-right-br share-req-rt-br" id="search_result_data">
          <form name="shareLinkForm" id="shareLinkForm" method="post">
           <input type="hidden" name="_token" value="{{ csrf_token() }}">
           <input type="hidden" name="send_request" value="1">
          @if(count($share_request))
             <?php $i=1;?>
            @foreach($share_request as $pro)
           <?php if($i%2==0){?> <div class="row share_br_btm <?php if($i==count($share_request)){?> no-share-br-btm<?php }?>"><?php }?>
            <div class="col-md-6">
              <div <?php if(count($share_request)>1){
?>class="row share-req-row"<?php }?>>
                <div> 
                <div class="share-req-top-blk">
				<div class="col-sm-2 col-xs-1 col-md-1"><div class="search_input"><input type="checkbox" id="profileList" name="profileList[]" value="{{$pro->id}}" checked="checked"><label></label></div></div>
                 <div class="col-sm-10 col-xs-10 col-md-10"><h4>{{$pro->name}}</h4></div>
				</div>  
                <div class="share-req-images-blk">				
                  <div class="col-sm-6 col-xs-6 search-result-dp">

                     <a href="{{url('profiles/'.$pro->id)}}">
					         @if($pro->profile_image && is_file('uploads/profile_images/'.$pro->profile_image))
                      <img class="img-responsive" src="{{url('uploads/profile_images/'.$pro->profile_image)}}" alt=""/>
                    @else                    
                      <img class="img-responsive" src="{{url('uploads/profile_images/default-profile.png')}}" alt=""/>
                    @endif
                    </a>
                  </div>
                  <div class="col-sm-6 col-xs-6"><img class="img-responsive" src="../images/add_pic.png" alt=""/></div>
				  </div>
                  <div class="clearfix"></div>
                </div>
                
              </div>
            </div>
            <?php if($i%2==0){?>  </div><?php }?>
            <?php $i++;?>
            @endforeach
            <div class="clearfix"></div>
            <div class="form-group form-inline share-acces-label-form">
             <lable class="">Grant Access :</lable>
              
                <select class="form-control share-form-control share-acces-label-select" name="p_type" id="p_type">
                  <option value="P">Profile</option>
                  <option value="S">Specific Item</option>
                </select>
             
            </div>
            <div class="clearfix"></div>
            <div class="col-md-12">
           <div class="clearfix"></div>
       
                <div class="dash-damal mtop10 display-none specific-raido" id="specific_items_list">
                    <div class="col-md-4 col-sm-6 share-req-tab-r">
                          <div class="panel panel-primary panel-bg">
                            <div class="panel-heading">
                              <h3 class="panel-title">PICTURES</h3>
                            </div>
                            <div class="panel-body">
                                 <?php if(count($asst_pic)> 0) {
									 $k=1;
									  ?>
                              @foreach($asst_pic as $pic)
                             <div class="row <?php if(count($asst_pic)!=$k){?>s-r-s<?php }?> no-srs">
                                <div class="col-sm-8 col-xs-6 specific-in-block no-pad">
                                  <div class="col-xs-3"><div class="search_input"><input type="checkbox" value="{{$pic->id}}" name="permission[]"><label></label></div> </div>
                                  <div class="col-xs-9 no-pad"> {{ ucfirst(str_limit($pic->name, $limit = 15, $end = '.....')) }}</div>
                                </div>
                                  <div class="col-sm-4 col-xs-6 specific-grant-img upload-img no-pad"> 
                                      <a href="javascript:;" class="view_btn img-responsive" data-id="{{$pic->id}}" data-url="../images/{{$pic->path}}" title="View">  <img class="img-responsive" src="../images/{{$pic->path}}"  alt=""/></a>
                                  </div></div>
                                  <?php $k++;?>
                              @endforeach
                               <?php } else { echo "<div align='center'> No Images.. </div>"; } ?>
                            </div>
                          </div>
                        </div>  
                    <div class="col-md-4 col-sm-6 share-req-tab-r">  
                          <div class="panel panel-primary panel-bg">
                            <div class="panel-heading">
                              <h3 class="panel-title">VIDEOS</h3>
                            </div>
                            <div class="panel-body">
                                <?php if(count($asst_vid)> 0) { 
								$j=1;
								?>
                              @foreach($asst_vid as $video)
                              <div class="row <?php if(count($asst_vid)!=$j){?>s-r-s<?php }?> no-srs">
                                <div class="col-sm-8 col-xs-6 specific-in-block no-pad">
                                  <div class="col-xs-3 "><div class="search_input"><input type="checkbox" value="{{$video->id}}" name="permission[]" ><label></label></div></div>
                                  <div class="col-xs-9 no-pad">{{ ucfirst(str_limit($video->name, $limit = 15, $end = '.....')) }}</div>
                                </div>
                                  <div class="col-sm-4 col-xs-6 specific-grant-img upload-img no-pad"> 
                                  
                                   <?php 
                                      if($video->processed == '0')
                                      {
                                    ?>
                                    <img class="view_btn img-responsive upload-img no-pad" width="30px" height="30px" src="../uploads/processing.jpg" class="img-responsive " view-id="{{$video->id}}">
                                    <?php
                                      }else{
                                    ?>
                                    <img src="{{$video->thumb_img}}" iframe-src ="https://player.vimeo.com/video/{{$video->path}}" view-id="{{$video->id}}" class="img-responsive popup upload-img no-pad">
                    
                                    <!---->
                                    <?php 
                                      }
                                    ?>
                                </div></div>
                                <?php $j++; ?>
                              @endforeach
                                <?php } else { echo "<div align='center'> No Videos </div>"; } ?>
                            </div>
                          </div>    
                    </div>
					<div class="clearfix visible-sm"></div>
                     <div class="col-md-4 col-sm-6 share-req-tab-r">  
                          <div class="panel panel-primary panel-bg">
                            <div class="panel-heading">
                              <h3 class="panel-title">RESUMES</h3>
                            </div>
                            <div class="panel-body">
                                <?php if(count($asst_res)> 0) { 
								$i=1;
								?>
                                @foreach($asst_res as $resume)
                                <div class="row <?php if(count($asst_res)!=$i){?>s-r-s<?php }?> no-srs">
                                <div class="col-sm-8 col-xs-6 specific-in-block no-pad">
                                  <div class="col-xs-3"><div class="search_input"><input type="checkbox" value="{{$resume->id}}" name="permission[]" ><label></label></div></div>
                                  <div class="col-xs-9 no-pad">{{ ucfirst(str_limit(trim($resume->name), $limit = 15, $end = '.....')) }}</div>
                                </div>
                                  <div class="col-sm-4 col-xs-6 specific-grant-img upload-img no-pad">
								  <div class="remume-blk-br">
                                      {{--*/ $addfile='../images/text.png' /*--}}
                                       {{--*/ $viewName = @end( @explode( '.', $resume->path ) ) /*--}}
                                        @if($viewName=='txt')
                                        {{--*/ $addfile='../images/text.png' /*--}}
                                        @endif
                                        @if($viewName=='doc')
                                        {{--*/ $addfile='../images/doc.png' /*--}}
                                        @endif
                                        @if($viewName=='docx')
                                        {{--*/ $addfile='../images/docx.png' /*--}}
                                        @endif
                                        @if($viewName=='pdf')
                                        {{--*/ $addfile='../images/pdf.png' /*--}}
                                        @endif
                                         @if($viewName=='xls')
                                        {{--*/ $addfile='../images/xls.png' /*--}}
                                        @endif
                                         @if($viewName=='xlsx')
                                        {{--*/ $addfile='../images/xlsx.png' /*--}}
                                        @endif
                                         @if($viewName=='rtf')
                                        {{--*/ $addfile='../images/rtf.png' /*--}}
                                        @endif
                                      <a href="{{URL::to('res_download', array($resume->id))}}" >  <img   class="img-responsive resume-share-icon" src="{{$addfile}}"  alt=""/></a>
                                  </div></div>  </div> 
                                  <?php $i++;?>                             
                                  @endforeach
                                <?php } else { echo "<div align='center'> No Resumes... </div>"; } ?>
                                
                          </div>    
                    </div>
                </div>  
                
        <div class="clearfix"></div>

             
            </div>
            <div class="form-group col-md-12">
              <button type="button" class="btn btn-primary share-send-btn" name="send_link" id="send_link">Send Link</button>
            </div>
          @else
            <div class="col-md-6 txt-red">
              Required profiles not found
            </div>  
          @endif  
          </div>          
          </form>
      </div>
    </div>
  </section> 
<!-- Modal -->
<div class="modal fade" id="popup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
  <div class="modal-dialog">
    <div class="modal-content">
         <iframe src="" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen width="600" height="400" id="modal-iframe"></iframe>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="modal-close" >Close</button>
      </div>
    </div>
  </div>
</div>


<div id="view_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">View Picture</h4>
                    </div>
                    <div class="modal-body">
                      <div class="form-horizontal">
                          <div class="form-group">
                               <div class="col-sm-12 text-center"><img src="" class="img-elem img-responsive"></div>
                          </div>
                          <div class="form-group">
                              <div class="col-md-12">
                                  <button data-dismiss="modal" class="btn-close btn-primary pull-right clear_form" type="button">Close</button>
                              </div>
                          </div>
                      </div>          
                   </div><!-- End of Modal body -->
            </div><!-- End of Modal content -->
        </div><!-- End of Modal dialog -->
    </div><!-- End of Profile Image Modal --> 
    
    
@endsection
@section('js')
<script src="{{ asset('js/share_js.js')}}"></script>
<script src="{{ asset('js/bootstrapValidator.min.js')}}"></script>
<script src="{{ asset('js/maskedinput/jquery.maskedinput.min.js')}}"></script>
<script src="{{ asset('js/validation.js')}}"></script>
<script src="{{ asset('js/bootbox.js')}}"></script>
<script>
$( window ).load(function() {   

boxes = $('.col-sm-6');
maxHeight = Math.max.apply(
Math, boxes.map(function() {
return $(this).height();
}).get());
boxes.height(maxHeight);
$('.col-sm-12 .panel').height(maxHeight/2-22);//22 = 20 (bottom-margin) + 2 *1 (border)
});
</script>
<script type="text/javascript">
 $(document).ready(function(){
   /* $('.popup').click(function(){
       $('#modal-iframe').attr('src',$(this).attr('iframe-src'))
       $('#popup').modal('show');
    });*/
 
 $(document).on('click','.popup',function(){
      var atr_val=$(this).attr('view-id');
      var dataString = 'atr_val='+ atr_val +  '&_token=' + $("input[name=_token]").val();
       // alert(dataString);
                       $.ajax({
                              type: "POST",
                              url : "video_view",
                              data : dataString,
                              success : function(data){ }
                          },"json");
                          
                          $('#modal-iframe').attr('src',$(this).attr('iframe-src'))
                          $('#popup').modal('show'); 
                          
       
    });   
      $("#modal-close").click(function(){
        $('#modal-iframe').attr('src',"");
        $('#popup').modal('hide');
    })
    
    if($('.view_btn').length)
  {
    $(document).on('click','.view_btn',function(){
         var atr_val=$(this).attr('data-id');
        
      $('#view_modal').modal('show');
      $('#view_modal .img-elem').attr('src', $(this).attr('data-url'));
      $('#view_modal .assets_id_elem').val($(this).attr('data-id'));
        
         var dataString = 'atr_val='+ atr_val +  '&_token=' + $("input[name=_token]").val();
        
            $.ajax({
                              type: "POST",
                              url : "picture_view",
                              data : dataString,
                              success : function(data){//alert(data);
                              }
                          },"json");
                          
     
    });
  }
 });
 </script>
@endsection
<style>
    .dash-damal .col-sm-4 .panel.panel-primary {
    padding: 0;
}
.upload-img {
    width: 45px;
    height: 72px;
}
.no-pad{
    padding: 0px !important;
}
</style>