
@extends('layouts.admin')
@section('pageTitle', 'Vega Soft')
@section('page-content')



<style>
#dynamic_ajax_table_length ,.dt-buttons ,#dynamic_ajax_table_filter{
    //float: left;
}
.custom-design-modal{
max-width:90%;
}
.dt-buttons{
    height: 34px;
}
#main-tabs{
    background-color: #eee;
    //display: none;
}
</style>
   <input type="hidden" id="table_settings_field" branch_id="" branch_name=""  column_heading="<?= $rows->column_heading;?>" column_width="<?= $rows->column_width;?>" column_alighn="<?= $rows->column_alighn;?>"  column_conversion="<?= $rows->column_conversion;?>" settings_row_id="<?= $id;?>" sp_date_picker="<?= $rows->sp_date_picker;?>"  header_from_date="<?=date('d-m-Y', strtotime('-7 days')); ?>"   header_till_date="<?=date('d-m-Y'); ?>"  sp_sort="<?= $rows->menu_id; ?>"  active_mn="<?= $rows->root;?>"  active_mnt="<?= $rows->menu_type;?>">
    @if ($rows->sedp != "")
  @foreach(explode(',', $rows->sedp) as  $z=>$info) 
     @if ($info == "1" && $z==1)
       <input type="hidden" class="additional_btns" btn_icon="fa fa-pencil" btn_text="Edit" btn_click_function="call_edit_modal" btn_class="btn btn-success btn-sm btn-dtbl" col_width="30" >
     @endif 
     @if ($info == "1" && $z==2)
        <input type="hidden" class="additional_btns" btn_icon="fa fa-trash-o " btn_text="Remove" btn_click_function="call_remove_modal" btn_class="btn btn-danger btn-sm btn-dtbl" col_width="40"  >
     @endif 
     @if ($info == "1" && $z==3)
          <input type="hidden" class="additional_btns" btn_icon="fa fa-print" btn_text="Print" btn_click_function="call_print_function2" btn_class="btn btn-info btn-sm btn-dtbl" col_width="40"  >
     @endif
  @endforeach
@endif
 <input type="hidden" class="additional_btns_td" btn_icon="fa fa-print" btn_text="Additional Details " btn_click_function="employee_view" btn_class="btn btn-warning  btn-sm btn-dtbl" col_width="40"  >

<div class="page-header">
<div class="row align-items-center">
<div class="col">
<h3 class="page-title"><?= $rows->menu_name;?></h3>
</div>
<div class="col-auto float-end ms-auto">
<a href="#" class="btn add-btn" data-bs-toggle="modal" data-bs-target="#add_employee"><i class="fa fa-plus"></i> Add Employee</a>

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


<div class="row filter-row">




</div>

<div class="row">
<div class="col-md-12">
<div class="table-responsive" id="table_result">
    
</div>
</div>
</div>
<input type="hidden" id="hidden_status" value="0">
<input type="hidden" id="row_id" value="0">




<div id="add_employee" class="modal custom-modal fade add_main_modal" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-lg custom-design-modal" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><?= $rows->menu_name;?></h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form>
    

<div class="card">
<div class="card-body" style="height:530px;">

<ul class="nav nav-tabs nav-tabs-solid nav-justified" id="main-tabs">
<li class="nav-item"><a class="nav-link active" href="#solid-justified-tab1" data-bs-toggle="tab">Personal Details</a></li>
<li class="nav-item"><a class="nav-link" id="tab2" href="#solid-justified-tab2" data-bs-toggle="tab">Additional Details</a></li>
<li class="nav-item"><a class="nav-link" id="tab3" href="#solid-justified-tab3" data-bs-toggle="tab">Payroll Details</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane show active" id="solid-justified-tab1">
    <div class="row" >
