<?php $__env->startSection('content'); ?>
<!-- can_desired_career content -->
<div class="right_col" role="main">
  <div class="row x_panel">
    <div class="col-md-12 col-sm-12 col-xs-12">
    <h1>Function</h1>
<?php if(isset($data)){ ?>
<form action="<?php echo url('/'); ?>/admin/can_desired_career/edit" id="" class="form-horizontal " method="post" enctype="multipart/form-data">
<?php echo e(csrf_field()); ?>

<input type="hidden" name="can_cd_id" value="<?php echo $data->can_cd_id; ?>">


    <!-- industry Start -->
    <div class="form-group">
        <label for="user_id" class="control-label col-md-3"> Industry <span style="color: red">*</span></label>
          <div class="col-md-4" id="industryOther">
          <select id="cdc_industry" name="cdc_industry" class="form-control select2" >
            <option value="">Select</option>
            <?php
              foreach ($industries as $value) {
                $selected = $data->cdc_industry==$value->indu_id?'selected="selected"':'';
                echo '<option '.$selected.' value="'.$value->indu_id.'"> '.$value->indu_title.'</option>';
              }
            ?>
            <option value="0" <?php if($data->cdc_industry=='0'){echo 'selected';}?>>Other</option>
          </select><br><br>
          <input type="text" class="form-control" name="other_cdc_industry" id="otherInd" <?php if($data->cdc_industry_other==""): ?>style="display: none;" <?php else: ?> value="<?php echo e($data->cdc_industry_other); ?>" <?php endif; ?> >
          <meta charset="utf-8" name="m_industry" content="<?php echo e($data->cdc_industry_other); ?>">
        </div>
        <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("cdc_industry")); ?></div>
      </div>
    </div>
      <!-- industry End -->



    <!-- functional_area Start -->
    <div class="form-group">
        <label for="user_id" class="control-label col-md-3"> Functional Area <span style="color: red">*</span></label>
          <div class="col-md-4" id="functionalOther">
          <select id="cdc_functional_area" name="cdc_functional_area" class="form-control select2" onchange="getRoles(this.value)">
            <option value="">Select</option>
            <?php
              foreach ($functional_areas as $value) {
                $selected = $data->cdc_functional_area==$value->fun_id?'selected="selected"':'';
                echo '<option '.$selected.' value="'.$value->fun_id.'"> '.$value->fun_functional_area.'</option>';
              }
            ?>
            <option value="0" <?php if($data->cdc_functional_area=='0'){echo 'selected';}?>>Other</option>
          </select><br><br>
          <input type="text" class="form-control" name="other_cdc_functional_area" id="otherFun" <?php if($data->cdc_functional_area_other==""): ?>style="display: none;" <?php else: ?> value="<?php echo e($data->cdc_functional_area_other); ?>" <?php endif; ?> >
          <meta charset="utf-8" name="m_functional_area" content="<?php echo e($data->cdc_functional_area_other); ?>">
        </div>
        <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("cdc_functional_area")); ?></div>
      </div>
    </div>
      <!-- functional_area End -->

    <div class="form-group">
        <label for="user_id" class="control-label col-md-3"> Role <span style="color: red">*</span></label>
          <div class="col-md-4" id="roleOther">
          <select id="cdc_sub_functional_area" name="cdc_sub_functional_area" class="form-control select2">
            <option value="">Select</option>
            <?php /*
              foreach ($sub_functional_areas as $value) {
                $selected = $data->cdc_sub_functional_area==$value->sub_id?'selected="selected"':'';
                echo '<option '.$selected.' value="'.$value->sub_id.'"> '.$value->sub_functional_title.'</option>';
              } */
            ?>
            <option value="0" <?php if($data->cdc_sub_functional_area=='0'){echo 'selected';}?>>Other</option>
          </select><br><br>
          <input type="text" class="form-control" name="other_roles" id="otherRole" <?php if($data->cdc_sub_functional_area_other==""): ?>style="display: none;" <?php else: ?> value="<?php echo e($data->cdc_sub_functional_area_other); ?>" <?php endif; ?>>
          <meta charset="utf-8" name="m_sub_functional_area" content="<?php echo e($data->cdc_sub_functional_area_other); ?>">
          <meta charset="utf-8" name="m_roles" content="<?php echo e($data->cdc_sub_functional_area); ?>">
        </div>
        <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("cdc_sub_functional_area")); ?></div>
      </div>
    </div>

        <!-- job_type Start -->
        <div class="form-group">
        <label class="col-sm-3 control-label">Job Type</label>
        <div class="col-sm-4">
        <?php $arr=explode(",", $data->cdc_job_type) ?>
        
            <span style="margin-right:20px;"><input type="checkbox" style="width:20px; height:20px;" <?php echo in_array("1", $arr)?'checked="checked"':""; ?> name="cdc_job_type[]" value="1"> Permanent </span>
            <span style="margin-right:20px;"><input type="checkbox" style="width:20px; height:20px;" <?php echo in_array("2", $arr)?'checked="checked"':""; ?> name="cdc_job_type[]" value="2"> Contractual </span>
    </div>
    </div>
    <!-- job_type End -->

    

        <!-- employment_type Start -->
        <div class="form-group">
        <label class="col-sm-3 control-label">Employment Type</label>
        <div class="col-sm-4">
        <?php $arr=explode(",", $data->cdc_employment_type) ?>
        
            <span style="margin-right:20px;"><input type="checkbox" style="width:20px; height:20px;" <?php echo in_array("1", $arr)?'checked="checked"':""; ?> name="cdc_employment_type[]" value="1"> Full Time </span>
            <span style="margin-right:20px;"><input type="checkbox" style="width:20px; height:20px;" <?php echo in_array("2", $arr)?'checked="checked"':""; ?> name="cdc_employment_type[]" value="2"> Part Time </span>
    </div>
    </div>
    <!-- employment_type End -->

    

    <!-- preferred_shift Start -->
    <div class="form-group">
        <label class="col-sm-3 control-label">Preferred Shift</label>
        <div class="col-sm-4">
            <span style="margin-right:20px;"><input type="radio" style="width:20px; height:20px;" <?php echo $data->cdc_preferred_shift=="1"?'checked="checked"':""; ?> name="cdc_preferred_shift" value="1"> Day </span>
            <span style="margin-right:20px;"><input type="radio" style="width:20px; height:20px;" <?php echo $data->cdc_preferred_shift=="2"?'checked="checked"':""; ?> name="cdc_preferred_shift" value="2"> Night </span>
            <span style="margin-right:20px;"><input type="radio" style="width:20px; height:20px;" <?php echo $data->cdc_preferred_shift=="3"?'checked="checked"':""; ?> name="cdc_preferred_shift" value="3"> Flexible </span>
        </div>
    </div>
    <!-- preferred_shift End -->

    

