<?php 
define('DOCUMENT_ROOT_CLASS','../');
define('DOCUMENT_ROOT_INC_FOLDER','');
$filepath = realpath(dirname(__FILE__));
if(!empty($_POST["action"]) and $_POST["action"] == "ajax_call"){ 
    require "../inc/ajax_header.php";
    $state = $_POST["state"];
    $user_id = $_POST["user_id"];
    $action = $_POST["action"];
    $commonFunctions->updateData('sys_erp_adm_user'," WHERE id = '".$_POST['user_id']."' ", "erp_sys_user_isActive = '".$state."' " ,'');
    exit();
}
require "../inc/header.php";
$msg = Session::get('msg');
Session::set("msg", NULL);
if(!empty($_POST['action']) and $_POST['action'] == "profile"){
	$column = $fileName = "";
    if($_FILES["erp_sys_user_logo"]){
        $target_dir = "../uploads/admin-setting/users/";
        $target_file = $target_dir . basename($_FILES["erp_sys_user_logo"]["name"]);
        $uploadOk = 1;
        $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
        @getimagesize($_FILES["erp_sys_user_logo"]["tmp_name"]);
        if(move_uploaded_file($_FILES["erp_sys_user_logo"]["tmp_name"], $target_file)){
            $column = " erp_sys_user_logo";
            $fileName = " erp_sys_user_logo = '".$_FILES["erp_sys_user_logo"]["name"]."' ";
            $commonFunctions->updateData('sys_erp_adm_user'," WHERE id = '".$_POST['user_id']."' ", $fileName ,'users-card.php?user_id='.$_POST['user_id']);
        }
    }else{
    	Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> User profile picture not saved!</div>');
    	echo "<script>location.href='users-card.php?user_id=".$_POST['user_id']."';</script>";
    }
}
if(!empty($_POST['action']) and $_POST['action'] == "reset_password"){
	if(!empty($_POST["password"])){
		$commonFunctions->updateData('sys_erp_adm_user'," WHERE id = '".$_POST['user_id']."' ", ' erp_sys_user_secutiry_password = "'.SHA1($_POST['password']).'" ','users-card.php?user_id='.$_POST['user_id']);
	}else{
		Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter password and confirm password!</div>');
    	echo "<script>location.href='users-card.php?user_id=".$_POST['user_id']."';</script>";
	}
}
$userData = $commonFunctions->getRowData('sys_erp_adm_user'," WHERE id = '".@$_GET['user_id']."' ");
?>
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">	
<style type="text/css">
    .validate_cus{
        color: red;
    }