<div class="col-md-6">
<div class="form-group">
<label>Name</label>
<input type="text" class="form-control input_text" id="emp_name">
</div>
<div class="form-group">
<label>
Husband / Father's Name</label>
<input type="password" class="form-control input_text" id="guardian">
</div>
<div class="form-group">
<label class="d-block">Gender:</label>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" id="gender_male" value="1" checked>
<label class="form-check-label" for="gender_male">Male</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" id="gender_female" value="2">
<label class="form-check-label" for="gender_female">Female</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" id="gender_trans" value="3">
<label class="form-check-label" for="gender_trans">Transgender</label>
</div>
</div>
<div class="form-group">
<label>Address</label>
<textarea rows="4" cols="5" class="form-control input_text" id="addres"></textarea>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Country
</label>
<select id="country" class="form-control" onchange="get_state();"></select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>State</label>

<select id="state" class="form-control" onchange="get_district();"></select>
</div>
</div>
</div>

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

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Employee Code</label>
<input type="text" class="form-control input_text" id="emp_code">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Serial No</label>
<input type="text" class="form-control input_text" id="serial_no">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Machine Code
</label>
<input type="text" class="form-control input_text" id="mach_code">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Branch Name</label>
<select class="form-control" id="branch_id"> 
         <option value="0">Select Branch</option>
           @foreach($brn as  $z=>$det) 
           <option value="{{$det->BranchID}}">{{$det->BranchName}}</option>
           @endforeach
        </select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>BloodGroup
</label>
<select id="blood" name="blood" class="form-control"> 
         <option value="">Select</option>
         <option value="A+">A+</option>
         <option value="A-">A-</option>
         <option value="B+">B+</option>
         <option value="B-">B-</option>
         <option value="AB+">AB+</option>
         <option value="AB-">AB-</option>
         <option value="O+">O+</option>
         <option value="O-">O-</option>
        </select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Date Of Birth</label>
<input type="text" id="dob" class="form-control input_text mdate">

</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Religion</label>
<select id="religion" name="" class="form-control input_text"> 
           <option value="">Select</option>
         <option value="Hindu">Hindu</option>
         <option value="Muslim">Muslim</option>
         <option value="Christian">Christian</option>
         <option value="Sikh">Sikh</option>
         <option value="Buddhist">Buddhist</option>
         <option value="Others">Others</option>
        </select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Date OF Join</label>
<input type="text" id="doj" class="form-control input_text mdate">

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

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Phone
</label>
<input type="text" id="phone"  class="form-control input_text">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Phone2</label>
<input type="text"  id="phone2" class="form-control input_text ">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>District</label>
<select id="district" class="form-control" onchange="get_district();"></select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Pincode</label>
<input type="text" id="pin" class="form-control">
</div>
</div>
</div>
</div>
</div>




</div>
<div class="tab-pane" id="solid-justified-tab2">

    <div class="row" >
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Branch Name</label>
<select class="form-control" id="BranchID"> 
         <option value="0">Select Branch</option>
           @foreach($brn as  $z=>$det) 
           <option value="{{$det->BranchID}}">{{$det->BranchName}}</option>
           @endforeach
        </select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Designation</label>
<select id="desg_id" class="form-control"> 
         <option value="0">Select</option>
          @foreach($des as  $z=>$det) 
           <option value="{{$det->desg_id}}">{{$det->desg_name}}</option>
           @endforeach
        </select>
</div>

</div>

</div>

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Working Hours</label>
<input type="text" class="form-control input_text time-picker">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Basic</label>
<input type="text" class="form-control input_text">
</div>
</div>
</div>

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>PF A/C No</label>
<input type="text" class="form-control input_text">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>ESI A/C No</label>
<input type="text" class="form-control input_text">
</div>
</div>
</div>


<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Bank Name</label>
<input type="text" class="form-control input_text">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Bank A/C Name</label>
<input type="text" class="form-control input_text">
</div>
</div>
</div>


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

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Department</label>
<select id="dep_id" class="form-control"> 
         <option value="0">Select</option>
          @foreach($dept as  $z=>$det) 
           <option value="{{$det->dep_id}}">{{$det->dep_name}}</option>
           @endforeach
        </select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Section</label>
<select id="sec_id" class="form-control"> 
 <option value="0">Select</option>
          @foreach($sec as  $z=>$det) 
           <option value="{{$det->dep_id}}">{{$det->dep_name}}</option>
           @endforeach
        </select>
</div>
</div>
</div>

<div class="row">
<div class="col-md-6"><br>
<div class="form-group row">

<label class="col-form-label col-md-8" for="invalidCheck3">
DA From DA Point