<!-- available_to_join_year Start -->
<div class="form-group">
  <label for="cdc_available_to_join_year" class="col-sm-3 control-label"> Available To Join </label>
  <div class="col-sm-2">
    <input type="text" class="form-control year" id="cdc_available_to_join_year" name="cdc_available_to_join_year" value="<?php echo e($data->cdc_available_to_join_year); ?>" placeholder="Year">
  </div>
  <div class="col-sm-2">
    <input type="text" class="form-control month" id="cdc_available_to_join_month" name="cdc_available_to_join_month" value="<?php echo e($data->cdc_available_to_join_month); ?>" placeholder="Month">
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("cdc_available_to_join_year")); ?></div>
         <div class="label label-danger"><?php echo e($errors->first("cdc_available_to_join_month")); ?></div>
      </div>
</div> 
<!-- available_to_join_year End -->



    <!-- join_immediately Start -->
    <div class="form-group">
        <label class="col-sm-3 control-label">Join Immediately</label>
        <div class="col-sm-4">
        <?php $arr=explode(",", $data->cdc_join_immediately) ?>
        
            <span style="margin-right:20px;"><input type="checkbox" style="width:20px; height:20px;" <?php echo in_array("1", $arr)?'checked="checked"':""; ?> name="cdc_join_immediately" value="1"> Join Immediately </span>
        </div>
    </div>
    <!-- join_immediately End -->

    

    <!-- expected_salary_currency Start -->
    <div class="form-group">
        <label class="col-sm-3 control-label">Expected Salary In Currency</label>
        <div class="col-sm-4">
            <span style="margin-right:20px;"><input type="radio" style="width:20px; height:20px;" <?php echo $data->cdc_expected_salary_currency=="1"?'checked="checked"':""; ?> name="cdc_expected_salary_currency" value="1"> Indian Rupees </span>
            <span style="margin-right:20px;"><input type="radio" style="width:20px; height:20px;" <?php echo $data->cdc_expected_salary_currency=="2"?'checked="checked"':""; ?> name="cdc_expected_salary_currency" value="2"> Us Dollers </span>
        </div>
    </div>
    <!-- expected_salary_currency End -->

  <!--  <div class="form-group">
      <label for="cdc_current_salary_lac" class="col-sm-3 control-label"> Current Salary </label>
      <div class="col-sm-2">
        <input type="number" class="form-control" id="cdc_current_salary_lac" name="cdc_current_salary_lac" value="<?php echo e($data->cdc_current_salary_lac); ?>"  placeholder="In Lacs">
      </div>
      <div class="col-sm-2">
        <input type="number" class="form-control" id="cdc_current_salary_thousands" name="cdc_current_salary_thousands" value="<?php echo e($data->cdc_current_salary_thousands); ?>" placeholder="In Thousands">
      </div>
      <div class="col-sm-5">
             <div class="label label-danger"><?php echo e($errors->first("cdc_current_salary_lac")); ?></div>
             <div class="label label-danger"><?php echo e($errors->first("cdc_current_salary_thousands")); ?></div>
          </div>
    </div>  
 -->
