<?php require_once('../auth/auth.php');require_once('../auth/function.php');
$gcatid= $_GET['gcatid']; ?>
<section class="content">
   <div class="container-fluid">
      <div class="row">
         <div class="col-md-12">
            <div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
               <div class="card-header" style="padding: 5px 8px;">
                  <h3 class="card-title"><?php echo language(246); ?></h3>
                  <div class="card-tools"> <button type="button" class="btn btn-tool" data-card-widget="remove"> <i class="fas fa-times"></i>  </button> </div>
               </div>
               <form id="employee_form" action="#" method="post" autocomplete="off">
                  <input type="hidden" name="newemployee" required="true">
                  <input type="hidden" name="gcatid" value="<?php echo $gcatid ?>" required="true">
                  <div class="card-body">
                     <div class="col-md-12">
                        <div class="row mt-2">
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label> <?php echo language(247); ?> <b class="text-danger"> *</b></label>
                                 <input type="text" name="em_acname"  class="form-control form-control-sm inputselect" required="true">
                              </div>
                           </div>
                           <div class="col-md-2">
                              <div class="form-group">
                                 <label> <?php echo language(110);?> <b class="text-danger"> *</b></label>
                                 <input type="text" name="alias_name"  class="form-control form-control-sm inputselect" required="true">
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(111);?> <b class="text-danger"> *</b></label>
                                 <input type="number" name="ac_number" id="checknumber"  onkeyup="checknumber();" class="form-control form-control-sm inputselect" required="true">
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(112);?> <b class="text-danger"> *</b></label>
                                 <input type="email" value="youmail@gmail.com" name="ac_email"  class="form-control form-control-sm inputselect" required="true">
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(113);?></label>
                                 <select name="divisions" id="divisions" onchange="divisionsList();" class="form-control" required="true">
                                    <option disabled selected>Select Division</option>
                                    <option value="Barishal">Barishal</option>
                                    <option value="Chattogram">Chattogram</option>
                                    <option value="Dhaka">Dhaka</option>
                                    <option value="Khulna">Khulna</option>
                                    <option value="Mymensingh">Mymensingh</option>
                                    <option value="Rajshahi">Rajshahi</option>
                                    <option value="Rangpur">Rangpur</option>
                                    <option value="Sylhet">Sylhet</option>
                                 </select>
                              </div>
                           </div>
                           <div class="col-md-2">
                              <div class="form-group">
                                 <label><?php echo language(114);?>  </label>
                                 <select  id="distr" name="distr" onchange="thanaList();" class="form-control" required="true">
                                 </select>
                              </div>
                           </div>
                           <div class="col-md-2">
                              <div class="form-group">
                                 <label> <?php echo language(115);?>   </label>
                                 <select  id="polic_sta" name="polic_sta"  class="form-control" required="true">
                                 </select>
                              </div>
                           </div>
                           <div class="col-md-5">
                              <div class="form-group">
                                 <label> <?php echo language(248);?> <b class="text-danger"> *</b></label>
                                 <input name="present_address" class="form-control form-control-sm inputselect" rows="2">
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(117);?> <b class="text-danger"> *</b></label>
                                 <input type="number" name="em_nid"  class="form-control form-control-sm inputselect">
                              </div>
                           </div>
                           
                           <?php
                              $em_query= mysqli_query($conn,"SELECT `em_id` FROM em_employee WHERE  em_id ORDER BY em_id DESC  ") or die (mysqli_error($conn));
                                   $rowus=mysqli_fetch_array($em_query);
                                     $em_id =$rowus['em_id']+1;
                                     $get_outlet= "EMP".'-'.$em_id;
                           ?>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(118);?> </label>
                                 <input type="text" name="out_it" value="<?php echo  $get_outlet;?>"  class="form-control form-control-sm inputselect">
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(173); ?>   </label>
                                 <select id="designation_type" name="designation_type"  class="form-control" required="true">
                                    <option></option>
                                    <?php 
                                       $desid_query= mysqli_query($conn,"SELECT em_desid,desig_name FROM em_designation WHERE coid='$coid'  AND status=1") or die (mysqli_error($conn));
                                       while($d_row= mysqli_fetch_assoc($desid_query)){
                                        echo '<option value='.$d_row["em_desid"].'>'.$d_row["desig_name"].'</option>';
                                       }?>  

                                 </select>
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(252); ?>  %</label>
                                 <input type="text" name="comm_margin"  class="form-control form-control-sm inputselect" value="0" >
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(120);?>  </label>
                                 <input type="number" name="crlimit"  class="form-control form-control-sm inputselect"  value="0" style="text-align:center;" >
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(177);?>   </label>
                                 <input type="number" name="salary"  class="form-control form-control-sm inputselect"  value="0" style="text-align:center;" >
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(251);?> </label>
                                 <input type="text" name="brith_date" class="form-control form-control-sm" onmouseover="lcdate(this)" style="text-align:center;" readonly="true" required="true" value="<?php echo $date;?>">
                              </div>
                           </div>
                           <div class="col-md-3">
                              <div class="form-group">
                                 <label><?php echo language(249);?>  </label>
                                 <input type="text" name="par_address"  class="form-control form-control-sm inputselect">
                              </div>
                           </div>
                           <div class="col-md-12">
                              <div class="form-group">
                                 <label><?php echo language(128);?> </label>
                                 <textarea name="g_note" class="form-control form-control-sm inputselect" rows="1" placeholder="Enter ..."></textarea>
                              </div>
                           </div>
                           
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label><?php echo language(250);?>   </label>
                                 <select id="working_type" name="working_type"  class="form-control" required="true">
                                    <option value="1">Part time </option>
                                    <option value="2">Ontime</option>
                                    <option value="3"> Salayry</option>
                                 </select>
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                 <center><label><?php echo language(131);?> </label></center>
                                 <input type="text" name="ac_join_date" class="form-control form-control-sm" onmouseover="stdate(this)" style="text-align:center;" readonly="true" required="true" value="<?php echo $date;?>">
                              </div>
                           </div>
                           <div class="col-md-1"> </div>
                           <div class="col-md-3">
                              <div class="form-group" style="margin-top:19px;">
                                 <div class="custom-control custom-checkbox">
                                    <input name="sendsms" class="custom-control-input" type="checkbox" id="customCheckbox2" value="yes">
                                    <label for="customCheckbox2" class="custom-control-label"><?php echo language(132);?></label>
                                 </div>
                              </div>
                           </div>
                        </div>
                     </div>
                  </div>
                  <center>
                  <div class="card-footer" style="padding: 8px 5px;">
                     <button type="submit" id="save" class="btn btn-success btn-xs"><?php echo language(23);?></button>
                     <button type="reset" class="btn btn-secondary btn-xs"><?php echo language(24);?></button>
                  </div>
                  </center>
               </form>
            </div>
         </div>
      </div>
   </div>