</style>
    <!-- Page-Title -->
    <div class="row">
        <div class="col-sm-12">
            <div class="page-title-box">
                <div class="row">
                    <div class="col form-row">
                    	<div class="col-sm-9">
                            <h4 class="page-title"><?php echo @$userData['erp_sys_user_name_first']." ".$userData['erp_sys_user_name_middle']." ".$userData['erp_sys_user_name_last'];?></h4>
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="javascript:void(0);">Admin Settings</a></li>
                                <li class="breadcrumb-item"><a href="javascript:void(0);">User Details</a></li>
                            </ol>
                        </div>
                        <div class="col-sm-3">
                            <style type="text/css">
                                .toggle{
                                    height: 30px !important;
                                }
                                .toggle > .toggle-group > .btn{
                                    line-height: 1.5 !important;
                                }
                                .toggle.btn {
                                    min-height: 2.0rem;
                                }
                            </style>
                            <?php $toggle_checked = (@$userData['erp_sys_user_isActive'] == 0)?"checked":"";
                                $state = (@$userData['erp_sys_user_isActive'] == 0)?1:0;
                            ?>
                            <input type="checkbox" id="actionCheck" <?php echo $toggle_checked; ?> data-toggle="toggle" data-on="Active" data-off="In-Active" data-onstyle="success" data-offstyle="danger" >&nbsp;

                            <a href="users.php?state=edit&user_id=<?php echo $userData['id'];?>"><button type="button" class="btn btn-sm btn-outline-primary">Edit</button></a>&nbsp;
                            <a href="users.php?state=list"><button type="button" class="btn btn-sm btn-outline-secondary">Back to Users List</button></a>
                            <!-- <a href="users.php?state=copy&user_id=<?php echo $userData['id'];?>">
                            	<button type="button"class="btn btn-sm btn-outline-dark">Duplicate</button>
                            </a> -->
                            <!-- <button type="button" class="btn btn-sm btn-outline-danger">Delete</button> -->
                        </div>
                    </div><!--end col-->
                </div><!--end row-->                                                              
            </div><!--end page-title-box-->
        </div><!--end col-->
    </div><!--end row-->
    <!-- end page title end breadcrumb -->

    <div class="row">
        <div class="col-12">
            <div class="card">
            	<div class="card-body">
                    <div class="dastone-profile">
                        <div class="row">
                            <div class="col-lg-4 align-self-center mb-3 mb-lg-0">
                                <div class="dastone-profile-main">
                                    <div class="dastone-profile-main-pic">
                                        <img src="../uploads/admin-setting/users/<?php echo (@$userData['erp_sys_user_logo'])?$userData['erp_sys_user_logo']:'default-img.jpg';?>" alt="" height="110" class="thumb-lx rounded" style='max-width:140px;'>
                                        <span class="dastone-profile_main-pic-change">
                                            <i class="fas fa-camera"></i>
                                        </span>
                                        <form enctype="multipart/form-data" method="post" id="fileUploadForm">
                                            <input type="hidden" name="action" value="profile">
                                            <input type="hidden" name="user_id" value="<?php echo $userData['id'];?>">
                                            <input type="file" name="erp_sys_user_logo" value="" style='display: none;' id="fileUpload">
                                        </form>
                                    </div>
                                    
                                </div>                                                
                            </div><!--end col-->
                            <div class="col-lg-4 ml-auto align-self-center">
                                <div class="dastone-profile_user-detail">
                                    <h5 class="dastone-user-name"><?php echo @$userData['erp_sys_user_name_first']." ".$userData['erp_sys_user_name_middle']." ".$userData['erp_sys_user_name_last'];?></h5>
                                    <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i> <b> Designation / Job Title :</b> <?php echo $commonFunctions->getName($userData['erp_sys_user_roleid'],'sys_erp_adm_user_roles','role','id'); ?></p>
                                    <p class="mt-0 mb-0"><i class="text-secondary font-22 align-middle"></i> <b> Branch :</b>  <?php echo $commonFunctions->getName($_SESSION['warehouse_id'],'invty_wrhus','short_name_location','id');?> <?php echo $commonFunctions->getName($_SESSION['warehouse_id'],'invty_wrhus','address','id');?> </p>
                                </div>
                            </div>
                            <div class="col-lg-4 ml-auto align-self-center">
                                <ul class="list-unstyled personal-detail mb-0">
                                    <li class="mt-2"><i class="las la-phone mr-2 text-secondary font-22 align-middle"></i> <b> phone </b> :  <?php echo (@$userData['erp_sys_org_phone_work'])?@$userData['erp_sys_org_phone_work']:"-";?></li>
                                    <li class="mt-2"><i class="las la-mobile mr-2 text-secondary font-22 align-middle"></i> <b> mobile </b> :  <?php echo (@$userData['erp_sys_user_mobile1'])?@$userData['erp_sys_user_mobile1']:"-";?></li>
                                    <li class="mt-2"><i class="las la-envelope text-secondary font-22 align-middle mr-2"></i> <b> Email </b> :   <a href="mailto:<?php echo (@$userData['erp_sys_user_email_work'])?@$userData['erp_sys_user_email_work']:"-";?>"><?php echo (@$userData['erp_sys_user_email_work'])?@$userData['erp_sys_user_email_work']:"-";?></a></li>                                                  
                                </ul>                                               
                            </div><!--end col-->
                            
                            <!-- <div class="col-lg-4 align-self-center">
                                <div class="row">
                                    <div class="col-auto text-right border-right">
                                        <button type="button" class="btn btn-soft-primary btn-icon-circle-sm mb-2">
                                            <i class="fab fa-facebook-f"></i>
                                        </button>
                                        <p class="mb-0 font-weight-semibold">Facebook</p>
                                        <h4 class="m-0 font-weight-bold">0k <span class="text-muted font-12 font-weight-normal">Followers</span></h4>
                                    </div> 
                                    <div class="col-auto">
                                        <button type="button" class="btn btn-soft-info btn-icon-circle-sm mb-2">
                                            <i class="fab fa-twitter"></i>
                                        </button>
                                        <p class="mb-0 font-weight-semibold">Twitter</p>
                                        <h4 class="m-0 font-weight-bold">0k <span class="text-muted font-12 font-weight-normal">Followers</span></h4>
                                    </div>
                                </div>                                               
                            </div> --><!--end col-->
                        </div><!--end row-->
                    </div><!--end f_profile-->                                                                                
                </div>
            </div> 
        </div><!--end col-->
    </div><!--end row-->
    <div class="pb-4">
        <ul class="nav-border nav nav-pills mb-0" id="pills-tab" role="tablist">
            <li class="nav-item">
                <a class="nav-link active" id="user_details_tab" data-toggle="pill" href="#user_details">User Details</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="user_permission_tab" data-toggle="pill" href="#permission">Permission</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="user_security_tab" data-toggle="pill" href="#security">Security</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="user_settings_tab" data-toggle="pill" href="#user_settings">Settings</a>
            </li>
        </ul>        
    </div><!--end card-body-->
    <style type="text/css">
    	label.form-control1 {display: block;}
    	label.label-title {font-weight: 600;}
    </style>
    <div class="row">
        <div class="col-12">
        	<?php echo !empty($msg)?$msg:''; ?>        
            <?php echo !empty($msg1)?$msg1:''; ?>      
            <div class="tab-content" id="pills-tabContent">
                <div class="tab-pane fade show active" id="user_details" role="tabpanel" aria-labelledby="user_details_tab">
                    <div class="row" >
                        <div class="col-lg-6 col-xl-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Personal Information</h4>                      
                                        </div><!--end col-->
                                        <div class="col-1">                      
                                            <a href="users.php?state=edit&user_id=<?php echo $userData['id'];?>"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a>              
                                        </div><!--end col-->                                                       
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                                                          
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">First Name</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_name_first'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Middle Name</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_name_middle'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Last Name</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_name_last'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Designation / Job Title</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $commonFunctions->getName($userData['erp_sys_user_roleid'],'sys_erp_adm_user_roles','role','id'); ?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Reportin Manager</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title">  </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Date of Birth</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title">  </h5>
                                        </div>
                                    </div>                                          
                                </div>                                            
                            </div>
                            <!-- Personal Information Card - End --->
                            <!-- Contact Information Personal Card - End --->
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Contact Information <label class="col-xl-3 col-lg-3 mb-lg-0 align-self-center">( Personal )</label></h4>                      
                                        </div><!--end col-->
                                        <div class="col-1">                      
                                            <!-- <a href="users.php?state=edit&user_id=<?php echo $userData['id'];?>"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a> -->              
                                        </div><!--end col-->                                                       
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                                                          
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Mobile Number</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_mobile2'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Whatsapp Number</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_id_msngr_whatsapp'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Email Address</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_email_personal'];?> </h5>
                                        </div>
                                    </div>                                                   
                                </div><!--end card-body-->
                            </div><!--end card-->
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Social Media </h4>                      
                                        </div><!--end col-->
                                        <div class="col-1">                      
                                            <!-- <a href="users.php?state=edit&user_id=<?php echo $userData['id'];?>"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a> -->              
                                        </div><!--end col-->                                                       
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                                                          
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Linkedin</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_id_sm_linkedin'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Twitter</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_id_sm_twitter'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Facebook</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_id_sm_facebook'];?> </h5>
                                        </div>
                                    </div>                                                    
                                </div><!--end card-body-->
                            </div><!--end card-->
                        </div>
                        <div class="col-lg-6 col-xl-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Contact Information <label class="col-xl-3 col-lg-3 mb-lg-0 align-self-center">( Official )</label></h4>                      
                                        </div><!--end col-->
                                        <div class="col-1">                      
                                            <!-- <a href="users.php?state=edit&user_id=<?php echo $userData['id'];?>"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a> -->              
                                        </div><!--end col-->                                                       
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                                                          
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Mobile Number</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_mobile_work'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Work Phone </label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_org_phone_work'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Work Fax</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_org_fax'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Email Address</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_email_work'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Website / URL</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title">  </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Branch / Warehouse</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $commonFunctions->getName($_SESSION['warehouse_id'],'invty_wrhus','short_name_location','id');?> <?php echo $commonFunctions->getName($_SESSION['warehouse_id'],'invty_wrhus','address','id');?> </h5>
                                        </div>
                                    </div> 
                                </div><!--end card-body-->
                            </div><!--end card-->
                            <div class="card">
                                <div class="card-header">
                                    <div class="row align-items-center">
                                        <div class="col-11">                      
                                            <h4 class="card-title text-left">Office Address </h4>                      
                                        </div><!--end col-->
                                        <div class="col-1">                      
                                            <!-- <a href="users.php?state=edit&user_id=<?php echo $userData['id'];?>"><button type="button" class="text-right btn btn-sm btn-light waves-effect waves-light">Edit</button></a> -->              
                                        </div><!--end col-->                                                       
                                    </div>  <!--end row-->                                  
                                </div><!--end card-header-->
                                <div class="card-body">                                                                          
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Address</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_address'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">City</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_city'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">State / Province</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $commonFunctions->getName(@$userData['erp_sys_user_state'],'sys_erp_adm_countries_states','label','rowid');?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Zip / Pin / PO Box</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo @$userData['erp_sys_user_zipcode'];?> </h5>
                                        </div>
                                    </div>
                                    <div class="form-group row">                                         
                                        <label class="col-xl-3 col-lg-3 text-left mb-lg-0 align-self-center">Country</label>
                                        <div class="col-lg-9 col-xl-8">
                                            <h5 class="card-title"> <?php echo $commonFunctions->getName(@$userData['erp_sys_user_country'],'sys_erp_adm_countries','label','rowid');?> </h5>
                                        </div>
                                    </div>                                                    
                                </div><!--end card-body-->
                            </div><!--end card-->
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="user_settings" role="tabpanel" aria-labelledby="user_settings">
                    <div class="card">
                		<div class="card-body">
                        	3
                    	</div><!--end row-->    
                    </div>
                </div>
                <div class="tab-pane" id="permission" role="tabpanel" aria-labelledby="permission">
                    <div class="card">
                		<div class="card-body">
                        	<?php $moduleData = $commonFunctions->getData('sys_erp_module',''); ?>
                            <table style="margin-top: 10px;width: 100% !important;text-align: center;" class="table datatable_t table-hover table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th class="text-center">SR No#</th>
                                        <th class="text-center">Module Name</th>
                                        <th class="text-center">Permission</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $i = 1;
                                    $role = $commonFunctions->getName($userData['erp_sys_user_roleid'],'sys_erp_adm_user_roles','role','id');
                                    foreach ($moduleData as $row) { 
                                        $modulePermissionData = $commonFunctions->getRowData('sys_erp_adm_user_access_permission',' WHERE module_id = "'.$row['id'].'" AND role_id = "'.@$userData['erp_sys_user_roleid'].'" ');
                                        $display = (@$modulePermissionData["display"] == 1 OR $role == "Super-Admin")?'<span class="badge badge-soft-success"> <i class="fa fa-check"></i> </span>':'<span class="badge badge-soft-danger"> <i class="fa fa-times" style="margin-left: 2px;margin-right: 2px;"></i> </span>';
                                        echo "<tr>";
                                        echo "<td>".$i++."</td>";
                                        echo "<td>".$row["name"]."</td>";
                                        echo "<td>".$display."</td>";
                                        echo "</tr>";
                                    }?>
                                </tbody>
                            </table>
                    	</div><!--end row-->    
                    </div>
                </div>
                <div class="tab-pane" id="security" role="tabpanel" aria-labelledby="user_security_tab">
                    <div class="card">
                		<div class="card-body">
                        	<form id="reset-password-form" action="" method="post" onsubmit="return confirm('Do you want changed your password?')">
                        		<input type="hidden" name="user_id" id="user_id" value="<?php echo $userData['id'];?>" >
                        		<input type="hidden" name="action" value="reset_password">
                        		<div class="form-row">
                            		<div class="col-lg-2"></div>
                            		<div class="col-lg-8">
                            			<div class="form-row">
                                			<div class="form-group searchForm col-md-6">
                                				<label for="password" class="">Password</label>
                                				<input type="password" maxlength="128" name="password" id="password" value="" autofocus="autofocus" class="form-control" placeholder="Password" required="">
                                			</div>
                                			<div class="form-group searchForm col-md-6">
                                				<label for="cnf_password" class="">Confirm Password</label>
                                				<input type="password" maxlength="128" name="cnf_password" id="cnf_password" value="" autofocus="autofocus" class="form-control" placeholder="Confirm Password" required="">
                                                <br>
                                                <input type="checkbox" id="checkview" onclick="myFunction()"> <label for="checkview">Show Password</label>
                                			</div>
                                			<div class="form-group searchForm col-md-12" style="text-align: center;">
                                				<br>
                                				<button type="submit" class="btn btn-primary"> Save </button>
                                				<br>
                                				<br>
                                				<br>
                                			</div>
                                		</div>
                            		</div>
                            		<div class="col-lg-2"></div>
                            	</div>
                        	</form>
                    	</div><!--end row-->    
                    </div>
                </div>

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

        
<?php require "../inc/footer.php"; ?>
<script type="text/javascript" src="https://www.jqueryscript.net/demo/Simple-jQuery-Based-Barcode-Generator-Barcode/jquery-barcode.js"></script>
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
<script type="text/javascript">
    
  	function generateBarcode(){
	    var value = "<?php echo strtolower(@$userData['barcode_value']); ?>";
	    var btype = "<?php echo strtolower(@$barcode_type); ?>";
	    var renderer = "css";
    	var quietZone = false;
	    
	    var settings = {
	      	output:renderer,
	      	bgColor: "#FFFFFF",
	      	color: "#000000",
	      	barWidth: "2",
	     	barHeight: "50",
	      	moduleSize: "5",
	      	posX: "10",
	      	posY: "20",
	      	addQuietZone: "1"
	    };
    	if (renderer == 'canvas'){
      		clearCanvas();
	      	$("#barcodeTarget").hide();
	      	$("#canvasTarget").show().barcode(value, btype, settings);
    	} else {
      		$("#canvasTarget").hide();
      		$("#barcodeTarget").html("").show().barcode(value, btype, settings);
    	}
  	}
      
  	function showConfig1D(){
	    $('.config .barcode1D').show();
	    $('.config .barcode2D').hide();
  	}
  
  	function showConfig2D(){
	    $('.config .barcode1D').hide();
	    $('.config .barcode2D').show();
  	}
  
  	function clearCanvas(){
	    var canvas = $('#canvasTarget').get(0);
	    var ctx = canvas.getContext('2d');
	    ctx.lineWidth = 1;
	    ctx.lineCap = 'butt';
	    ctx.fillStyle = '#FFFFFF';
	    ctx.strokeStyle  = '#000000';
	    ctx.clearRect (0, 0, canvas.width, canvas.height);
	    ctx.strokeRect (0, 0, canvas.width, canvas.height);
  	}
  
  	$(function(){
    	generateBarcode();
  	});
  	$(".dastone-profile_main-pic-change").click(function(){
  		$("#fileUpload").click();
  	});
  	$("#fileUpload").change(function(){
  		if(confirm("Please make sure do you want to change your profile picture?")){
  			$("#fileUploadForm").submit();
  		}else{
  			return false;
  		}
  	});
