<?php include("header.php"); 
$large_img = $site_url.'assets/images/profile_av.svg';
if(isset($emp_list['profile_img']) && !empty($emp_list['profile_img'])){
     $large_img    = $site_url.'dist/assets/profile/'.$emp_list['profile_img'];
}
if(isset($_POST['edit_profile'])){
    $full_name = $_POST['full_name_input'];
    $email = $_POST['email_input'];
    $compnay = $_POST['company_input'];
    $phone = $_POST['phone_input'];
    mysqli_query($conn, "UPDATE db_users SET full_name='".$full_name."', email='".$email."', company_name='".$compnay."', phone='".$phone."' WHERE id=".$_SESSION['loggedin_user']);
    $emp_list   = mysqli_fetch_assoc(mysqli_query($conn, "select * from db_users where id=".$_SESSION['loggedin_user']));
    
    if(!empty($emp_list['profile_img'])){
        $pro_img = $site_url.'dist/assets/profile/'.$emp_list['profile_img'];
    }
    $show_name  = $emp_list['full_name'];
    $show_email = $emp_list['email'];
    $show_phone = $emp_list['phone'];
    $is_admin_login = ($emp_list['type'] == 'admin') ? 1 : 0;
    $curr_user_type = $emp_list['type'];
}
if(isset($_POST['save_new_pwd'])){
    if($_POST['new_pwd'] == $_POST['cnf_pwd']){
        $emp_list = mysqli_query($conn, "UPDATE db_users SET password='".md5($_POST['new_pwd'])."' where id='".$_POST['hidden_user_id']."' ");
        $u_info = get_user_by_id($_POST['hidden_user_id']);
        $msg = 'Hello '.$u_info['full_name'].'<br> You have successfully reset password on '.$site_url.'. <br><br><b>Note:</b> if not reset by you then immediadtly visit site and reset password again to prevent unauthorize access.';
        send_zoho_mail($u_info['email'],"Password reset successfully!!",$msg);
        echo "<script>window.location.href='".$site_url."?signout=1';</script>";
    }
}
if($_FILES["logo-img"]["name"] != '')
{
 
    $fname = basename($_FILES["logo-img"]["name"]);

    $doc_root = $_SERVER['DOCUMENT_ROOT'];
    if(strpos($_SERVER['REQUEST_URI'], 'timesheet_new') !== false) {
        $doc_root = $_SERVER['DOCUMENT_ROOT']."/timesheet_new";
    }
    $rawBaseName = pathinfo($_FILES['logo-img']['name'], PATHINFO_FILENAME );
    $extension = pathinfo($_FILES['logo-img']['name'], PATHINFO_EXTENSION );
    $counter = 0;

    while(file_exists($doc_root."/dist/assets/images/logo/".$fname)) {
        $fname = $rawBaseName . $counter . '.' . $extension;
        $counter++;
    }
    move_uploaded_file($_FILES["logo-img"]["tmp_name"], $doc_root."/dist/assets/images/logo/".$fname);
    mysqli_query($conn, "Update db_users SET company_logo='".$fname."' WHERE id=".$_SESSION['loggedin_user']);

}
if($_FILES["profile-img"]["name"] != '')
{
 
    $fname = basename($_FILES["profile-img"]["name"]);

    $doc_root = $_SERVER['DOCUMENT_ROOT'];
    if(strpos($_SERVER['REQUEST_URI'], 'timesheet_new') !== false) {
        $doc_root = $_SERVER['DOCUMENT_ROOT']."/timesheet_new";
    }
    $rawBaseName = pathinfo($_FILES['profile-img']['name'], PATHINFO_FILENAME );
    $extension = pathinfo($_FILES['profile-img']['name'], PATHINFO_EXTENSION );
    $counter = 0;

    while(file_exists($doc_root."/dist/assets/profile/".$fname)) {
        $fname = $rawBaseName . $counter . '.' . $extension;
        $counter++;
    }
    move_uploaded_file($_FILES["profile-img"]["tmp_name"], $doc_root."/dist/assets/profile/".$fname);
    mysqli_query($conn, "Update db_users SET profile_img='".$fname."' WHERE id=".$_SESSION['loggedin_user']);

}
if(isset($_POST['delete_profile_img']) && $_POST['delete_profile_img'] == 1){
    mysqli_query($conn, "Update db_users SET profile_img='' WHERE id=".$_SESSION['loggedin_user']);
}



