<?php
session_start();
$adminemailid=$_SESSION['emailid'];
$companyname=$_SESSION['companyname'];
$companytype=$_SESSION['companytype'];
$designation=$_SESSION['designation'];
$companymailid=$_SESSION['companymailid'];
date_default_timezone_set("Asia/Kolkata");
include('../Model/configuration.php');
include('../../View/mcrypt.php');
$mcrypt = new MCrypt();
$sql="SELECT `emailid` FROM `signupdetails`";
$result = $pdo->query($sql);
$emp_id_array=[];
$emailid_array=[];
foreach($result as $row){
    $emp_emailid=$row['emailid'];
    array_push($emailid_array,$emp_emailid);
}
$sql="SELECT `emp_id` FROM `signupdetails` where companyname='".$companyname."'";
$result = $pdo->query($sql);
foreach($result as $row){
    $emp_id=$row['emp_id'];
    array_push($emp_id_array,$emp_id);
}
$sql1="SELECT `Id`,lastlogin, `companyname`, `adminemailid`, `employeename`, `emp_id`, `emailid`, `mobilenumber`, `companytype`, `websignout`, `designation`, `password`, first_name, `last_name`, `nationality`, `dateandtime`, `signout`, `imagefilepath`, `IMEI`, `empcompanytype` FROM `signupdetails` WHERE signupdetails.companyname='".$companyname."' and  `deleted`='no'";
//echo $sql1;
$result1 = $pdo->query($sql1);

$sql_country="SELECT `id`, `sortname`, `name`, `phonecode` FROM `countries`";
$resultcountry = $pdo->query($sql_country);
$country_name_array=array();
$country_phonecode_array=array();
foreach($resultcountry as $rowcountry){
    $cname=$rowcountry['name'];
    $cphonecode=$rowcountry['phonecode'];
    array_push($country_name_array, $cname);
    array_push($country_phonecode_array, $cphonecode);
}