<!-- expected_salary_lac Start -->
<div class="form-group">
  <label for="cdc_expected_salary_lac" class="col-sm-3 control-label"> Expected Salary </label>
  <div class="col-sm-2">
    <input type="number" class="form-control" id="cdc_expected_salary_lac" name="cdc_expected_salary_lac" value="<?php echo e($data->cdc_expected_salary_lac); ?>"  placeholder="In Lacs">
  </div>
  <div class="col-sm-2">
    <input type="number" class="form-control" id="cdc_expected_salary_thousands" name="cdc_expected_salary_thousands" value="<?php echo e($data->cdc_expected_salary_thousands); ?>" placeholder="In Thousands">
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("cdc_expected_salary_lac")); ?></div>
         <div class="label label-danger"><?php echo e($errors->first("cdc_expected_salary_thousands")); ?></div>
      </div>
</div> 
<!-- expected_salary_lac End -->


    <!-- desired_location Start -->
    <div class="form-group">
        <label for="user_id" class="control-label col-md-3"> Desired Location </label>
          <div class="col-md-4">
          <select id="cdc_desired_location" name="cdc_desired_location[]" class="form-control select2" multiple="multiple">
            <?php
            $dl=[];
              $dl=explode(',',$data->cdc_desired_location ?? '');
              // dd($dl);
              foreach ($cities as $value) {
                $selected = in_array($value->id, $dl) ?'selected="selected"':'';
                echo '<option '.$selected.' value="'.$value->id.'"> '.$value->name.'</option>';
              }
            ?>
          </select>
        </div>
        <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("cdc_desired_location")); ?></div>
      </div>
    </div>
      <!-- desired_location End -->



    <!-- status Start -->
     <div class="form-group">
        <label class="control-label col-md-3">status</label>                    
         <div class=" col-md-4 switch">
                    <div class="onoffswitch">
     <input type="checkbox" class="onoffswitch-checkbox"  data-on-label="Yes" data-off-label="No"  name="cdc_status" value="1" id="cdc_status" <?php if($data->cdc_status == 1){echo "checked=checked";}?> style="width:20px; height:20px;"/>
                    </div>
                </div>
      </div>
      <!-- status End -->


  <div class="form-group">
  <div class="col-sm-3">
  </div>
   <div class="col-sm-6">
    <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; ?>">
    <button type="reset" class="btn btn-default ">Reset</button>
    <button type="submit" class="btn btn-info ">Update</button>
   </div>
  </div>
</form>
<?php } else{
    echo '<h2 align="center" class="text-danger">No record found!</h2>';
  } ?>
    </div>
  </div>
</div>
<!-- /can_desired_career content -->
<script type="text/javascript">
  $(document).ready(function(){
    getRoles($('#cdc_functional_area').val());

    var selectedText = $('#cdc_industry').val();
    // console.log(selectedText);
    if(selectedText!=null && selectedText.includes('0'))
    {
      $('#otherInd').show();
    }else{
      $('#otherInd').hide();
    }
    $('input[name="other_cdc_industry"]').val($('meta[name="m_industry"]').attr('content'));    
    
  });

  function getRoles(id)
  {
    var selectedText = $('#cdc_functional_area').val();
    // console.log(selectedText);
    if(selectedText!=null && selectedText.includes('0'))
    {
      $('#otherFun').show();
    }else{
      $('#otherFun').hide();
    }
    $('input[name="other_cdc_functional_area"]').val($('meta[name="m_functional_area"]').attr('content'));

    $.ajax({
      type:"post",
      url:"<?php echo e(url('/')); ?>/admin/getRoles",
      data:{'_token':'<?php echo e(csrf_token()); ?>','fun_id':id},
      dataType:'json',
      success:function(res)
      {
        // console.log(res);
        var sub = '';
        sub += '<option value="">Select</option>';
        if(res.length>0)
        {
          for(var i=0;i<res.length;i++)
          {
            sub += '<option value='+res[i].sub_id+'>'+res[i].sub_functional_title+'</option>';
          }
        }
        sub += '<option value="0">Other</option>';
        $('#cdc_sub_functional_area').html(sub);
        $('#cdc_sub_functional_area').val($('meta[name="m_roles"]').attr('content')).trigger('change');
      }
    });
  }

  $('#cdc_industry').change(function(){
    var textbox = '';
    var selectedText = $(this).val();
    // console.log(selectedText);
    if(selectedText!=null && selectedText.includes('0'))
    {
      $('#otherInd').show();
    }else{
      $('#otherInd').hide();
    }
  });

  $('#cdc_sub_functional_area').change(function(){
    var textbox = '';
    var selectedText = $(this).val();
    // console.log(selectedText);
    if(selectedText!=null && selectedText.includes('0'))
    {
      $('#otherRole').show();
    }else{
      $('#otherRole').hide();
    }
    $('input[name="other_roles"]').val($('meta[name="m_sub_functional_area"]').attr('content'));
  });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>