</section>
<script>
$(document).ready(function(){
   $("select").select2();
});
</script>
<script>
$(document).ready(function() {
$('#employee_form').on('submit', function(e){
var ac_type =$("#ac_type").val();
$('#save').prop('disabled', true);
$('#save').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> '+'Loading...');
e.preventDefault();
$.post("../hr_manage/employee_db.php",$(this).serialize(),function(data){
$('#employee_form')[0].reset();
$('#save').prop('disabled', false);
$('#save').html('Save');
$.post('../hr_manage/employee_list.php?ac_type='+'sl-exp'+'&em_group_id=<?php echo $gcatid ?>',{},function(res){
$('#hrhome').html(res);
});
toastr.success(Showing, '<?php echo "New Employee Add Successful" ?>');

});
});
});
</script>
<script type="text/javascript">
function checkname(){  var co_gsm=document.getElementById( "co_gsm" ).value;
if(co_gsm){
$.ajax({
type: 'post',
url: '../user/user_check.php',
data: {
co_gsm:co_gsm,
},
success: function (response) {
$( '#co_gsm' ).html(response);
if(response=="OK") {
return true; }else{return false; }}
});}
else{
$( '#co_gsm' ).html("");
return false;
}
}
function checkall(){
var namehtml=document.getElementById("co_gsm").innerHTML;
if(namehtml=="OK"){
return true;
}else
{return false;
}
}
</script>