?>
<html>
    
    <head>
        <link rel="icon" href="../../Images/cloud-icon-27.png">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../../Bootstrap/css/bootstrap.min.css">
        <script src="../../Bootstrap/jquery.min.js"></script>
        <script src="../../Bootstrap/js/bootstrap.min.js"></script>
        <script src="../../Bootbox/bootbox.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.css">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.js"></script>
        <script src="../../Js/bootstrapAlert.js"></script>
        <link href="../../font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
        <link href="deal_action_stream.css" rel="stylesheet">
        <script src="deal_action_stream.js"></script>
        
        <link href="../../Clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet" type="text/css" />
        <link href="../../Clockpicker/github.min.css" rel="stylesheet" type="text/css" />
        <script src="../../Clockpicker/jquery-clockpicker.min.js"></script>
    
        <link href="../../Datepicker/bootstrap-datepicker.css" rel="stylesheet" type="text/css" />
        <script src="../../Datepicker/bootstrap-datepicker.js"></script>
    
        
        <link rel="stylesheet" href="../../Selectpicker/bootstrap-select.min.css">
        <link rel="stylesheet" href="../../Selectpicker/bootstrap-select.css.map">
        <script src="../../Selectpicker/bootstrap-select.js"></script>
        <script src="../../Selectpicker/bootstrap-select.js.map"></script>
        
        <style>
            .image-upload > input
            {
                visibility: hidden;
            }
        </style>
        <style>
            .bootstrap-select .dropdown-toggle .filter-option {
                position: inherit;
            }
            .bootstrap-select>.dropdown-toggle {
                height:35px;
            }
            .bootstrap-select>.btn {
            padding: 3px 12px;
            }
        </style>
        <style>
            div .user{
                box-sizing: border-box;
                -webkit-box-sizing: border-box;
                -moz-box-sizing: border-box;
                -ms-box-sizing: border-box;
                -webkit-border-radius: 4px;
                -moz-border-radius: 4px;
                border-radius: 4px;height: 85px;
                float: left;
                width:100%;
                height:100px;
                margin: 0 0px 8px 0;
                padding: 8px 0px;
                background: #F5F5F5;
                overflow: hidden;
                position: relative;
            }
            div>.user>.col-xs-4{
                padding-left:10px;
                padding-right:10px;
            }
        </style>
    </head>
    
    <body>
       
        <div class="container-fluid">
            <?php
            $empcount=$result1->rowcount();
            $colcount=-1;
            foreach($result1 as $row1){
                $colcount=$row1['Id'];
                $employeename=$row1['employeename'];
                $empmailid=$row1['emailid'];
                $emp_id=$row1['emp_id'];
                if($emp_id=="no data available"){
                    $emp_id="";
                }
                $designation=$row1['designation'];
                $lastlogin=$row1['lastlogin'];
                $first_name=$row1['first_name'];
                if(($first_name=="no data available")||($first_name=="")){
                    $first_name=$employeename;
                }
                $last_name=$row1['last_name'];
                if(($last_name=="no data available")){
                    $last_name="";
                }
                $password1=$row1['password'];
                $password= $mcrypt->decrypt($password1);
                $imagefilepath=$row1['imagefilepath'];
                $mobilenumber1=$row1['mobilenumber'];
                $mobilenumber=explode(" ",$mobilenumber1);
                $phone_number=$mobilenumber[count($mobilenumber)-1];
                $nationality=$row1['nationality'];
                if(($imagefilepath=="")||($imagefilepath=="no data available")){
                    $imagefilepath="Image/profile-default-male.png";
                }else{
                    $imagefilepath="../../signupicon/".$imagefilepath;
                }
                if(strtolower($designation)==strtolower("employee")){
                    $designation="User";
                }
            ?>
            
                <?php
                if($colcount==2){
                ?>
                <div class="row">
                <?php
                }
                ?>
                   <div class="col-xs-4" style="padding-left:4px;padding-right:4px;cursor:pointer;" <?php if($adminemailid==$companymailid){?> onclick="editfunction('#id_vel_<?php echo $colcount;?>','#employee_name_vel_<?php echo $colcount;?>','#first_name_vel_<?php echo $colcount;?>', '#last_name_vel_<?php echo $colcount;?>', '#emp_emailid_vel_<?php echo $colcount;?>', '#emp_id_vel_<?php echo $colcount;?>', '#password_vel_<?php echo $colcount;?>', '#nationality_vel_<?php echo $colcount;?>', '#phone_number_vel_<?php echo $colcount;?>', '#image_path_vel_<?php echo $colcount;?>')" <?php } ?>>
                       <div class="user">
                            <input type="hidden" id="id_vel_<?php echo $colcount;?>" value="<?php echo $colcount;?>">
                            <input type="hidden" id="employee_name_vel_<?php echo $colcount;?>" value="<?php echo $employeename;?>">
                            <input type="hidden" id="first_name_vel_<?php echo $colcount;?>" value="<?php echo $first_name;?>">
                            <input type="hidden" id="last_name_vel_<?php echo $colcount;?>" value="<?php echo $last_name;?>">
                            <input type="hidden" id="emp_emailid_vel_<?php echo $colcount;?>" value="<?php echo $empmailid;?>">
                            <input type="hidden" id="emp_id_vel_<?php echo $colcount;?>" value="<?php echo $emp_id;?>">
                            <input type="hidden" id="password_vel_<?php echo $colcount;?>" value="<?php echo $password;?>">
                            <input type="hidden" id="nationality_vel_<?php echo $colcount;?>" value="<?php echo $nationality;?>">
                            <input type="hidden" id="phone_number_vel_<?php echo $colcount;?>" value="<?php echo $phone_number;?>">
                            <input type="hidden" id="image_path_vel_<?php echo $colcount;?>" value="<?php echo $imagefilepath;?>">
                           <div class="col-xs-4">
                               <img src="<?php echo $imagefilepath;?>" width="100%" height="100%">
                           </div>
                           <div class="col-xs-8" style="font-size:12px;line-height: 22px;">
                               <span style="font-size:14px;"><b><?php echo $employeename;?></b><br></span>
                               <span style="color:#5695E4;font-size:12px;width: auto;display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 160px;"><?php echo $empmailid;?></span>
                               <?php
                               if($designation!="admin"){
                                ?>
                                <span style="border-radius: 4px;font-size:12px;padding: 2px 5px;color: #fff;background-color: #d58512;border-color: #985f0d;"><?php echo $designation;?></span><br>
                                <?php
                                }else{
                                ?>
                                <span style="border-radius: 4px;font-size:12px;padding: 2px 5px;color: #fff;background-color: #A5D321;border-color: #A5D321;"><?php echo $designation;?></span><br>
                                <?php
                                }
                                ?>
                               <?php
                               if($lastlogin=="0000-00-00 00:00:00"){
                                ?>
                                <span style="color:#979797">Still User Not Login</span>
                                <?php
                               }else{
                                   $seen1=explode(" ",$lastlogin);
                                   $seen=$seen1[0];
                                   if($seen==date("Y-m-d")){
                                       $seen="Today";
                                   }else if($seen==date('Y-m-d',strtotime("-1 days"))){
                                       $seen="Yesterday";
                                   }
                               ?>
                               <span style="color:#979797">Last Seen <?php echo $seen;?></span>
                               <?php
                               }
                               ?>
                           </div>
                       </div>
                   </div>
                <?php
                if($colcount==2){
                    $colcount=0;
                ?>
               </div>
               <?php
                }else{
                    $colcount++;
                }
            }
            ?>
       </div>
       
       