/*$img = $_FILES["image"]["name"];
$tmp = $_FILES["image"]["tmp_name"];*/


$get_companies = mysqli_query($conn, "select * from db_users where type='company' ");


?>

            <!-- Body: Body -->
            <div class="body d-flex py-3">
                <div class="container-xxl">
                    <div class="row align-items-center">
                        <div class="border-0 mb-4">
                            <div class="card-header py-3 no-bg bg-transparent d-flex align-items-center px-0 justify-content-between border-bottom flex-wrap">
                                <h3 class="h4 mb-0">Profile</h3>
                            </div>
                        </div>
                    </div> <!-- Row end  -->
                    <div class="row g-3 mb-3">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-body">
                                    <div class="row g-3">
                                        <div class="col-md-12 col-lg-3">
                                            <div class="profile-data">
                                                <img src="<?=  $large_img; ?>" class="img-thumbnail profile-img-output" alt="...">
                                                <div class="action-list">
                                                    <input type="file" name="profile-img" class="profile-img" style="display:none;" onchange='changeFile(event)'>
                                                <i class="icofont-pencil-alt-2 edit-pro-img"></i>
                                                <i class="icofont-close-circled delete-pro-img"></i>

                                            </div>
                                        </div>
                                            <ul class="list-unstyled custom d-flex mb-3 mt-3">
                                                <li class="me-3"><a href="#" class="card-link"><i class="fa-brands fa-facebook-f"></i></a></li>
                                                <li class="me-3"><a href="#" class="card-link"><i class="fa-brands fa-twitter"></i></a></li>
                                                <li class="me-3"><a href="#" class="card-link"><i class="fa-brands fa-instagram"></i></a></li>
                                            </ul>
                                        </div>
                                        <div class="col-md-12 col-lg-6 company-contact">
                                            <h4><?= $show_name; ?></h4>
                                            <div class="d-flex flex-row flex-wrap align-items-center mb-3 mt-2">
                                                <!-- <div class="me-3 me-md-5">
                                                    <small class="text-muted">Education</small>
                                                    <div class="mb-0 fw-bold">MCA</div>
                                                </div>
                                                <div class="me-3 me-md-5">
                                                    <small class="text-muted">Experience</small>
                                                    <div class="mb-0 fw-bold">8+</div>
                                                </div>
                                                <div>
                                                    <small class="text-muted">City</small>
                                                    <div class="mb-0 fw-bold">London</div>
                                                </div> -->
                                            </div>
                                            <span><?= $emp_list['description']; ?></span>
                                            <ul class="design-box ps-0">
                                                <!-- <li>
                                                    <div class="icon text-center">
                                                        <i class="fa fa-map-marker text-secondary"></i>
                                                    </div>
                                                    <div class="fw-bold mb-0">Address</div>
                                                    <span>Trinity Rd, Gravesend	Kent, DA12 1LU</span>
                                                </li> -->
                                                <li>
                                                    <div class="icon text-center">
                                                        <i class="fa fa-mobile text-secondary"></i>
                                                    </div>
                                                    <div class="fw-bold mb-0">Mobile</div>
                                                    <span><?= $show_phone; ?></span>
                                                </li>
                                                <li>
                                                    <div class="icon text-center">
                                                        <i class="fa fa-envelope text-secondary"></i>
                                                    </div>
                                                    <div class="fw-bold mb-0">Email Address</div>
                                                    <span><?= $show_email; ?></span>
                                                </li>
                                            </ul>
                                        </div>
                                        <div class="col-md-12 col-lg-3 logo-section">
                                            <?php 
                                            
                                           
                                                if($emp_list['type'] == 'company'){
                                                    $logo_url = !empty($emp_list['company_logo']) ? $site_url.'dist/assets/images/logo/'.$emp_list['company_logo'] : "";
                                                    
                                                    echo "<h3>Company Info</h3><img src='".$logo_url."' id='output' style='width: 100px;'><br><label>Company Logo:</label><input type='file' name='logo-img' id='logo-img' value='Upload Logo' style='width:100%;' onchange='loadFile(event)' accept='image/gif,image/png,image/jpg,image/jpeg,image/svg'><br><small>(Note : allowed only this file types .gif, .png, .jpg, .jpeg, .svg)</small><div class='group'><label>Company Name:</label><input type='text' disabled name='comp_name' value='".$emp_list['username']."'></div>";
                                                }
                                            ?>
                                        </div>
                                    </div>       
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row g-3">
                        <div class="col-12">
                            <ul class="nav nav-tabs tab-body-header rounded d-inline-flex">
                                <li class="nav-item"><a class="nav-link active show" data-bs-toggle="tab" href="#Company_Settings">Edit Profile</a></li>
                                 <li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#Notifications">Notifications </a></li>
                                <!-- <li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#Change_Password">Change Password </a></li>  -->
                            </ul>
                            <div class="tab-content mt-3">
                                <div class="tab-pane active show" id="Company_Settings">
                                    <div class="card mb-3">
                                        <div class="card-header p-3">
                                            <h5 class="card-title">Profile Settings</h5>
                                        </div>
                                        <div class="card-body">
                                            <form class="row g-3" method="post">
                                                <div class="col-md-4 col-sm-12">
                                                    <div class="form-group">
                                                        <label class="form-label">Name <span class="text-danger">*</span></label>
                                                        <input class="form-control" type="text" name="full_name_input" value="<?= $show_name; ?>" disabled>
                                                    </div>
                                                </div>
                                                <!-- <div class="col-md-4 col-sm-12">
                                                    <div class="form-group">
                                                        <label class="form-label">Contact Person</label>
                                                        <input class="form-control" value="" type="text">
                                                    </div>
                                                </div> -->
                                                <!-- <div class="col-md-4 col-sm-12">
                                                    <div class="form-group">
                                                        <label class="form-label">Mobile Number <span class="text-danger">*</span></label>
                                                        <input class="form-control" value="" type="text">
                                                    </div>
                                                </div> -->
                                                <!-- <div class="col-12">
                                                    <div class="form-group">
                                                        <label class="form-label">Address</label>
                                                        <textarea class="form-control" placeholder="44 Shirley Ave. West Chicago, IL 60185" aria-label="With textarea"></textarea>
                                                    </div>
                                                </div> -->
                                                <div class="col-md-6 col-sm-12">
                                                    <label class="form-label">Email <span class="text-danger">*</span></label>
                                                    <div class="input-group">
                                                        <span class="input-group-text">@</span>
                                                        <input type="text" class="form-control" name="email_input" value="<?= $show_email; ?>" disabled>
                                                    </div>
                                                </div>
                                                <!-- <div class="col-md-6 col-sm-12">
                                                    <label class="form-label">Website Url</label>
                                                    <div class="input-group">
                                                        <span class="input-group-text">http://</span>
                                                        <input type="text" class="form-control" value="">
                                                    </div>
                                                </div> -->
                                                
                                                <!-- <div class="col-sm-6 col-md-6 col-lg-3">
                                                    <div class="form-group">
                                                        <label class="form-label">State/Province</label>
                                                        <select class="form-control">
                                                            <option>California</option>
                                                            <option>Alaska</option>
                                                            <option>Alabama</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="col-sm-6 col-md-6 col-lg-3">
                                                    <div class="form-group">
                                                        <label class="form-label">City</label>
                                                        <input class="form-control" value="London" type="text">
                                                    </div>
                                                </div>
                                                <div class="col-sm-6 col-md-6 col-lg-3">
                                                    <div class="form-group">
                                                        <label class="form-label">Postal Code</label>
                                                        <input class="form-control" value="99444" type="text">
                                                    </div>
                                                </div> -->
                                                <div class="col-sm-6" style="display: none;">
                                                    
                                                    <div class="form-group">
                                                        <label class="form-label">Company Name</label>
                                                        <select name="company_input" class="form-control">
                                                            <option value="">Select Company</option>
                                                            <?php 
                                                                foreach ($get_companies as $single_comp) {
                                                                    $sel = ($emp_list['company_name'] == $single_comp['id']) ? "selected" : "";
                                                                   echo '<option value="'.$single_comp['id'].'" '.$sel.'>'.$single_comp['full_name'].'</option>';
                                                                }
                                                            ?>
                                                        </select>
                                                        <!-- <input class="form-control" name="company_input" value="<?= $get_company['full_name']; ?>" type="text" name="company_name"> -->
                                                    </div>
                                                </div>
                                                <div class="col-sm-6">
                                                    <div class="form-group">
                                                        <label class="form-label">Phone Number</label>
                                                        <input class="form-control" name="phone_input" value="<?= $show_phone; ?>" type="tel" min="0" max="10" required>
                                                    </div>
                                                </div>
                                                <p><u class="reset_u" data-id="<?= $_SESSION['loggedin_user']; ?>" style="cursor: pointer;">Reset Password here</u></p>
                                               <!--  <div class="col-sm-6">
                                                    <div class="form-group">
                                                        <label class="form-label">Fax</label>
                                                        <input class="form-control" value="902-855-8888" type="text">
                                                    </div>
                                                </div> -->
                                                <div class="col-12 mt-4">
                                                    <button type="submit" name="edit_profile" class="btn btn-primary">SAVE</button>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane" id="Notifications">
                                    <div class="card">
                                        <div class="card-header p-3">
                                            <h5 class="card-title">Notifications Settings</h5>
                                        </div>
                                        <div class="card-body">
                                            <ul class="list-unstyled list-group list-group-custom list-group-flush mb-0">
                                                
                                                <li class="list-group-item px-0 py-3">
                                                    <div class="form-check form-switch">
                                                        <input class="form-check-input" type="checkbox" value="" id="ns-2">
                                                        <label class="form-check-label" for="ns-2">
                                                            Anyone seeing my profile page
                                                        </label>
                                                    </div>
                                                </li>
                                               
                                                <li class="list-group-item px-0 py-3">
                                                    <div class="form-check form-switch">
                                                        <input class="form-check-input" type="checkbox" value="" id="ns-4">
                                                        <label class="form-check-label" for="ns-4">
                                                            Anyone send me a message
                                                        </label>
                                                    </div>
                                                </li>
                                                
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane" id="Change_Password">
                                    <div class="card">
                                        <div class="card-header p-3">
                                            <h5 class="card-title">Change Password</h5>
                                        </div>
                                        <div class="card-body">
                                            <div class="row g-3">
                                                <div class="col-lg-4 col-md-12">
                                                    <div class="form-group">
                                                        <input type="text" class="form-control" value="Johnquinn" disabled="" placeholder="Username">
                                                    </div>
                                                </div>
                                                <div class="col-lg-4 col-md-12">
                                                    <div class="form-group">
                                                        <input type="email" class="form-control" value="" placeholder="Email">
                                                    </div>
                                                </div>
                                                <div class="col-lg-4 col-md-12">
                                                    <div class="form-group">
                                                        <input type="text" class="form-control" placeholder="Phone Number">
                                                    </div>
                                                </div>
                                                <div class="col-12">
                                                    <h6 class="border-top pt-2 mt-3 mb-3">Change Password</h6>
                                                    <div class="mb-2">
                                                        <input type="password" class="form-control" placeholder="Current Password">
                                                    </div>
                                                    <div class="mb-2">
                                                        <input type="password" class="form-control" placeholder="New Password">
                                                    </div>
                                                    <div class="mb-2">
                                                        <input type="password" class="form-control" placeholder="Confirm New Password">
                                                    </div>
                                                </div>
                                                <div class="col-12 mt-4">
                                                    <button type="button" class="btn btn-primary">SAVE</button> &nbsp;
                                                    <button type="button" class="btn btn-default">CANCEL</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="clearfix">
              <div class="spinner-border float-right" role="status" style="display: none;">
                <span class="sr-only">Loading...</span>
              </div>
            </div>
            <div class="modal fade" id="reset_password" tabindex="-1"  aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered modal-lg modal-dialog-scrollable">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title  fw-bold" id="createprojectlLabel"> Reset Password</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body"> 
                        
                             <form name="f2" method="POST">
                                <div class="mb-3">
                                    <label for="FormNewPwd" class="form-label">New Password</label>
                                    <input type="password" name="new_pwd" class="form-control" id="FormNewPwd" placeholder="New Password Here" required="" onkeyup="checkPasswordStrength(this);">
                                    <i class="icofont-eye pwd-toggle"></i>
                                    <div id="password-strength-status"></div>
                                </div>

                                <div class="mb-3">
                                    <label for="formConfirmPwd" class="form-label">Confirm Password</label>
                                    <input class="form-control" name="cnf_pwd" type="password" id="formConfirmPwd" placeholder="Confirm Password Here" required="" onkeyup="checkPasswordStrength(this);">
                                    <i class="icofont-eye pwd-toggle"></i>
                                    <div id="password-strength-status"></div>
                                </div>
                          
                            <input type="hidden" name="hidden_user_id" value="<?= $_SESSION['loggedin_user']; ?>">
                            <input type="submit" name="save_new_pwd" class="save_new_pwd" style="display: none;">
                           
                            </form>
                        </div>
                        <div class="modal-footer">
                            <!-- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Done</button> -->
                            <button type="submit" class="btn btn-primary" name="update_profile" onclick="$('.save_new_pwd').click();"> Save</button>
                            <button type="button" class="btn btn-primary clear-btn">Clear</button>
                        </div> 
                    </div>  
                </div>
            </div>