</label>
<div class="col-md-4 text-center">
<input checked name="da_mark"  type="checkbox" id="invalidCheck3" onchange="da_R_only();">
</div>


</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>DA</label>
<input type="text" id="da_amount" class="form-control input_text ">

</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>LWF A/C No</label>
<input type="text" id="date" class="form-control input_text">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Payment Type</label>
<select id="payment_type" class="form-control input_text ">
                              <option value="cash" selected>cash</option>
                              <option value="bank">bank</option>
                             
                            </select>
</div>
</div>
</div>

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Bank A/C Number</label>
<input type="text" id="date" class="form-control input_text">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Bank IFSC</label>
<input type="text" id="date" class="form-control input_text">
</div>
</div>
</div>

</div>
</div>



</div>
<div class="tab-pane" id="solid-justified-tab3">
<div class="row w-100">
  <div class="col-3">
    <!-- Tab navs -->
    <div class="nav flex-column nav-tabs text-center"  id="v-tabs-tab"    role="tablist"     aria-orientation="vertical"  >

    @foreach($pfset as $st)
    
      <a
      class="nav-link " href="#child-justified-tab{{$st->st_id}}" data-bs-toggle="tab"
        >{{$st->st_name}}</a
      >

      @endforeach
   
   
    </div>
    <!-- Tab navs -->
  </div>

  <div class="col-9" class="tab-content">
    <!-- Tab content -->
    
    <div class="tab-content">


<div class="tab-pane" form_id='1' id="child-justified-tab1">
<div class="col-lg-12">


<div class="col-xl-12 col-lg-12 d-flex">
<div class="card flex-fill">
<div class="card-header">
<h4 class="card-title mb-0">Provident Fund Settings</h4>
</div>
<div class="card-body">

<div class="form-group row">
<label class="col-lg-3 col-form-label">Employee's Contribution (%)</label>
<div class="col-lg-4">
<input type="text" id="pf_e" class="form-control form-control-sm input_txt">
</div>
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label">Employer's Contribution (%) </label>
<div class="col-lg-4">
<input type="text" id="pf_er" class="form-control form-control-sm input_txt">
</div>
</div>






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







</div>



</div>


<div class="tab-pane" form_id='3' id="child-justified-tab3">
<div class="col-lg-12">


<div class="col-xl-12 col-lg-12 d-flex">
<div class="card flex-fill">
<div class="card-header">
<h4 class="card-title mb-0">DA Settings</h4>
</div>
<div class="card-body">


<div class="form-group row">

<label class="col-lg-2 col-form-label">DA Point</label>
<div class="col-lg-2">
<input type="text" id="da_pt" class="form-control form-control-sm">
</div>
<label class="col-lg-2 col-form-label">Minus(-)</label>
<div class="col-lg-2">
<input type="text" id="da_minus" class="form-control form-control-sm">
</div>
<label class="col-lg-2 col-form-label">Value</label>
<div class="col-lg-2">
<input type="text" id="da_val" class="form-control form-control-sm">
</div>



</div>




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







</div>
</div>


<div class="tab-pane" form_id='4' id="child-justified-tab4">
<div class="col-lg-12">


<div class="col-xl-12 col-lg-12 d-flex">
<div class="card flex-fill">
<div class="card-header">
<h4 class="card-title mb-0">Allowence</h4>
</div>
<div class="card-body">

<div class="form-group row">
<label class="col-lg-3 col-form-label">Allowence Per Day</label>
<div class="col-lg-4">
<input type="text" id="alwc_day" class="form-control form-control-sm">
</div>
</div>


<div class="form-group row">
<label class="col-lg-3 col-form-label">Monthly Allowance </label>
<div class="col-lg-4">
<input type="text" id="alwc_mth" class="form-control form-control-sm">
</div>



</div>

<div class="form-group row">
<label class="col-lg-3 col-form-label">OverTime Weightage </label>
<div class="col-lg-4">
<input type="text" id="otw" class="form-control form-control-sm">
</div>



</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label">City Allowance</label>
<div class="col-lg-4">
<input type="text" id="alwnc_ct" class="form-control form-control-sm">
</div>