<script>
    function editfunction(id,employeename,firstname,lastname,empemailid,empid,password,country,phone,image){
        var adminemailid="<?php echo $adminemailid;?>";
        var country_name_array=<?php echo json_encode($country_name_array);?>;
        var country_phonecode_array=<?php echo json_encode($country_phonecode_array);?>;
        
        var id=$(id).val();
        var employeename=$(employeename).val();
        var firstname=$(firstname).val();
        var lastname=$(lastname).val();
        var empemailid=$(empemailid).val();
        if(empemailid==adminemailid){
            $("#deleteemployee").hide();
            $("#showoldpassword").show();
        }else{
            $("#deleteemployee").show();
            $("#showoldpassword").hide();
        }
        var empid=$(empid).val();
        var password=$(password).val();
        var country=$(country).val();
        var phone=$(phone).val();
        var image=$(image).val();
        if((firstname=="")){
            firstname=employeename;
        }
        var countryoption="";
        for(i=0;i<country_name_array.length;i++){
            countryname=country_name_array[i];
            countryphonecode=country_phonecode_array[i];
            if(countryname==country){
                countryoption+="<option value='"+countryname+"#@"+countryphonecode+"' selected>"+countryname+" (+"+countryphonecode+")<option>";
            }else{
                countryoption+="<option value='"+countryname+"#@"+countryphonecode+"'>"+countryname+" (+"+countryphonecode+")<option>";
            }
        }
        $("#oldid").val(id);
        $("#firstname").val(firstname);
        $("#lastname").val(lastname);
        $("#empid").val(empid);
        $("#empmailid").val(empemailid);
        $("#country").append(countryoption);
        $(".selectpicker").selectpicker("refresh");
        $("#phonenumber").val(phone);
        $('#empphoto').attr('src', image)
        $('#oldpassword').val(password);
        $("#oldempmailid").val(empemailid);
        $("#oldempid").val(empid);
        $('#myModal').modal('show'); 
    }
</script>

