<?php $__env->startSection('content'); ?>

<?php
$searchValue = isset($_GET['searchValue'])?$_GET['searchValue']:'';
$searchBy = isset($_GET['searchBy'])?$_GET['searchBy']:'';
$order_by = isset($_GET['order_by'])?$_GET['order_by']:'';
$order = isset($_GET['order'])?$_GET['order']:'';
$redirect = url('/').'/admin/cvs_assign?'.urlencode($_SERVER["QUERY_STRING"]);


?>
<!-- page content -->
<div class="right_col" role="main">
  <div class="row x_panel">
      <?php if(Session::has('message')): ?>
          <div class="alert alert-success">
              <button type="button" class="close" data-close="alert"></button>
               <?php echo e(Session::get('message')); ?>

          </div>
    <?php endif; ?>
    <!-- <div class="pull-right">
      <a href="<?php echo $links['csvlink']; ?>" class="btn btn-success">CSV</a>
      <a href="<?php echo $links['pdflink']; ?>" class="btn btn-success">PDF</a>
    </div>
    <div class="pull-left">
      <a href="<?php echo url('/'); ?>/admin/cvs_assign/add" class="btn btn-success">Add Cv's Assign</a>
    </div> -->
    <h1>Candidates
      <div id="ass" style="display: none;"> 
        <a onclick="addValues('<?php echo e($com_id); ?>','<?php echo e($job_id); ?>')" class="btn btn-success">Assign CV</a>
      </div>
      <div class="pull-right"> 
        <a href="<?php echo url('/'); ?>/admin/cvs_assign/<?php echo e($com_id); ?>/<?php echo e($job_id); ?>" class="btn btn-success">Refresh</a>
      </div>
    </h1> 
    <hr>

    <form method="GET" action="" class="form-inline ibox-content">
        <div class="form-group">
          <select name="searchBy" class="form-control">
           <option value="candidates.can_name" <?php echo $searchBy=="candidates.can_name"?'selected="selected"':""; ?>>Name</option>
           <option value="candidates.can_email" <?php echo $searchBy=="candidates.can_email"?'selected="selected"':""; ?>>Email</option>
           <option value="candidates.can_mobile" <?php echo $searchBy=="candidates.can_mobile"?'selected="selected"':""; ?>>Mobile</option>
           <option value="functional_areas.fun_functional_area" <?php echo $searchBy=="functional_areas.fun_functional_area"?'selected="selected"':""; ?>>Functional Area</option>
           <option value="skills.skills" <?php echo $searchBy=="skills.skills"?'selected="selected"':""; ?>>Skills</option>
           <option value="c1.name" <?php echo $searchBy=="c1.name"?'selected="selected"':""; ?>>Current Location</option>
           <option value="states.name" <?php echo $searchBy=="states.name"?'selected="selected"':""; ?>>State</option>
           <option value="c2.name" <?php echo $searchBy=="c2.name"?'selected="selected"':""; ?>>City</option>
          </select>
        </div>
        <div class="form-group">
          <input type="text" name="searchValue" id="searchValue" class="form-control" value="<?php echo $searchValue; ?>">
        </div>
        <input type="submit" name="search" value="Search" class="btn btn-info">
        <div class="form-group pull-right">
          <select name="per_page" class="form-control" onchange="this.form.submit()">
            <option value="5" <?php echo $per_page=="5"?'selected="selected"':""; ?>>5</option>
            <option value="10" <?php echo $per_page=="10"?'selected="selected"':""; ?>>10</option>
            <option value="20" <?php echo $per_page=="20"?'selected="selected"':""; ?>>20</option>
            <option value="50" <?php echo $per_page=="50"?'selected="selected"':""; ?>>50</option>
            <option value="100" <?php echo $per_page=="100"?'selected="selected"':""; ?>>100</option>
          </select>
        </div>
      </form>
      <hr>

    <div class="col-md-12 col-sm-12 col-xs-12">
    
    <div class="table-responsive">
      <table class="table table-striped table-bordered table-hover Tax" >
      <thead>
      <th><input onclick="assignData(this)" id="foo[]" name="foo[]" type="checkbox" value="" /></th>
       <th> Sr No. </th>
          <?php $sortSym=isset($_GET["order"]) && $_GET["order"]=="asc" ? "up" : "down"; ?>
            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="candidates.can_name"?"<i class='fa fa-sort-$sortSym' aria-hidden='true'></i>": "<i class='fa fa-sort' aria-hidden='true'></i>"; ?>

            <th> 
            <a href="<?php echo $links["candidates.can_name_link"]; ?>" class="link_css"> Name <?php echo $symbol ?></a>
            </th>
				
				
            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="candidates.can_email"?"<i class='fa fa-sort-$sortSym' aria-hidden='true'></i>": "<i class='fa fa-sort' aria-hidden='true'></i>"; ?>

            <th> 
            <a href="<?php echo $links["candidates.can_email_link"]; ?>" class="link_css"> Email <?php echo $symbol ?></a>
            </th>

            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="candidates.can_mobile"?"<i class='fa fa-sort-$sortSym' aria-hidden='true'></i>": "<i class='fa fa-sort' aria-hidden='true'></i>"; ?>

            <th> 
            <a href="<?php echo $links["candidates.can_mobile_link"]; ?>" class="link_css"> Mobile <?php echo $symbol ?></a>
            </th>

            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="can_desired_career.cdc_functional_area"?"<i class='fa fa-sort-$sortSym' aria-hidden='true'></i>": "<i class='fa fa-sort' aria-hidden='true'></i>"; ?>

            <th> 
            <a href="<?php echo $links["can_desired_career.cdc_functional_area_link"]; ?>" class="link_css"> Functional Area <?php echo $symbol ?></a>
            </th>

            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="candidates.can_key_skills"?"<i class='fa fa-sort-$sortSym' aria-hidden='true'></i>": "<i class='fa fa-sort' aria-hidden='true'></i>"; ?>

            <th> 
            <a href="<?php echo $links["candidates.can_key_skills_link"]; ?>" class="link_css"> Skills <?php echo $symbol ?></a>
            </th>


            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="candidates.can_current_location"?"<i class='fa fa-sort-$sortSym' aria-hidden='true'></i>": "<i class='fa fa-sort' aria-hidden='true'></i>"; ?>

            <th> 
            <a href="<?php echo $links["candidates.can_current_location_link"]; ?>" class="link_css"> Current Location <?php echo $symbol ?></a>
            </th>

            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="candidates.can_state"?"<i class='fa fa-sort-$sortSym' aria-hidden='true'></i>": "<i class='fa fa-sort' aria-hidden='true'></i>"; ?>

            <th> 
            <a href="<?php echo $links["candidates.can_state_link"]; ?>" class="link_css"> State <?php echo $symbol ?></a>
            </th>

            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="candidates.can_city"?"<i class='fa fa-sort-$sortSym' aria-hidden='true'></i>": "<i class='fa fa-sort' aria-hidden='true'></i>"; ?>

            <th> 
            <a href="<?php echo $links["candidates.can_city_link"]; ?>" class="link_css"> City <?php echo $symbol ?></a>
            </th>  
			
      </thead>
      <tbody>
      <?php $count=1;
            $img_path=url('/').'/uploads/';
          foreach($data as $value){ if(!in_array($value->can_id, $job)){
           ?>          
          <tr id="hide<?php $value->can_id; ?>" >            
            <th>
              <input name='input' id='del' onclick="assignMe(this)"  type='checkbox' class='del' value='<?php echo $value->can_id; ?>'/>
            </th>
            <th>
              <?php echo $count; $count++; ?>
            </th>
            <th>
              <?php if(!empty($value->can_name)){ echo $value->can_name; }?>
            </th>
                                                
            <th>
              <?php if(!empty($value->can_email)){ echo $value->can_email; }?>
            </th>

            <th>
              <?php if(!empty($value->can_mobile)){ echo $value->can_mobile; }?>
            </th>

            <th>
              <?php echo e($value->functional_area); ?>

            </th>

            <th>
              <?php echo e($value->skills); ?>

            </th>

            <th>
              <?php echo e($value->name); ?>

            </th>

            <th>
              <?php echo e($value->state); ?>

            </th>

            <th>
              <?php echo e($value->city); ?>

            </th>
                        
          </tr>
          <?php }}
            if($count<=1){
              echo '<tr><td colspan="100"><h3 align="center" class="text-danger">No Record found!</center</td></tr>';
            } ?>
            </tbody>
            </table>
            <?php echo e($data->links('vendor.pagination.default')); ?>

            </div>

    </div>
  </div>