</div>
@foreach($allownce as $al)
<div class="form-group row">
<label class="col-lg-3 col-form-label">{{$al->allowance}}</label>
<div class="col-lg-4">
<input type="text" id="{{$al->id}}" class="form-control form-control-sm allowance_amount">
</div>



</div>
@endforeach










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







</div>

</div>


<div class="tab-pane" form_id='5' id="child-justified-tab5">
<div class="col-lg-12">


<div class="col-xl-12 col-lg-12 d-flex">
<div class="card flex-fill">
<div class="card-header">
<h4 class="card-title mb-0">L.W.F</h4>
</div>
<div class="card-body">

<div class="form-group row">
<label class="col-lg-3 col-form-label">L.W.f</label>
<div class="col-lg-4">
<input type="text" id="lwf" class="form-control form-control-sm">
</div>
</div>






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







</div>

</div>


<div class="tab-pane" form_id='6' id="child-justified-tab6">
<div class="col-lg-12">


<div class="col-xl-12 col-lg-12 d-flex">
<div class="card flex-fill">
<div class="card-header">
<h4 class="card-title mb-0">Category</h4>
</div>
<div class="card-body">

<div class="col-lg-12">

<div class="form-group row">

<label class="col-lg-2 col-form-label">Add Category</label>
<div class="col-lg-2">
<input type="text" id="cat" class="form-control form-control-sm">
</div>

<label class="col-lg-2 col-form-label">Select Category</label>
<div class="col-lg-4">

<select class="form-control form-select">



</select>

<input type="text" id="scat" class="form-control form-control-sm">
</div>




</div>


<div class="form-group row">
<div class="checkbox col-lg-5">
<label>
<input type="checkbox" name="DAFromPoint" class="da_pnt_chk" value="1"> DA From DA Point
</label>
</div>

<div class="col-lg-4">
<input type="text" class="form-control form-control-sm input_text" id="max_dys" placeholder="Max Working Days">

</div>

</div>

<div class="form-group row">

<div class="col-lg-4">
  

<div class="card mb-0">
<div class="card-header">
<h4 class="card-title mb-0">Salary Calculated</h4>
</div>
<div class="card-body">
  
<div class="col-md-10">

<div class="radio">
<label>
<input type="radio" name="Monthly" value="0">Daily
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="Monthly" value="1">Monthly
</label>
</div>
</div>
</div>
</div>


</div>

<div class="col-lg-4">

<div class="card mb-0">
<div class="card-header">
<h4 class="card-title mb-0">PF Deduction On</h4>
</div>
<div class="card-body">
  
<div class="col-md-10">
<div class="checkbox">
<label>
<input type="checkbox" name="pf_dedc" class="pf_check" value="1"> Basic
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="pf_dedc" class="pf_check" value="2"> DA
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="pf_dedc" class="pf_check" value="3"> HRA
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="pf_dedc" class="pf_check" value="3"> Additional Earning
</label>
</div>
</div>
</div>
</div>
</div>

<div class="col-lg-4">

<div class="card mb-0">
<div class="card-header">
<h4 class="card-title mb-0">ESI Deduction On</h4>
</div>
<div class="card-body">
<div class="col-md-10">
<div class="checkbox">
<label>
<input type="checkbox" name="esi_dedc" class="esi_check" value="1"> Basic
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="esi_dedc" class="esi_check" value="2"> DA
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="esi_dedc" class="esi_check" value="3"> HRA
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="esi_dedc" class="esi_check" value="4"> Additional Earning
</label>
</div>
</div>
</div>
</div>
</div>

</div>



</div>

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








</div>

</div>


<div class="tab-pane" form_id='7' id="child-justified-tab7">
<div class="col-lg-12">


<div class="col-xl-12 col-lg-12 d-flex">
<div class="card flex-fill">
<div class="card-header">
<h4 class="card-title mb-0">Punch Settings</h4>
</div>
<div class="card-body">



<div class="form-group row">
<label class="col-lg-3 col-form-label">Min Punching Gap (Seconds)</label>
<div class="col-lg-4">
<input type="text" id="pnch_gp" class="form-control form-control-sm">
</div>
</div>