<!-- Modal -->
<div id="myModal" class="modal fade" style="background-color:white;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Edit team member's details</h3>
    </div>
    <div class="modal-body">
        
        
        <div class="container-fluid">
            
            <form>
                <div class="row">
                    <div class="col-xs-3">
                        <div class="image-upload">
                            <label for="file-input">
                                <img src="Image/profile-default-male.png" id="empphoto" width="100%" height="auto" style="z-index:1;cursor:pointer"/>
                            </label>
                            <input id="file-input" type="file" onchange="functionupload(this)"  style="z-index:2;margin-top:-35px;" accept="image/png, image/jpeg, image/jpg">
                        </div>
                    </div>
                    <div class="col-xs-9">
                        <div class="col-xs-6" style="padding-top:20px;">
                            <span>First Name</span>
                            <input type="text" id="firstname" class="form-control" name="firstname">
                        </div>
                        <div class="col-xs-6" style="padding-top:20px;">
                            <span>Last Name</span>
                            <input type="text" id="lastname" class="form-control" name="lastname">
                        </div>
                        <div class="col-xs-6" style="padding-top:20px;">
                            <span>Email</span>
                            <input type="text" id="empmailid" onchange="funempmailid()" readonly class="form-control" name="empmailid">
                        </div>
                        <div class="col-xs-6" style="padding-top:20px;">
                            <span>Employee Id</span>
                            <input type="text" id="empid" onchange="funempid()" class="form-control" name="empid">
                        </div>
                        <div class="col-xs-6" style="padding-top:20px;">
                            <span>Country Code</span>
                            <select id="country" class="selectpicker form-control" name="country" data-live-search="true">
                                <?php
                                foreach($result1 as $row1){
                                    $id=$row1['id'];
                                    $name=$row1['name'];
                                    $phonecode=$row1['phonecode'];
                                    if(strtoupper($name)==strtoupper("India")){
                                    ?>
                                    <option value="<?php echo $name.'#@'.$phonecode;?>" selected><?php echo $name." (+".$phonecode.")";?></option>
                                    <?php
                                    }else{
                                    ?>
                                    <option value="<?php echo $name.'#@'.$phonecode;?>"><?php echo $name." (+".$phonecode.")";?></option>
                                    <?php  
                                    }
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-xs-6" style="padding-top:20px;">
                            <span>Phone Number</span>
                            <input type="text" id="phonenumber" class="form-control" name="phonenumber">
                        </div>
                        <div style="padding-top:20px;">
                            <div style="color:#5695E4;cursor:pointer;" id="changepasswordhide"><div class="col-xs-6" style="padding-top:20px;" id="changepassword">Change Password</div><div style="padding-top:20px;" class="col-xs-6" id="deleteemployee">Delete User</div></div>
                            <span id="changepasswordshow" style="display:none">
                                <div class="col-xs-12" style="padding-top:20px;" ><b>Change Password</b></div>
                                <div class="col-xs-12" id="showoldpassword" style="padding-top:20px;">
                                    <span>Old Password</span>
                                    <input type="text" id="checkoldpassword" class="form-control" name="checkoldpassword">
                                </div>
                                <div class="col-xs-6" style="padding-top:20px;">
                                    <span>New Password</span>
                                    <input type="text" id="newpassword" class="form-control" name="newpassword" onchange="checkpasswordfun()">
                                </div>
                                <div class="col-xs-6" style="padding-top:20px;">
                                    <span>Re-type New Password</span>
                                    <input type="text" id="retypenewpassword" class="form-control" name="retypenewpassword" onchange="checkpasswordfun()">
                                </div>
                            </span>
                        </div>
                        
                        <input type="hidden" id="oldempmailid" value="">
                        <input type="hidden" id="oldempid" value="">
                        <input type="hidden" id="oldpassword" value="">
                        <input type="hidden" id="oldid" value="">
                    </div>
                        
                </div>
                <div style="padding-top:40px;">
                    <center>
                        <input type="button" class="btn btn-primary" id="updateuserdetails" value="Save changes">
                        <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
                    </center>
                </div>
                
            </form>
            
        </div>
    </div>
</div>
<script>
    function  checkpasswordfun(){
        var newpassword=$("#newpassword").val();
        var retypenewpassword=$("#retypenewpassword").val();
        var adminemailid="<?php echo $adminemailid;?>";
        var empmailid=$("#oldempmailid").val();
        if(adminemailid==empmailid){
        var checkoldpassword=$("#checkoldpassword").val();
        var oldpassword=$("#oldpassword").val();
            if(checkoldpassword!=oldpassword){
                $("#checkoldpassword").css("border-color","red");
                swal("warning","Please enter the Correct password", "warning");
                $("#updateuserdetails").attr("disabled",true);
                return;
            }
            if(newpassword==retypenewpassword){
                $("#updateuserdetails").attr("disabled",false);
                $("#newpassword").css("border-color","green");
                $("#retypenewpassword").css("border-color","green");
            }else{
                $("#updateuserdetails").attr("disabled",true);
                $("#newpassword").css("border-color","red");
                $("#retypenewpassword").css("border-color","red");
                return;
            }
        }else{
            if(newpassword==retypenewpassword){
                $("#updateuserdetails").attr("disabled",false);
                $("#newpassword").css("border-color","green");
                $("#retypenewpassword").css("border-color","green");
            }else{
                $("#updateuserdetails").attr("disabled",true);
                $("#newpassword").css("border-color","red");
                $("#retypenewpassword").css("border-color","red");
                return;
            }
        }
    }
</script>
<script>
    $(document).on("change", "#checkoldpassword", function(){
        var checkoldpassword=$("#checkoldpassword").val();
        var oldpassword=$("#oldpassword").val();
        if(checkoldpassword!=oldpassword){
            $("#checkoldpassword").css("border-color","red");
            swal("warning","Please enter the Correct password", "warning");
            $("#updateuserdetails").attr("disabled",true);
        }else{
            $("#checkoldpassword").css("border-color","green");
            $("#updateuserdetails").attr("disabled",false);
        }
    });
</script>
        <script>
            $(document).on("click", "#changepassword", function(){
               $("#changepasswordhide").hide();
               $("#changepasswordshow").show();
               $("#updateuserdetails").attr("disabled",true);
            });
        </script>
        <script>
            function functionupload(input){
                
                if (input.files && input.files[0]) {
                    var reader = new FileReader();
    
                    reader.onload = function (e) {
                        $('#empphoto')
                            .attr('src', e.target.result)
                            .width(150)
                            .height(200);
                    };
                    var oldempmailid=$("#oldempmailid").val();
                    var oldid=$("#oldid").val();
                    var fileUpload = $("#file-input").get(0);
                    var files = fileUpload.files;
                    var formData = new FormData();
                    filesd = document.getElementById("file-input").files[0];
                    formData.append("updateuserphoto","filesd");
                    formData.append("files",filesd);
                    formData.append("empmailid",oldempmailid);
                    formData.append("oldid",oldid);
                    $.ajax({
                        url : "../Control/user.php",
                        type: 'POST',
                        data : formData,
                        cache       : false,
                        contentType : false,
                        processData : false,
                        success:function(respond)
                        {
                            //swal("","Photo uploaded Successfully", "success");
                        }
                    });
                    reader.readAsDataURL(input.files[0]);
                }else{
                    
                    reader.onload = function (e) {
                        $('#empphoto')
                            .attr('src', "Image/profile-default-male.png")
                            .width(150)
                            .height(200);
                    };
                }
            }
        </script>
        <script>
            function isValidEmail(email)
            {
                return /^[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,4}$/.test(email)
                    && /^(?=.{1,64}@.{4,64}$)(?=.{6,100}$).*/.test(email);
            }
            function isValidphone(phoneNumber){
                var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
                if(phoneNumber!=""){
                    if (filter.test(phoneNumber)) {
                      if(phoneNumber.length>4){
                           return true;
                      } else {
                            BootstrapAlert.warning({
                              title: "Warning!",
                              message: "Please Fill the correct Phone Number"
                            });
                            return false;
                      }
                    }
                    else {
                        BootstrapAlert.warning({
                          title: "Warning!",
                          message: "Please Fill the correct Phone Number"
                        });
                      return false;
                    }
                }
                else {
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Phone Number"
                    });
                  return false;
                }
            }
            function funempmailid(){
                var empmailid=$("#empmailid").val();
                empmailid=empmailid.trim();
                var validateemail=isValidEmail(empmailid);
                if(validateemail==false){
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Email address"
                    });
                    $("#empmailid").val();
                    $("#empmailid").focus();
                    $("#empmailid").css("border-color","red");
                    return;
                }else{
                    $("#empmailid").css("border-color","green");
                }
                var oldempmailid=$("#oldempmailid").val();
                oldempmailid=oldempmailid.trim();
                if(empmailid==""){
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Email address"
                    });
                    $("#empmailid").val();
                    $("#empmailid").focus();
                    return;
                }
                var emailid_array=<?php echo json_encode($emailid_array);?>;
                if(oldempmailid!=empmailid){
                    if(jQuery.inArray(empmailid, emailid_array)!='-1'){
                        //swal("error","Email Already is there","error");
                        BootstrapAlert.alert({
                          title: "Warning!",
                          message: "Please Fill the Correct Mail Id"
                        });
                        $("#empmailid").val("");
                        $("#empmailid").focus();
                        return;
                    }
                }
            }
            function funempid(){
                var empid=$("#empid").val();
                var emp_id_array=<?php echo json_encode($emp_id_array);?>;
                empid=empid.trim();
                var oldempid=$("#oldempid").val();
                oldempid=oldempid.trim();
                if(empid==""){
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Employee Id"
                    });
                    $("#empid").val();
                    $("#empid").focus();
                    return;
                }
                if(oldempid==empid){
                    if(jQuery.inArray(empid, emp_id_array)!='-1'){
                        //swal("error","Email Already is there","error");
                        BootstrapAlert.alert({
                          title: "Warning!",
                          message: "Please Fill the Correct Employee Id"
                        });
                        $("#empid").val("");
                        $("#empid").focus();
                        return;
                    }
                }
            }
        </script>
        <script>
            $(document).on("click", "#updateuserdetails", function(){
                var firstname=$("#firstname").val();
                var lastname=$("#lastname").val();
                var empid=$("#empid").val();
                var empmailid=$("#empmailid").val();
                var validateemail=isValidEmail(empmailid);
                if(validateemail==false){
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Email address"
                    });
                    $("#empmailid").val();
                    $("#empmailid").focus();
                    $("#empmailid").css("border-color","red");
                    return;
                }else{
                    $("#empmailid").css("border-color","green");
                }
                var country=$("#country").val();
                var phonenumber=$("#phonenumber").val();
                var validatephone=isValidphone(phonenumber);
                if(validatephone==false){
                    $("#phonenumber").val();
                    $("#phonenumber").focus();
                    $("#phonenumber").css("border-color","red");
                    return;
                }else{
                    $("#phonenumber").css("border-color","green");
                }
                var oldempmailid=$("#oldempmailid").val();
                var oldempid=$("#oldempid").val();
                var oldpassword=$("#oldpassword").val();
                var oldid=$("#oldid").val();
                var newpassword=$("#newpassword").val();
                if((newpassword=="")||(newpassword=="undefined")){
                    newpassword=oldpassword;
                }
               firstname=firstname.trim();
               if(firstname==""){
                   BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the First Name"
                    });
                    $("#firstname").focus();
                    return;
               }
               lastname=lastname.trim();
               if(lastname==""){
                   BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Last Name"
                    });
                    $("#lastname").focus();
                    return;
               }
               funempmailid();
               funempid();
                if(empid==""){
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Employee Id"
                    });
                    $("#empid").val();
                    $("#empid").focus();
                    return;
                }
                if(empmailid==""){
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Email address"
                    });
                    $("#empmailid").val();
                    $("#empmailid").focus();
                    return;
                }
               country=country.trim();
               if(country==""){
                   BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Choose the Country"
                    });
                    $("#country").focus();
                    return;
               }
               phonenumber=phonenumber.trim();
               if(phonenumber==""){
                   BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Fill the Phone Number"
                    });
                    $("#phonenumber").focus();
                    return;
               }
                var fileUpload = $("#file-input").get(0);
                var files = fileUpload.files;
                if (files.length == 0) {
                    fileisthere="no";
                }
                var formData = new FormData();
                filesd = document.getElementById("file-input").files[0];
                formData.append("updateuser","filesd");
                formData.append("firstname",firstname);
                formData.append("lastname",lastname);
                formData.append("empid",empid);
                formData.append("empmailid",empmailid);
                formData.append("country",country);
                formData.append("phonenumber",phonenumber);
                formData.append("newpassword",newpassword);
                formData.append("oldempmailid",oldempmailid);
                formData.append("oldempid",oldempid);
                formData.append("oldpassword",oldpassword);
                formData.append("oldid",oldid);
                $.ajax({
                    url : "../Control/user.php",
                    type: 'POST',
                    data : formData,
                    cache       : false,
                    contentType : false,
                    processData : false,
                    success:function(respond)
                    {
                        swal("","Photo uploaded Successfully", "success");
                        window.location.replace("all_employee.php");
                    }
                });
            });
        </script>
        
    </body>
    
</html>
    </body>