</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.1/jquery.validate.min.js"></script>
<script type="text/javascript">
	var value = $("#password_reg").val();

$.validator.addMethod("checklower", function(value) {
  return /[a-z]/.test(value);
});
$.validator.addMethod("checkupper", function(value) {
  return /[A-Z]/.test(value);
});
$.validator.addMethod("checkdigit", function(value) {
  return /[0-9]/.test(value);
});
$.validator.addMethod("pwcheck", function(value) {
  return /^[A-Za-z0-9\d=!\-@._*]*$/.test(value) && /[a-z]/.test(value) && /\d/.test(value) && /[A-Z]/.test(value);
});
$('#reset-password-form').validate({
  rules: {
    password: {
      minlength: 6,
      maxlength: 30,
      required: true,
      //pwcheck: true,
      checklower: true,
      checkupper: true,
      checkdigit: true
    },
    cnf_password: {
      equalTo: "#password",
    },
  },
  messages: {
    password: {
      pwcheck: "Password is not strong enough",
      checklower: "Need atleast 1 lowercase alphabet",
      checkupper: "Need atleast 1 uppercase alphabet",
      checkdigit: "Need atleast 1 digit"
    }
  },
  highlight: function(element) {
    var id_attr = "#" + $(element).attr("id") + "1";
    $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
    $(id_attr).removeClass('glyphicon-ok').addClass('glyphicon-remove');
    $('.form-group').css('margin-bottom', '5px');
    $('.form').css('padding', '30px 40px');
    $('.tab-group').css('margin', '0 0 25px 0');
    $('.help-block').css('display', '');
  },
  unhighlight: function(element) {
    var id_attr = "#" + $(element).attr("id") + "1";
    $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
    $(id_attr).removeClass('glyphicon-remove').addClass('glyphicon-ok');
    $('#cnf_password').attr('disabled', false);
  },
  errorElement: 'span',
  errorClass: 'validate_cus error',
  errorPlacement: function(error, element) {
    x = element.length;
    if (element.length) {
      error.insertAfter(element);
    } else {
      error.insertAfter(element);
    }
  },
  /*submitHandler: function(form) {
  	var user_id = $("#user_id").val();
  	$.ajax({
	    type: 'POST',
	    url: "users-card.php?user_id="+user_id,
	    data: {"user_id":user_id,"action":"reset_password","password":$("#password").val()},
	    success: function(resultData) { 
	    	alert("Save Complete") 
	    }
	});
  	return false;
  }*/
});
$("#actionCheck").change(function(){
    state = "<?php echo $state;?>";
    $.ajax({
        type: 'POST',
        url: "",
        data: {"state":state,"user_id":"<?php echo $userData['id'];?>","action":"ajax_call"},
        success: function(resultData) { 
            window.location.href = "";
        }
    });
});
function myFunction() {
  var x = document.getElementById("password");
  if (x.type === "password") {
    x.type = "text";
  } else {
    x.type = "password";
  }

  var x = document.getElementById("cnf_password");
  if (x.type === "password") {
    x.type = "text";
  } else {
    x.type = "password";
  }
}
</script>