<div class="form-group row">
<label class="col-lg-3 col-form-label">Full Day (Min) </label>
<div class="col-lg-3">
<input type="text"  id="f_day_min" class="form-control form-control-sm"   onBlur="calculat_hour_to_index('f_day_min');"  >
</div>
<label class="col-lg-3 col-form-label">Full Day (Max) </label>
<div class="col-lg-3">
<input type="text" id="f_day_max" class="form-control form-control-sm" onBlur="calculat_hour_to_index('f_day_max');" >
</div>


</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label">Half Day (Min-hrs) </label>
<div class="col-lg-3">
<input type="text" id="h_day_min" class="form-control form-control-sm" onBlur="calculat_hour_to_index('h_day_min');" >
</div>
<label class="col-lg-3 col-form-label">Half Day (Max-hrs) </label>
<div class="col-lg-3">
<input type="text" id="h_day_max" class="form-control form-control-sm"  onBlur="calculat_hour_to_index('h_day_max');">
</div>


</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label">Quarter Day (Min-hrs) </label>
<div class="col-lg-3">
<input type="text"  id="q_day_min" class="form-control form-control-sm"  onBlur="calculat_hour_to_index('q_day_min');">
</div>
<label class="col-lg-3 col-form-label">Quarter Day (Max-hrs) </label>
<div class="col-lg-3">
<input type="text" id="q_day_max" class="form-control form-control-sm" onBlur="calculat_hour_to_index('q_day_max');">
</div>


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


<div class="tab-pane" form_id='2' id="child-justified-tab2">


<div class="col-lg-12">


<div class="col-xl-12 col-lg-12 d-flex">
<div class="card flex-fill">
<div class="card-header">
<h4 class="card-title mb-0">ESI Settings</h4>
</div>
<div class="card-body">

<div class="form-group row">
<label class="col-lg-3 col-form-label">Employee's Contribution (%)</label>
<div class="col-lg-4">
<input type="text" id="esi_e" class="form-control form-control-sm">
</div>
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label">Employer's Contribution (%) </label>
<div class="col-lg-4">
<input type="text" id="esi_er" class="form-control form-control-sm">
</div>
</div>







</div>
</div>










</div>







</div>
</div>
     
    </div>
    <!-- Tab content -->
  </div>
</div>




</div>


</div>
</div>

<div class="text-end">
<button type="button" id="add_btn" class="btn btn-primary btn-lg" onclick="submit_form();">Save</button>
<button type="button" id="edit_btn" class="btn btn-success btn-lg" onclick="submit_form();">Edit</button>
<button type="button" class="btn btn-success btn-lg" onclick="reset_form();">Reset</button>
</div>


</div>

</form>
</div>
</div>
</div>
</div>
@endsection




@section('page-script')

<script src="{{ asset('project-js/employee_master_scripts.js')}}"></script>
<script src="{{ asset('project-js/vega-front-scripts.js')}}"></script>
<script type="text/javascript">
     $( document ).ready(function() {
        set_mn();
 get_country();
//$('#tab2,#tab3').prop('disabled',true);
da_R_only();

/*$('#v-tabs-tab> .nav-link:first-child').addClass('active');
$('#child-justified-tab1').addClass('active');*/
fetch_view_table();

});



function submit_form() {
 status=0;
 if($.trim($('#emp_name').val())==''){
    alert('Enter Branch Name');
    $('#emp_name').focus();
    status==1;
    return;
 }
 if (status==0) {
Save_form();
 }
}
//http://192.168.18.128/prl_api/ij/prl_branch_edit.php