<?php include("footer.php"); ?>
<style type="text/css">
    .spinner-border.float-right {
        position: fixed;
        top: 45%;
        right: 50%;
        z-index: 999999;
    }
    .profile-data:hover img {
        opacity: 0.8;
    }
    .logo-section h3 {
        font-size: 24px;
        margin-bottom: 15px;
    }
    .logo-section img {
        max-width: 60px;
        width: 100%;
    }
    .logo-section label {
        padding: 10px 0;
    }
    .group label {
        padding-right: 15px;
    }
    .group input {
        padding: 4px 10px;
        border-radius: 5px;
        border: 1px solid #dee2e6;
    }
    .profile-data {
        position: relative;
        max-width: 285px;
        width: 100%;
    }
    .action-list {
        position: absolute;
        top:7px;
        right: 0px;
        display: none;
        cursor: pointer;
    }
    .profile-data:hover .action-list {
        display: block;
    }
    .action-list i {
        font-size:20px;
        padding-right:6px;
    }

    @media (max-width:1199px) {
        .group input {
        width: 100%;
    }
    .logo-section h3 {
        font-size: 22px;
        margin-bottom: 10px;
    }
    }

    @media (max-width:991px){
        .col-md-12.col-lg-6.company-contact {
        flex: 0 0 60%;
        width: 60%;
    }
        .col-md-12.col-lg-3.logo-section {
        flex: 0 0 40%;
        width: 40%;
    }
    }
    @media (max-width:575px){
        .col-md-12.col-lg-6.company-contact {
        flex: 0 0 100%;
        width: 100%;
    }
        .col-md-12.col-lg-3.logo-section {
        flex: 0 0 100%;
        width: 100%;
    }
    .group input {
        width: auto;
    }
    }
    .form-control[name="password"], .form-control[name="cnf_pwd"], .form-control[name="new_pwd"] {
                width: 94%;
                display: inline-block;
                border-right: 0px;
                border-radius: 0.25rem 0px 0px 0.25rem;
            }
            i.pwd-toggle {
                padding: 11px 6px 9px 0px;
                cursor: pointer;
                background: #fff;
                margin-left: -5px;
                border: 1px solid #f0f0f0;
                border-left: 0px;
                border-radius: 0px 0.25rem 0.25rem 0px;
            }
            .form-control:focus + i.pwd-toggle {
                /* box-shadow: 0 0 10px rgb(33 37 41 / 15%); */
                background-color: var(--card-color);
                border-color: var(--primary-color);
            }
            @media(max-width:768px){
                .form-control[type="Password"] {
                width: 94% !important;
            }
            }