</div>
<img onclick="callme('','item','')" src="<?php echo url('/')?>/accets/img/mac-trashcan_full-new.png" id="recycle" style="width:90px;  display:none; position:fixed; bottom: 50px; right: 50px;"/>
<!-- /page content -->

<!-- Common Delete Popup  -->
<div class="modal fade" id="commonDelete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
 <form action="<?php echo url('/'); ?>/admin/cvs_assign/delete" method="post">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="frm_title">Delete</h4>
      </div>
      <div class="modal-body" id="frm_body">
       Do you really want to delete?
        <input type="hidden" id="set_commondel_id" name="cv_id">
        <input type="hidden" name="redirect" value="<?php echo $redirect; ?>">
        <?php echo e(csrf_field()); ?>

      </div>
      <div class="modal-footer">
        <button style='margin-left:10px;' type="submit" class="btn btn-primary col-sm-2 pull-right" id="frm_submit">Yes</button>
        <button type="button" class="btn btn-danger col-sm-2 pull-right" data-dismiss="modal" id="frm_cancel">No</button>
      </div>
    </div>
  </div>
</form>
</div>
<!-- ./ Common Delete Popup /. -->

<script type="text/javascript">
  function delRow()
  {var confrm = confirm("Are you sure you want to delete?");
     if(confrm)
     {
       ids = values();
       $.ajax({
         type:"POST",
         url:'<?php echo url("/")."/admin/cvs_assign/deleteAll"; ?>',
         data:{
          allIds:ids,
          _token:"<?php echo e(csrf_token()); ?>",
         },
         success:function(res){
           location.reload();
           },
       });
     }
  }

  function assignData(source, mg) 
  {
    var getInputs = document.getElementsByTagName("input");
    for (var i = 0, max = getInputs.length; i < max; i++) 
    {
      if (getInputs[i].type === 'checkbox')
        if (source.checked == true)
        {
            getInputs[i].checked = true;
        } else
        {
            getInputs[i].checked = false;
        }
    }

    data = values().filter(Boolean);
    if(data.length>0)
      {
        $('#ass').css('display','inline');
      }else
      {
        $('#ass').css('display','none');
      }
    // console.log(data);
  }

  function values()
  {
      var val = $('input:checked').map(function () {return this.value; }).get(); return val;
  }

  function assignMe(strng, page, h_id)
  {
      data = values();    
      if(data.length>0)
      {
        $('#ass').css('display','inline');
      }else
      {
        $('#ass').css('display','none');
      }
      // console.log(data);
  }

  function addValues(com_id,job_id)
  {
     data = values().filter(Boolean);
     // console.log(data);return false;
     $.ajax({
      type:'post',
      url:'<?php echo e(url("/")); ?>/admin/assignCandidates',
      data:{'_token':'<?php echo e(csrf_token()); ?>','can_id':data,'job_id':job_id,'com_id':com_id},
      dataType:'json',
      success:function(res)
      {
        if(res==true)
        {
          alert('CV assign successfully');
          window.location.reload(true);
        }else
        {
          alert('Something went wrong!');
        }
      }
     });
  }
</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>