function call_edit_modal(row_id) {
$('#add_btn').hide();
$('#edit_btn').show();

    $('#row_id').val(row_id);
    $('#hidden_status').val(1);
        $.ajax({
              type: 'POST',
               async: false,
                url: '/prl_branch_edit',
                data: {
                     '_token': "{{ csrf_token() }}",
                    'cid':"{{ Session::get('cid')}}",
                     row_id: row_id,
              url1:'prl_branch_edit.php'
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {
 datas=response.edit;

          
              $('.add_main_modal').modal('show');
            $('#BranchName').val(datas[0]['BranchName']); 
            $('#BranchCode').val(datas[0]['BranchCode']); 
            $('#BranchAddress').val(datas[0]['BranchAddress']); 
            $('#BranchPhone').val(datas[0]['BranchPhone']); 
            $('#working_hours').val(datas[0]['working_hours']); 
   
            
       // start_focus();   
        }
          
     });  
}

  function Save_form() {
  arr={
              'cid':"{{ Session::get('cid')}}",
              'hidden_status':$.trim($('#hidden_status').val()),
              'row_id':$.trim($('#row_id').val()),
              'emp_name':$.trim($('#emp_name').val()),
              'guardian':$.trim($('#guardian').val()),
              'addres':$.trim($('#addres').val()),
              'country':$.trim($('#country').val()),
              'state':$.trim($('#state').val()),
              'district':$.trim($('#district').val()),
              'emp_code':$.trim($('#emp_code').val()),
              'serial_no':$.trim($('#serial_no').val()),
              'mach_code':$.trim($('#mach_code').val()),
              'phone':$.trim($('#phone').val()),
              'blood':$.trim($('#blood').val()),
              'dob':$.trim($('#dob').val()),
              'religion':$.trim($('#religion').val()),
              'doj':$.trim($('#doj').val()),
              'pin':$.trim($('#pin').val()),
              'phone2':$.trim($('#phone2').val()),
              'branch_id':$.trim($('#branch_id').val()),
              'gender':$.trim($('input[name="gender"]:checked').val()),
              'company_id':"{{ Session::get('CID')}}",
              'added_by':"{{ Session::get('user_id')}}",
};
           $.ajax({
          url: "/store_data",
          type: "POST",
          data:{
             '_token': "{{ csrf_token() }}",
              json_data: JSON.stringify(arr),
              url1:'prl_employee_save.php'
             
          },
          success:function(response){
            
            console.log(response);
            if (response) {
              alert(response['msg']);
            
               $('.add_main_modal').modal('hide');
               fetch_view_table();
            }else{

            }
          },
          error: function(response) {
          }
         });
  }

$(".add_main_modal" ).on('hidden.bs.modal', function(){ $('#add_btn').show();
$('#edit_btn').hide();
 $('#hidden_status').val(0);
reset_form();
});


function get_country() {
        $.ajax({
              type: 'POST',
               async: false,
                url: '/get_data',
                data: {
                     '_token': "{{ csrf_token() }}",
                    'cid':"{{ Session::get('cid')}}",
                     row_id: 'X',
              url1:'prl_get_country.php'
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) { 
$('#country').html("<option val='0'>-Select Country-</option>");
 $(response).each(function (i,val){
$('#country').append("<option value='"+val['country_id']+"'>"+val['country_name']+"</option>");
 });
$('#country').val(103);
get_state();
        }
          
     });  
}


function get_state() {
        $.ajax({
              type: 'POST',
               async: false,
                url: '/get_data',
                data: {
                     '_token': "{{ csrf_token() }}",
                    'cid':"{{ Session::get('cid')}}",
                     row_id: $('#country').val(),
              url1:'prl_get_state.php'
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {
$('#state').html("<option val='0'>-Select State-</option>");
 $(response).each(function (i,val){
$('#state').append("<option value='"+val['state_id']+"'>"+val['state_name']+"</option>");
 });
$('#state').val(10);
get_district();
        }
          
     });  
}


function get_district() {
        $.ajax({
              type: 'POST',
               async: false,
                url: '/get_data',
                data: {
                     '_token': "{{ csrf_token() }}",
                    'cid':"{{ Session::get('cid')}}",
                     row_id: $('#state').val(),
              url1:'prl_get_district.php'
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {
$('#district').html("<option val='0'>-Select District-</option>");
 $(response).each(function (i,val){
$('#district').append("<option value='"+val['district_id']+"'>"+val['district_name']+"</option>");
 });

$('#country').val(4);
        }
          
     });  
}
function da_R_only() {
    if($('input[name="da_mark"]').prop('checked')){
        $('#da_amount').prop('readonly',false);
    }else{
            $('#da_amount').prop('readonly',true);
    }

}
function employee_view(epl_id) {
    window.location.href='/viw_employee/'+epl_id;
}
</script>
@endsection