</style>
<script>

  var loadFile = function(event) {
    var output = document.getElementById('output');
    var name = document.getElementById("logo-img").files[0].name;
    var form_data = new FormData();
    var ext = name.split('.').pop().toLowerCase();

      if(jQuery.inArray(ext, ['gif','png','jpg','jpeg', 'svg']) == -1) 
      {
       alert("Invalid Image File");
       return false;
      }
        output.src = URL.createObjectURL(event.target.files[0]);
        $(".company-logo").attr("src",URL.createObjectURL(event.target.files[0]));
        output.onload = function() {
            URL.revokeObjectURL(output.src) // free memory
      

          form_data.append("logo-img", document.getElementById('logo-img').files[0]);
           $.ajax({
            url:window.location.pathname,
            method:"POST",
            data: form_data,
            contentType: false,
            cache: false,
            processData: false,
            beforeSend:function(){
            // $('#uploaded_image').html("<label class='text-success'>Image Uploading...</label>");
            },   
            success:function(data)
            {
             $('#uploaded_image').html(data);
            }
           });
    }
  };
  var changeFile = function(event){
    document.querySelector('.profile-img-output')[0];
    var f_name = event.target.files[0].name;
    var form_data = new FormData();
    var ext = f_name.split('.').pop().toLowerCase();

      if(jQuery.inArray(ext, ['gif','png','jpg','jpeg', 'svg']) == -1) 
      {
       alert("Invalid Image File");
       return false;
      }
        $(".spinner-border").show();
      
        $(".profile-img-output").attr("src",URL.createObjectURL(event.target.files[0]));
        $(".profile-img-output")[0].onload = function() {
            URL.revokeObjectURL(output.src) // free memory
            form_data.append("profile-img", event.target.files[0]);
            $.ajax({
                url:window.location.pathname,
                method:"POST",
                data: form_data,
                contentType: false,
                cache: false,
                processData: false,
                beforeSend:function(){
                
                },   
                success:function(data)
                {
                    $(".spinner-border").hide();
                 //$('#uploaded_image').html(data);
                }
            });
        }

  }
  $(document).on("click", ".edit-pro-img", function(){
    $('.profile-img').click();
  });
  $(document).on("click", ".delete-pro-img", function(){
    if(confirm("Are you sure?")){
        $(".spinner-border").show();
        $(".profile-img-output").attr("src",'<?= $site_url.'assets/images/profile_av.svg'; ?>');
        $.ajax({
            url:window.location.pathname,
            method:"POST",
            data:{delete_profile_img:1},   
            success:function(data){
                $(".spinner-border").hide();
            }
        });
    }
    
    
  });
  $(document).on('click', '.reset_u', function(){
    $("#reset_password").modal('show');
    $("#reset_password input[name='hidden_user_id']").val($(this).attr('data-id'));
});
$(document).on("click", ".pwd-toggle", function(){
        var cur_type = $(this).prev('input').attr('type');
        if(cur_type == 'password'){
            $(this).prev('input').attr('type','text');
            $(this).removeClass('icofont-eye');
            $(this).addClass('icofont-eye-blocked');
        } else {
            $(this).prev('input').attr('type','password');
            $(this).removeClass('icofont-eye-blocked');
            $(this).addClass('icofont-eye');
            
        }
        });
        function checkPasswordStrength(curr) {
            var number = /([0-9])/;
            var alphabets = /([a-zA-Z])/;
            var special_characters = /([~,!,@,#,$,%,^,&,*,-,_,+,=,?,>,<])/;
            var password = $(curr).val().trim();
            if (password.length < 6) {
                $(curr).closest("div").find('#password-strength-status').removeClass();
                $(curr).closest("div").find('#password-strength-status').addClass('weak-password');
                $(curr).closest("div").find('#password-strength-status').html("Weak (should be atleast 6 characters.)");
            } else {
                if (password.match(number) && password.match(alphabets) && password.match(special_characters)) {
                    $(curr).closest("div").find('#password-strength-status').removeClass();
                    $(curr).closest("div").find('#password-strength-status').addClass('strong-password');
                    $(curr).closest("div").find('#password-strength-status').html("Strong");
                    return true;
                }
                else {
                    $(curr).closest("div").find('#password-strength-status').removeClass();
                    $(curr).closest("div").find('#password-strength-status').addClass('medium-password');
                    $(curr).closest("div").find('#password-strength-status').html("Medium (should include alphabets, numbers and special characters.)");
                }
            }
            return false;
        }
        $(document).on("submit", "form[name='f2']", function(e){
            var pass = 0;
            if(!checkPasswordStrength($("input[name='new_pwd']"))){
                e.preventDefault();
                alert("Password Must be strong.");
                
                return false;
            } else { pass += 1; }
            if(!checkPasswordStrength($("input[name='cnf_pwd']"))){
                e.preventDefault();
                
                alert("Password Must be strong.")
                return false;
            } else { pass += 1; }

            if(pass >= 2){
                return true;
            }
        });
</script>