<?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/jobs/'.$rel_field.'/'.$rel_id.'?'.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/jobs/add/<?php echo $rel_field; ?>/<?php echo $rel_id; ?>" class="btn btn-success">Add Jobs</a>
    </div>
    <br>
    <hr>

    <form method="GET" action="" class="form-inline ibox-content">
        <div class="form-group">
          <select name="searchBy" class="form-control">
           <option value="jobs.job_company_name" <?php echo $searchBy=="jobs.job_company_name"?'selected="selected"':""; ?>>Company Name</option>
           <option value="jobs.job_title" <?php echo $searchBy=="jobs.job_title"?'selected="selected"':""; ?>>Title</option>
           <option value="jobs.job_status" <?php echo $searchBy=="jobs.job_status"?'selected="selected"':""; ?>>Status</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">
    <h1>Jobs</h1>
    <br>
    <div class="table-responsive">
      <table class="table table-striped table-bordered table-hover Tax" >
      <thead>
      <th><input onclick="toggle(this,'cbgroup1')" 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"]=="jobs.job_company_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["jobs.job_company_name_link"]; ?>" class="link_css"> Company Name <?php echo $symbol ?></a>
            </th>         
            
            <?php $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="jobs.job_title"?"<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["jobs.job_title_link"]; ?>" class="link_css"> Title <?php echo $symbol ?></a>
            </th>
            
            <?php
             $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="jobs.job_description"?"<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["jobs.job_description_link"]; ?>" class="link_css"> Job Description <?php echo $symbol ?></a>
            </th>
            
            <?php $symbol = isset($_GET["sortBy"]) && $_GET["sortBy"]=="jobs.job_status"?"<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["jobs.job_status_link"]; ?>" class="link_css"> Status <?php echo $symbol ?></a>
            </th>
            <?php if($rel_field!='job_company'): ?>
            <th>
              Candidates
            </th>
            <?php else: ?>
            <th>
              Assign CV's
            </th>
            <?php endif; ?>
          <th>Payment Details</th>  
          <th>Job Status</th>
          <th>Action</th>
      </thead>
      <tbody>
      <?php $count=1;
            $img_path=url('/').'/uploads/';
          foreach($data as $value){
           ?>
          <tr id="hide<?php $value->job_id; ?>" >
            
            <th>
            <input name='input' id='del' onclick="callme('show')"  type='checkbox' class='del' value='<?php echo $value->job_id; ?>'/>
            </th>
            <th>
            <?php echo $count; $count++; ?>
            </th>
                        
            <th>
            <?php echo e($value->job_company_name); ?>

            </th>

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

            </th>
                
            <th>
            <?php echo $value->job_description;?>
            </th>
                
            <th>
            <a href="<?php echo url("/")?>/admin/jobs/status/job_status/<?php echo $value->job_id; ?>">
            <?php if(!empty($value->job_status) and $value->job_status==1 )
            { echo "Active"; }else{ echo "Inactive";}?>
            </a>
            </th>
            <?php if($rel_field!='job_company'): ?>
            <th>
              <a href="<?php echo url("/"); ?>/admin/candidates/con_id/<?php echo $rel_id; ?>/<?php echo $value->job_id; ?>" title="Add">
                <span class="btn btn-info ">
                  Add Candidates
                </span>
              </a>
            </th>
            <?php else: ?>
            <th>
              <a href="<?php echo url("/"); ?>/admin/cvs_assign/<?php echo $rel_id; ?>/<?php echo $value->job_id; ?>" title="Add">
                <span class="btn btn-info ">
                  Add CV's
                </span>
              </a>
            </th>
            <?php endif; ?> 
           <th>
             <a href="javascript:;" onclick="openPaymentModel('<?php echo $value->job_id; ?>');">
               <span class="btn btn-info ">
                  Add Payment Details
                </span>
             </a>
           </th> 
           <th>
              <a title="Change Status" onclick="openStatusModel('<?php echo $value->job_id; ?>');">
                  <span class="btn btn-info " ><i class="fa fa-edit"></i></span>
              </a>
           </th>    
           <th>
           <!-- <a href="<?php echo url("/"); ?>/admin/jobs/view/<?php echo $value->job_id?>" title="View">
            <span class="btn btn-info " ><i class="fa fa-eye"></i></span>
           </a> -->
           <a href="<?php echo url("/"); ?>/admin/jobs/edit/<?php echo $value->job_id; ?>/<?php echo $rel_field; ?>/<?php echo $rel_id; ?>" title="Edit">
            <span class="btn btn-info " ><i class="fa fa-edit"></i></span>
           </a>
           <a  title="Delete" data-toggle="modal" data-target="#commonDelete" onclick="$('#set_commondel_id').val('<?php echo $value->job_id; ?>');">
           <span class="btn btn-info " ><i class="fa fa-trash-o "></i></span>
           </a>
    
            </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 -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <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="exampleModalLabel">Job Status</h4>
      </div>
      <div class="modal-body">    
        <form action="" method="post" id="statusForm">
          <input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
          <input type="hidden" id="set_status_id" name="job_id">
           <div class="form-horizontal">
             <label class="control-label col-sm-3">Status</label>
             <div class="col-sm-7">
               <select class="form-control" name="status" id="status">
                  <option value="0">Select</option>
                  <option value="1" >Open</option>
                  <option value="2" >Closed</option>
                </select>
                <span class="text-danger" id="statusErr"></span>
             </div>
           </div><br><br>
           <div class="form-horizontal">
             <label class="control-label col-sm-3">Comments</label>
             <div class="col-sm-7">
               <textarea class="form-control" name="job_status_comment" id="job_status_comment"><?php echo e(old('job_status_comment')); ?></textarea>
               <span class="text-danger" id="commentErr"></span>
             </div>
           </div>
        </form>    
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" onclick="saveStatus()">Save changes</button>
      </div>
    </div>
  </div>
</div>

<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <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="exampleModalLabel">Paymnet Details</h4>
      </div>
      <div class="modal-body">    
        <form action="" method="post" id="paymentForm">
          <input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
          <input type="hidden" id="set_job_id" name="job_id" value="}">
           <div class="form-horizontal">
             <label class="control-label col-sm-3">Start Date</label>
             <div class="col-sm-7">
               <input type="text" name="start_date" class="form-control date" id="start_date" value="<?php echo e(old('start_date')); ?>">
             </div>
           </div><br><br>
           <div class="form-horizontal">
             <label class="control-label col-sm-3">End Date</label>
             <div class="col-sm-7">
               <input type="text" class="form-control date" id="end_date" name="end_date" value="<?php echo e(old('end_date')); ?>">
             </div>
           </div><br><br>
           <div class="form-horizontal">
             <label class="control-label col-sm-3">Percentage (%)</label>
             <div class="col-sm-7">
               <input type="number" class="form-control" id="percent" name="percent" value="<?php echo e(old('percent')); ?>">
             </div>
           </div><br><br>
           <div class="form-horizontal">
             <label class="control-label col-sm-3">Payment Days</label>
             <div class="col-sm-7">
               <input type="number" class="form-control" id="payment_days" name="payment_days" value="<?php echo e(old('payment_days')); ?>">
             </div>
           </div><br><br>
           <div class="form-horizontal">
             <label class="control-label col-sm-3">Replacement Days</label>
             <div class="col-sm-7">
               <input type="number" class="form-control" id="replacement_days" name="replacement_days" value="<?php echo e(old('replacement_days')); ?>">
             </div>
           </div><br><br>
           <div class="form-horizontal">
             <label class="control-label col-sm-3">Consultant Share</label>
             <div class="col-sm-7">
               <input type="number" class="form-control" id="consultant_share" name="consultant_share" value="<?php echo e(old('consultant_share')); ?>">
             </div>
           </div>
        </form>    
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" onclick="savePayment()">Save changes</button>
      </div>
    </div>
  </div>
</div>
<!-- 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/jobs/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" name="rel_field" id="rel_field" value="<?php echo $rel_field; ?>">
    <input type="hidden" name="rel_id" id="rel_id" value="<?php echo $rel_id; ?>">
    <input type="hidden" id="set_commondel_id" name="job_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/jobs/deleteAll"; ?>',
         data:{
          allIds:ids,
          _token:"<?php echo e(csrf_token()); ?>",
         },
         success:function(res){
           location.reload();
           },
       });
     }
   }

   function saveStatus()
   {
     var status = $('#status').val();
     if(status=='')
     {
        $('#statusErr').fadeIn(500);
        $('#statusErr').text('Please Select Status.');
        setTimeout(function(){$('#statusErr').fadeOut(500);},3000);
        return false;
     }

     if($('#job_status_comment').val()=='')
     {
        $('#commentErr').fadeIn(500);
        $('#commentErr').text('Please Add Comment.');
        setTimeout(function(){$('#commentErr').fadeOut(500);},3000);
        return false;      
     }
     // $('#statusForm').submit();
     $.ajax({
      type:'post',
      url:"<?php echo e(url('/')); ?>/admin/activationStatus",
      data:$('#statusForm').serialize(),
      dataType:'json',
      success:function(res)
      {
        // console.log(res);
        if(res)
        {
          alert('Status Updated Successfully.');
          window.location.reload(true);
        }else
        {
          alert('Something went wrong!');
        }
      }
     });
   }

   function openStatusModel(id)
   {
     $.ajax({
       type:'get',
       url:'<?php echo e(url("/")); ?>/admin/getStatusdata/'+id,
       dataType:'json',
       success:function(res)
       {
        // console.log(res['job_activate_status']);
         if(res)
         {     
          $('#exampleModal').modal('show');     
          $('#status').val(res['job_activate_status']);
          $('#job_status_comment').val(res['job_status_comment']);
         }
       }
     });
   }

   function openPaymentModel(id)
   {
     $.ajax({
       type:'get',
       url:'<?php echo e(url("/")); ?>/admin/getPaymentData/'+id,
       dataType:'json',
       success:function(res)
       {
        console.log(res);
          $('#paymentModal').modal('show');
          $('#set_job_id').val(id);     
          $('#start_date').val(res.start_date);
          $('#end_date').val(res.end_date);
          $('#percent').val(res.percent);
          $('#payment_days').val(res.payment_days);
          $('#replacement_days').val(res.replacement_days);
          $('#consultant_share').val(res.consultant_share);
       }
     });
   }

   function savePayment()
   {
      $.ajax({
        type:'post',
        url:"<?php echo e(url('/')); ?>/admin/savePaymentDetails",
        data:$('#paymentForm').serialize(),
        dataType:'json',
        success:function(res)
        {
          console.log(res);
          if(res==true)
          {
            alert('Payment Details Updated Successfully');
            window.location.reload(true);
          }

        }
      });
   }
</script>

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

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