<?php
require_once("../layouts/members/head.php");
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
?>



<?php
if (isset($_POST['editMember']) && $user_data['user_id'] > 0) {
    $fields = ['name', 'company', 'mobile', 'email', 'aadhaar', 'pan', 'usertype', 'status', 'parent_id', 'user_id'];
    $services = ['pan_service', 'pandetils_service', 'aadhar_service', 'dl_pdf_service', 'rationpdf_service', 'vehical_service', 'voter_service',
                 'aadhar_fingerPrint_service', 'aadhar_manual_service', 'aadhar_Verify_service', 'eid_Status_service', 'aadhar_to_maskpan_service',
                 'pan_to_maskuid_service', 'aadhar_to_panLink_service', 'pan_print_service', 'Rc_pdf_services', 'challan_Check_Service', 
                 'ration_to_pdf_Service', 'dl_find_service', 'rationto_uid_find_service', 'uid_ration_pdf_Service', 'voter_advance_Service', 
                 'voter_Manual_Service', 'voter_Mobile_Link_Service', 'voter_Pdf_Service', 'recharge_active', 'll_service', 'eshram_services',
                 'ayushman_service','rtps_service','janaadhar_service','familyid_service','farmer_services','electricBill_services','aadhar_otp_service',
                 'pan2uid_find_service','npci_service','vehical_rc_father_find_Service','mobile_dth_recharge_services','psa_active','janaadhar_member_details_services',
                 'dl_mobile_find_services','chassis2rc_services','learning_pdf_services','learning_find_services'
                 ];

    $fees = ['aadhar_advance_fee', 'aadhar_manual_print_fee', 'pan_card_print_fee', 'aadhar_verify_fee', 'challan_fee', 'dl_pdf_fee', 
             'enrollment_status_fee', 'ration_pdf_fee', 'pan_find_fee', 'pandetils_fee', 'pan_uid_status_fee', 'pan_to_mask_uid_fee',
             'dl_find_fee', 'rationto_uid_find_fee', 'ifsc_verify_fee', 'pincode_verify_fee', 'mobile_verify_fee', 'vehical_rc_fee',
             'voter_advance_fee', 'voter_mobile_link_fee', 'voter_pdf_fee', 'll_apply_fee', 'uid_to_details_fee', 'eshram_print_fee',
             'ayushman_fee','rtps_br_price','janaadhar_fee','janaadhar_find_fee','familid_fee','dbt_farmer_fee','electricBill_fee',
             'agriFarmer_fee','Agrifarmer_Status_fee','aadhar_otp_fee','janaadhar_status_fee','pan2uid_find_fee','npci_link_status_fee',
             'vehical_rc_father_find_fee','rationto_uid_find_all_fee','pan_apply_fee','janaadhar_member_details_fee', 'dl_mobile_find_fee',
             'chassis2rc_fee','learning_find_fee','learning_pdf_fee','min_balance'
             ];

    foreach (array_merge($fields, $services, $fees) as $f) $$f = $_POST[$f] ?? '';

    // Minimal validation
    if ($name && $company && $mobile && $email && $aadhaar && $pan && $user_id) {

        $condition = ($user_data['user_id'] == 1) ? 
            "user_id='$user_id'" : 
            (($user_data['usertype'] == 'White Label') ? 
            "user_id='$user_id' AND site_id='".$site_data['site_id']."'" : 
            "user_id='$user_id' AND parent_id='".$user_data['user_id']."'");

        if ($old_member = db_fetch_array("members", $condition)) {

            $parent_id = ($user_data['user_id'] == 1) ? $parent_id : $old_member['parent_id'];
            $parent = db_fetch_array("members", "user_id='$parent_id' AND usertype!='Retailer'");

            if ($parent && is_access_usertype($user_data, $usertype)) {
                $insData = [
                    'name' => $name,
                    'company' => $company,
                    'mobile' => $mobile,
                    'email' => $email
                ];

                if ($user_data['user_id'] == 1) {
                    $insData['usertype'] = $usertype;
                    $insData['status'] = $status;
                    $insData['aadhaar'] = $aadhaar;
                    $insData['pan'] = $pan;
                    $insData['parent_id'] = $parent['user_id'];
                    $insData['parent_uid'] = $parent['username'];

                    foreach ($services as $key) {
                        $insData[$key] = ($_POST[$key] ?? '') == '1' ? 'YES' : 'NO';
                    }
                    foreach ($fees as $key) {
                        $insData[$key] = safe_str($_POST[$key] ?? '');
                    }
                }

                if (db_update("members", $insData, "user_id='".$old_member['user_id']."'")) {
                    awal_alert_msg("Member Updated Successfully!", 'success');
                } else {
                    awal_alert_msg("No Any Changes!", 'info');
                }

            } else {
                awal_alert_msg("UserType Not Access!", 'error');
            }

        } else {
            awal_alert_msg("User Not Found!", 'error');
        }

    } else {
        awal_alert_msg("Please Fill All Valid Details!", 'error');
    }
}
?>


<?php
if(isset($_POST['transferBalance'])){

$user_id = safe_str($_POST['user_id']);
$transfertype = strtolower(safe_str($_POST['transfertype']));
$amount = safe_str($_POST['transferamount']);
$ref_id = safe_str($_POST['ref_id']);

$reportData = db_fetch_array("reports", " ref_id='".$ref_id."' ");
if(empty($reportData['id'])){

$userData = db_fetch_array("members", " user_id='".$user_id."' ");
if($userData['user_id']>0){

// Credit
if($transfertype=="credit"){

if($user_data['balance']>=$amount){

$order_id = order_txn_id();
$old_balance = $user_data['balance'];
$new_balance = $old_balance - $amount;

$insData = array();
$insData['site_id'] = $site_data['site_id'];
$insData['user_id'] = $user_data['user_id'];
$insData['username'] = $user_data['username'];
$insData['parent_id'] = $user_data['parent_id'];
$insData['order_id'] = $order_id;
$insData['service'] = "WALLET";
$insData['type'] = "Debit";
$insData['account_number'] = $userData['mobile'];
$insData['operator'] = "WalletTransfer";
$insData['amount'] = $amount;
$insData['main_amount'] = $amount;
$insData['old_balance'] = $user_data['balance'];
$insData['new_balance'] = $new_balance;
$insData['txn_id'] = $order_id;
$insData['ref_id'] = $ref_id;
$insData['description'] = "Rs.{$amount} Has Been Debit and Transfer To {$userData['username']} for Wallet";
$insData['date_time'] = current_timestamp();
$insData['status'] = "Success";
if(db_insert("reports", $insData)){
db_update("members", ["balance"=>$new_balance], " user_id='".$user_data['user_id']."' ");

$old_balance = $userData['balance'];
$new_balance = $old_balance + $amount;

$insData = array();
$insData['site_id'] = $site_data['site_id'];
$insData['user_id'] = $userData['user_id'];
$insData['username'] = $userData['username'];
$insData['parent_id'] = $userData['parent_id'];
$insData['order_id'] = order_txn_id();
$insData['service'] = "WALLET";
$insData['type'] = "Credit";
$insData['account_number'] = $user_data['mobile'];
$insData['operator'] = "WalletReceived";
$insData['amount'] = $amount;
$insData['main_amount'] = $amount;
$insData['old_balance'] = $user_data['balance'];
$insData['new_balance'] = $new_balance;
$insData['txn_id'] = $order_id;
$insData['ref_id'] = $ref_id;
$insData['description'] = "Rs.{$amount} Has Been Received Into Wallet By {$user_data['username']} for Wallet";
$insData['date_time'] = current_timestamp();
$insData['status'] = "Success";
if(db_insert("reports", $insData)){
db_update("members", ["balance"=>$new_balance], " user_id='".$userData['user_id']."' ");
alert_msg("Rs.{$amount} Credit Successfully","success");
}else{
alert_msg('Wallet Credit Error!','danger');  
}

}else{
alert_msg('Wallet Debit Error!','danger');  
}


}else{
alert_msg('Insufficient Your Wallet Balance!','danger');  
}


}


// Debit
if($transfertype=="debit" && in_array($user_data['user_id'], ['1'])){

if($userData['balance']>=$amount){

$order_id = order_txn_id();
$old_balance = $userData['balance'];
$new_balance = $old_balance - $amount;

$insData = array();
$insData['site_id'] = $site_data['site_id'];
$insData['user_id'] = $userData['user_id'];
$insData['username'] = $userData['username'];
$insData['parent_id'] = $userData['parent_id'];
$insData['order_id'] = $order_id;
$insData['service'] = "WALLET";
$insData['type'] = "Debit";
$insData['account_number'] = $userData['mobile'];
$insData['operator'] = "WalletTransfer";
$insData['amount'] = $amount;
$insData['main_amount'] = $amount;
$insData['old_balance'] = $userData['balance'];
$insData['new_balance'] = $new_balance;
$insData['txn_id'] = $order_id;
$insData['ref_id'] = $ref_id;
$insData['description'] = "Rs.{$amount} Has Been Debit By {$user_data['username']} for Wallet";
$insData['date_time'] = current_timestamp();
$insData['status'] = "Success";
if(db_insert("reports", $insData)){
db_update("members", ["balance"=>$new_balance], " user_id='".$userData['user_id']."' ");

$old_balance = $user_data['balance'];
$new_balance = $old_balance + $amount;

$insData = array();
$insData['site_id'] = $site_data['site_id'];
$insData['user_id'] = $user_data['user_id'];
$insData['username'] = $user_data['username'];
$insData['parent_id'] = $user_data['parent_id'];
$insData['order_id'] = order_txn_id();
$insData['service'] = "WALLET";
$insData['type'] = "Credit";
$insData['account_number'] = $user_data['mobile'];
$insData['operator'] = "WalletReceived";
$insData['amount'] = $amount;
$insData['main_amount'] = $amount;
$insData['old_balance'] = $user_data['balance'];
$insData['new_balance'] = $new_balance;
$insData['txn_id'] = $order_id;
$insData['ref_id'] = $ref_id;
$insData['description'] = "Rs.{$amount} Has Been Credit From {$userData['username']} for Wallet";
$insData['date_time'] = current_timestamp();
$insData['status'] = "Success";
if(db_insert("reports", $insData)){
db_update("members", ["balance"=>$new_balance], " user_id='".$user_data['user_id']."' ");
alert_msg("Rs.{$amount} Debit Successfully","success");
}else{
alert_msg('Wallet Credit Error!','danger');  
}
}else{
alert_msg('Wallet Debit Error!','danger');  
}
}else{
alert_msg('Insufficient Member Wallet Balance!','danger');  
}
}
}else{
alert_msg('Member Not Found!','danger');  
}
}else{
alert_msg("Duplicate Reference Number!",'danger'); 
}

}
?>


<?php
if(isset($_POST['resetpassword']) && $user_data['user_id']>0){

$user_id = real_escape_string($_POST['user_id']);
if(!empty($user_id)){

if(in_array($user_data['usertype'], ['Admin','White Label'])){

if (in_array($user_data['user_id'], ['1']) && in_array($user_data['usertype'], ['Admin'])){
$condition = " user_id='".$user_id."' ";
}else if(in_array($user_data['usertype'], ['White Label'])){
$condition = " user_id='".$user_id."' && site_id='".$site_data['site_id']."' "; 
}

$old_member = db_fetch_array("members",$condition);
if($old_member['user_id']>0 && $old_member['usertype']!="Admin"){
$password = generateNumericOTP(6);
$insData = array();
$insData['password'] = $password;
if(db_update("members", $insData, " user_id='".$old_member['user_id']."' AND usertype!='Admin' ")){	
$message = "Dear {$old_member['name']}, Your Login Username: {$old_member['username']} and New Password: {$old_member['password']}, Login https://".baseurl();    
send_sms_credentials($old_member['mobile'],$message);
send_email($old_member['email'],"User Login Deatils",$message); 	
awal_alert_msg("Password Reset Successfully!",'success','');  
}else{
awal_alert_msg("Server Error!",'info');
}
}else{
awal_alert_msg("Member Not Found!",'error');
}
}else{
awal_alert_msg("Access Denied!",'error');
}
}else{
awal_alert_msg("Error!",'error');
}
}
?>



<?php
if(isset($_POST['remove']) && in_array($user_data['user_id'], ['1'])){

$user_id = real_escape_string($_POST['user_id']);
if(!empty($user_id)){

if(in_array($user_data['usertype'], ['Admin','White Label'])){

if (in_array($user_data['user_id'], ['1']) && in_array($user_data['usertype'], ['Admin'])){
$condition = " user_id='".$user_id."' ";
}else if(in_array($user_data['usertype'], ['White Label'])){
$condition = " user_id='".$user_id."' && site_id='".$site_data['site_id']."' "; 
}

$old_member = db_fetch_array("members",$condition);
if($old_member['user_id']>0 && $old_member['usertype']!="Admin"){
if(db_delete("members"," user_id='".$old_member['user_id']."' AND usertype!='Admin' ")){
awal_alert_msg("Member Delete Successfully!",'success','');  
}else{
awal_alert_msg("Server Error!",'info');
}
}else{
awal_alert_msg("Member Not Found!",'error');
}
}else{
awal_alert_msg("Access Denied!",'error');
}
}else{
awal_alert_msg("Error!",'error');
}

}
?>
<style>
    .card {
      border-radius: 10px;
      backdrop-filter: blur(5px); /* Adds a subtle blur effect */
      -webkit-backdrop-filter: blur(5px); /* For Safari compatibility */
      transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    }

    .card:hover {
      transform: translateY(-5px);
      box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);
    }

    .card-title {
      font-size: 14px;
      font-weight: 600;
      color: #333;
    }

    .form-check-input {
      transform: scale(1.2); /* Slightly larger toggle switches */
    }

    .container {
      background-color: rgba(240, 240, 240, 0.6); /* Transparent container background */
      padding: 20px;
      border-radius: 12px;
    }

</style>
<div class="row">
  <div class="col-lg-12 col-md-12 col-12 mb-4 hand">
    <div class="card pmd-card hand">
      <div class="card-header bg-primary text-white py-2">
        <div class="d-flex align-items-center">
          <span class="mr-auto"><?=file_name()?></span>
        </div>
      </div>
      <div class="card-body p-0">

        <form class="row px-4 py-3" method="POST" action="">
          <div class="col-md-2 mb-2">
	        <label>Top</label>
	        <select class="form-control" name="limit" required>
	          	<option value="10">10</option>
	            <option value="50">50</option>
	            <option value="100">100</option>
	            <option value="200">200</option>
	            <option value="500">500</option>
	            <option value="1000">1000</option>
	            <option value="1500">1500</option>
	            <option value="2000">2000</option>
	            <option value="2500">2500</option>
	            <option value="3000">3000</option>
	            <option value="4000">4000</option>
	            <option value="5000">ALL</option>
	        </select>
          </div>
          <div class="col-md-8 mb-2">
           <label>Search</label>  
           <input type="text" name="searchInput" placeholder="Search By:- Username / Mobile Number / Etc" class="form-control">
          </div>
          <div class="col-md-2 mb-2">
           <label>&nbsp;</label>
           <button type="submit" name="search" class="btn btn-primary btn-block">Search</button>
          </div>
        </form>


       <div class="table-responsive scroll">
        <table class="table w-100" id="dataTable">
          <thead>
            <tr class="bg-secondary">
              <th>UserID</th>
              <th>Type</th>
              <th>Parent</th>
              <th>Name</th>
              <th>Mobile</th>
              <th>Email</th>
              <th>Balance</th>
              <th>Date</th>
              <th>Status</th>
              <th>Action</th>
            </tr>
          </thead>
          <tbody>

<?php
$limit = 5000;
$searchInput = false;
if(isset($_POST['search'])){
$limit = is_valid_amount($_POST['limit']);
$searchInput = safe_clean($_POST['searchInput']);
}


if (in_array($user_data['user_id'], ['']) && in_array($user_data['usertype'], [''])){
$condition = " username!='' ";
}else if(in_array($user_data['usertype'], ['White Label'])){
$condition = " (parent_id='".$user_data['user_id']."' || site_id='".$site_data['site_id']."' ) "; 
}else{
$condition = " parent_uid='".$user_data['mobile']."' ";  
}

if(!empty($searchInput)){
$condition .= " AND CONCAT(`username`,`mobile`,`email`,`parent_uid`) LIKE '%$searchInput%'";     
}

$response = db_fetch_all("members", "$condition ORDER BY user_id DESC LIMIT $limit ");
foreach ($response as $key => $value) {
$value['created_at'] = date("d-M-Y",strtotime($value['created_at']));

if(in_array($value['status'],['Active'])){
$status = '<span class="badge badge-success"><span class="oi oi-media-record pulse mr-1"></span>'.$value['status'].'</span>';
}else if(in_array($value['status'],['Pending'])){
$status = '<span class="badge badge-warning"><span class="oi oi-media-record pulse mr-1"></span>'.$value['status'].'</span>';
}else if(in_array($value['status'],['InActive'])){
$status = '<span class="badge badge-danger"><span class="oi oi-media-record pulse mr-1"></span>'.$value['status'].'</span>';
}else if(in_array($value['status'],['Unpaid'])){
$status = '<span class="badge badge-danger"><span class="oi oi-media-record pulse mr-1"></span>'.$value['status'].'</span>';
}

$member_data = base64_encode(json_encode([
   "user_id" => $value['user_id'],
   "site_id" => $value['site_id'],
   "username" => $value['username'],
   "usertype" => $value['usertype'],
   "parent_id" => $value['parent_id'],
   "parent_uid" => $value['parent_uid'],
   "name" => $value['name'],
   "company" => $value['company'],
   "mobile" => $value['mobile'],
   "email" => $value['email'], 
   "aadhaar" => $value['aadhaar'],
   "pan" => $value['pan'],
   "balance" => $value['balance'],
   "psa_id" => $value['psa_id'],
   "pan_service" => $value['pan_service'],
   "pandetils_service" => $value['pandetils_service'],
   "aadhar_service" => $value['aadhar_service'],
   "dl_pdf_service" => $value['dl_pdf_service'],
   "rationpdf_service" => $value['rationpdf_service'],
   "vehical_service" => $value['vehical_service'],
   "aadhar_fingerPrint_service" => $value['aadhar_fingerPrint_service'],
   "aadhar_manual_service" => $value['aadhar_manual_service'],
   "aadhar_Verify_service" => $value['aadhar_Verify_service'],
   "eid_Status_service" => $value['eid_Status_service'],
   "aadhar_to_maskpan_service" => $value['aadhar_to_maskpan_service'],
   "pan_to_maskuid_service" => $value['pan_to_maskuid_service'],
   "aadhar_to_panLink_service" => $value['aadhar_to_panLink_service'],
   "pan_print_service" => $value['pan_print_service'],
   "Rc_pdf_services" => $value['Rc_pdf_services'],
   "challan_Check_Service" => $value['challan_Check_Service'],
   "ration_to_pdf_Service" => $value['ration_to_pdf_Service'],
   "dl_find_service" => $value['dl_find_service'],
   "eshram_services" => $value['eshram_services'],
   "eshram_print_fee" => $value['eshram_print_fee'],
   "ayushman_service" => $value['ayushman_service'],
   "ayushman_fee" => $value['ayushman_fee'],
   "rtps_service" => $value['rtps_service'],
   "rtps_br_price" => $value['rtps_br_price'],
   "janaadhar_service" => $value['janaadhar_service'],
   "janaadhar_fee" => $value['janaadhar_fee'],
   "janaadhar_find_fee" => $value['janaadhar_find_fee'],
   "janaadhar_status_fee" => $value['janaadhar_status_fee'],
   "farmer_services" => $value['farmer_services'],
   "dbt_farmer_fee" => $value['dbt_farmer_fee'],
   "electricBill_services" => $value['electricBill_services'],
   "aadhar_otp_service" => $value['aadhar_otp_service'],
   "electricBill_fee" => $value['electricBill_fee'],
   "agriFarmer_fee" => $value['agriFarmer_fee'],
   "Agrifarmer_Status_fee" => $value['Agrifarmer_Status_fee'],
   "aadhar_otp_fee" => $value['aadhar_otp_fee'],
   "familyid_service" => $value['familyid_service'],
   "familid_fee" => $value['familid_fee'],
   "uid_to_details_fee" => $value['uid_to_details_fee'],
   "ll_service" => $value['ll_service'],
   "ll_apply_fee" => $value['ll_apply_fee'],
   "rationto_uid_find_service" => $value['rationto_uid_find_service'],
   "uid_ration_pdf_Service" => $value['uid_ration_pdf_Service'],
   "voter_advance_Service" => $value['voter_advance_Service'],
   "voter_Manual_Service" => $value['voter_Manual_Service'],
   "voter_Mobile_Link_Service" => $value['voter_Mobile_Link_Service'],
   "voter_Pdf_Service" => $value['voter_Pdf_Service'],
   "voter_service" => $value['voter_service'],
   "aadhar_advance_fee" => $value['aadhar_advance_fee'],
   "aadhar_manual_print_fee" => $value['aadhar_manual_print_fee'],
   "pan_card_print_fee" => $value['pan_card_print_fee'],
   "aadhar_verify_fee" => $value['aadhar_verify_fee'],
   "challan_fee" => $value['challan_fee'],
   "dl_pdf_fee" => $value['dl_pdf_fee'],
   "enrollment_status_fee" => $value['enrollment_status_fee'],
   "ration_pdf_fee" => $value['ration_pdf_fee'],
   "pan_find_fee" => $value['pan_find_fee'],
   "pan2uid_find_service" => $value['pan2uid_find_service'],
   "npci_service" => $value['npci_service'],
   "vehical_rc_father_find_Service" => $value['vehical_rc_father_find_Service'],
   "mobile_dth_recharge_services" => $value['mobile_dth_recharge_services'],
   "psa_active" => $value['psa_active'],
   "janaadhar_member_details_services" => $value['janaadhar_member_details_services'],
   "dl_mobile_find_services" => $value['dl_mobile_find_services'],
   "chassis2rc_services" => $value['chassis2rc_services'],
   "learning_pdf_services" => $value['learning_pdf_services'],
   "learning_find_services" => $value['learning_find_services'],
   "npci_link_status_fee" => $value['npci_link_status_fee'],
   "rationto_uid_find_all_fee" => $value['rationto_uid_find_all_fee'],
   "pan_apply_fee" => $value['pan_apply_fee'],
   "janaadhar_member_details_fee" => $value['janaadhar_member_details_fee'],
   "dl_mobile_find_fee" => $value['dl_mobile_find_fee'],
   "chassis2rc_fee" => $value['chassis2rc_fee'],
   "learning_find_fee" => $value['learning_find_fee'],
   "learning_pdf_fee" => $value['learning_pdf_fee'],
   "min_balance" => $value['min_balance'],
   "vehical_rc_father_find_fee" => $value['vehical_rc_father_find_fee'],
   "pan2uid_find_fee" => $value['pan2uid_find_fee'],
   "pandetils_fee" => $value['pandetils_fee'],
   "pan_uid_status_fee" => $value['pan_uid_status_fee'],
   "pan_to_mask_uid_fee" => $value['pan_to_mask_uid_fee'],
   "rationto_uid_find_fee" => $value['rationto_uid_find_fee'],
   "dl_find_fee" => $value['dl_find_fee'],
   "ifsc_verify_fee" => $value['ifsc_verify_fee'],
   "pincode_verify_fee" => $value['pincode_verify_fee'],
   "mobile_verify_fee" => $value['mobile_verify_fee'],
   "vehical_rc_fee" => $value['vehical_rc_fee'],
   "voter_advance_fee" => $value['voter_advance_fee'],
   "voter_mobile_link_fee" => $value['voter_mobile_link_fee'],
   "voter_pdf_fee" => $value['voter_pdf_fee'],
   "recharge_active" => $value['recharge_active'],
   "created_at" => $value['created_at'],
   "remark" => $value['remark'],
   "status" => $value['status'],
]));
?>

            <tr>
              <td><?=$value['username']?></td>
              <td><?=$value['usertype']?></td>
              <td><?=$value['parent_uid']?></td>
              <td><?=$value['name']?></td>
              <td><?=$value['mobile']?></td>
              <td><?=$value['email']?></td>
              <td><i class="fas fa-inr fa-sm fa-fw"></i><?=$value['balance']?></td>
              <td><?=$value['created_at']?></td>
              <td><?=$status?></td>
              <td>
              	<input type="hidden" id="<?=$value['user_id']?>" value="<?=$member_data?>">
              	<button class="btn btn-primary btn-xs mb-2" title="Edit" onclick="edit($('#<?=$value['user_id']?>').val())"><i class="fas fa-edit"></i></button>
              	<button class="btn btn-info btn-xs mb-2" title="Transfer" onclick="transfer($('#<?=$value['user_id']?>').val())"><i class="fas fa-wallet"></i></button>
              	<?php if (in_array($user_data['user_id'], ['1']) && in_array($user_data['usertype'], ['Admin'])){ ?>
              	<button class="btn btn-danger btn-xs mb-2" title="Delete" onclick="remove($('#<?=$value['user_id']?>').val())"><i class="fas fa-trash"></i></button>
                <?php } ?>
              </td>
            </tr>
<?php
}
?>            
            
          </tbody>
        </table>
       </div>
      </div>
    </div>
  </div>
</div>

<!-- Edit Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <form class="modal-content" method="POST" action="">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Edit Member - <b class="username"></b></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body row py-3">
        <div class="col-md-6 mb-3">
          <label>Name</label>
          <input type="text" class="form-control name" placeholder="Enter Name" name="name" required>
        </div>
        <div class="col-md-6 mb-3">
          <label>Shop Name</label>
          <input type="text" class="form-control company" placeholder="Enter Shop Name" name="company" required>
        </div>
        <div class="col-md-6 mb-3">
          <label>Mobile Number</label>
          <input type="number" class="form-control mobile" placeholder="Enter Mobile Number" name="mobile" onkeypress="if(this.value.length==10) return false;" required>
        </div>
        <div class="col-md-6 mb-3">
          <label>Email Address</label>
          <input type="emial" class="form-control email" placeholder="Enter Email Address" name="email" required>
        </div>
        <div class="col-md-6 mb-3">
          <label>Aadhaar Number</label>
          <input type="number" class="form-control aadhaar" placeholder="Enter Aadhaar Number" name="aadhaar" onkeypress="if(this.value.length==12) return false;" required>
        </div>
        <div class="col-md-6 mb-3">
          <label>PAN Number</label>
          <input type="text" class="form-control pan" placeholder="Enter PAN Number" name="pan" onkeypress="if(this.value.length==10) return false;" required>
        </div>
        <?php if (in_array($user_data['user_id'], ['1']) && in_array($user_data['usertype'], ['Admin'])){ ?>
        <div class="col-md-3 mb-3">
          <label>User Type</label>
          <select class="form-control usertype" name="usertype" required>
                <option value="">Select</option>
            <?php if (in_array($user_data['user_id'], ['1']) && in_array($user_data['usertype'], ['Admin'])){ ?>
                <option value="Retailer">Retailer</option>
                <option value="Distributor">Distributor</option>
                <option value="Master Distributor">Master Distributor</option>
                <!--<option value="White Label">White Label</option>-->
                <option value="Admin">Admin</option>
            <?php } ?> 
            <?php if(in_array($user_data['usertype'], ['White Label'])){ ?>
                <option value="Retailer">Retailer</option>
                <option value="Distributor">Distributor</option>
                <option value="Master Distributor">Master Distributor</option>
            <?php } ?>   
            <?php if(in_array($user_data['usertype'], ['Master Distributor'])){ ?>
                <option value="Retailer">Retailer</option>
                <option value="Distributor">Distributor</option>
            <?php } ?>   
            <?php if(in_array($user_data['usertype'], ['Distributor'])){ ?>
                <option value="Retailer">Retailer</option>
            <?php } ?>            
            </select>
        </div>

        <?php if (in_array($user_data['user_id'], ['1']) && in_array($user_data['usertype'], ['Admin'])){ ?>        
        <div class="col-md-3 mb-3">
          <label>Parent</label>
          <select class="form-control parent_id" name="parent_id" required>
                <option value="">Select</option>
            <?php
            if (in_array($user_data['user_id'], ['1']) && in_array($user_data['usertype'], ['Admin'])){
            $condition = " usertype!='Retailer' ";
            }else if(in_array($user_data['usertype'], ['White Label'])){
            $condition = "usertype!='Retailer' AND (parent_id='".$user_data['user_id']."' || site_id='".$site_data['site_id']."' ) "; 
            }else{
            $condition = "usertype!='Retailer' parent_id='".$user_data['user_id']."' ";  
            }

            $response = db_fetch_all("members", "$condition ORDER BY user_id DESC"," user_id, username, name ");
            foreach ($response as $key => $value) {
            ?>
                <option value="<?=$value['user_id']?>"><?=$value['username']?> - <?=$value['name']?></option>
            <?php
            }
            ?>
            </select>
        </div>
        <?php } ?> 
        <div class="col-md-3 mb-3">
          <label>Status</label>
          <select class="form-control status" name="status" required>
                <option value="Active">Active</option>
                <option value="InActive">InActive</option>
                <option value="Pending">Pending</option>
                <option value="Unpaid">Unpaid</option>
            </select>
        </div> 
        
    <div class="container mt-4">
      <h6 class="mb-3 text-center">Service ON/OFF</h6><hr>
	    <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>ALL AADHAAR SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input aadhar_service" id="aadhar_service" name="aadhar_service" value="1">
	           <label class="custom-control-label" for="aadhar_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>ALL VOTER SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input voter_service" id="voter_service" name="voter_service" value="1">
	           <label class="custom-control-label" for="voter_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>ALL DL SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input dl_pdf_service" id="dl_pdf_service" name="dl_pdf_service" value="1">
	           <label class="custom-control-label" for="dl_pdf_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>ALL RATION SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input rationpdf_service" id="rationpdf_service" name="rationpdf_service" value="1">
	           <label class="custom-control-label" for="rationpdf_service"></label>
	         </div>
	       </div>
	       </div>
	       <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>ALL VEHICAL SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input vehical_service" id="vehical_service" name="vehical_service" value="1">
	           <label class="custom-control-label" for="vehical_service"></label>
	         </div>
	       </div> 
	      <div class="col">
	         <label>ALL PAN SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input pan_service" id="pan_service" name="pan_service" value="1">
	           <label class="custom-control-label" for="pan_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>WALLET ADD INSTANT</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input recharge" id="recharge" name="recharge_active" value="1">
	           <label class="custom-control-label" for="recharge"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>AADHAR FINGERPRINT</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input aadhar_fingerPrint_service" id="aadhar_fingerPrint_service" name="aadhar_fingerPrint_service" value="1">
	           <label class="custom-control-label" for="aadhar_fingerPrint_service"></label>
	         </div>
	       </div>
	       </div>
	       <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>AADHAR MANUAL</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input aadhar_manual_service" id="aadhar_manual_service" name="aadhar_manual_service" value="1">
	           <label class="custom-control-label" for="aadhar_manual_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>AADHAR NO. VERIFY</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input aadhar_Verify_service" id="aadhar_Verify_service" name="aadhar_Verify_service" value="1">
	           <label class="custom-control-label" for="aadhar_Verify_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>EID STATUS CHECK</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input eid_Status_service" id="eid_Status_service" name="eid_Status_service" value="1">
	           <label class="custom-control-label" for="eid_Status_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>UID TO MASK PAN</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input aadhar_to_maskpan_service" id="aadhar_to_maskpan_service" name="aadhar_to_maskpan_service" value="1">
	           <label class="custom-control-label" for="aadhar_to_maskpan_service"></label>
	         </div>
	       </div>
	       </div>
	       <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>PAN TO MASK UID</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input pan_to_maskuid_service" id="pan_to_maskuid_service" name="pan_to_maskuid_service" value="1">
	           <label class="custom-control-label" for="pan_to_maskuid_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>UID PAN LINK STATUS</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input aadhar_to_panLink_service" id="aadhar_to_panLink_service" name="aadhar_to_panLink_service" value="1">
	           <label class="custom-control-label" for="aadhar_to_panLink_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>PAN PRINT</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input pan_print_service" id="pan_print_service" name="pan_print_service" value="1">
	           <label class="custom-control-label" for="pan_print_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>PAN DETAILS</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input pandetils_service" id="pandetils_service" name="pandetils_service" value="1">
	           <label class="custom-control-label" for="pandetils_service"></label>
	         </div>
	       </div>
	       </div>
	       <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>RC PDF</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input Rc_pdf_services" id="Rc_pdf_services" name="Rc_pdf_services" value="1">
	           <label class="custom-control-label" for="Rc_pdf_services"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>RATION TO PDF</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input ration_to_pdf_Service" id="ration_to_pdf_Service" name="ration_to_pdf_Service" value="1">
	           <label class="custom-control-label" for="ration_to_pdf_Service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>RATION TO UID FIND</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input rationto_uid_find_service" id="rationto_uid_find_service" name="rationto_uid_find_service" value="1">
	           <label class="custom-control-label" for="rationto_uid_find_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>UID 2 RATION PDF</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input uid_ration_pdf_Service" id="uid_ration_pdf_Service" name="uid_ration_pdf_Service" value="1">
	           <label class="custom-control-label" for="uid_ration_pdf_Service"></label>
	         </div>
	       </div>
	       </div>
	       <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>VOTER ADVANCE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input voter_advance_Service" id="voter_advance_Service" name="voter_advance_Service" value="1">
	           <label class="custom-control-label" for="voter_advance_Service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>VOTER MANUAL</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input voter_Manual_Service" id="voter_Manual_Service" name="voter_Manual_Service" value="1">
	           <label class="custom-control-label" for="voter_Manual_Service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>VOTER MOBILE LINK</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input voter_Mobile_Link_Service" id="voter_Mobile_Link_Service" name="voter_Mobile_Link_Service" value="1">
	           <label class="custom-control-label" for="voter_Mobile_Link_Service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>VOTER ORIGINAL PDF</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input voter_Pdf_Service" id="voter_Pdf_Service" name="voter_Pdf_Service" value="1">
	           <label class="custom-control-label" for="voter_Pdf_Service"></label>
	         </div>
	       </div>
	    </div>
	    <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>LL EXAM </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input ll_service" id="ll_service" name="ll_service" value="1">
	           <label class="custom-control-label" for="ll_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>AYUSHMAN SERVICE </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input ayushman_service" id="ayushman_service" name="ayushman_service" value="1">
	           <label class="custom-control-label" for="ayushman_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>e-Shram SERVICE </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input eshram_services" id="eshram_services" name="eshram_services" value="1">
	           <label class="custom-control-label" for="eshram_services"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>CHALLAN DETAILS</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input challan_Check_Service" id="challan_Check_Service" name="challan_Check_Service" value="1">
	           <label class="custom-control-label" for="challan_Check_Service"></label>
	         </div>
	       </div>
	    </div>
	    <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>DL FIND</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input dl_find_service" id="dl_find_service" name="dl_find_service" value="1">
	           <label class="custom-control-label" for="dl_find_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>JANAADHAR SERVICE </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input janaadhar_service" id="janaadhar_service" name="janaadhar_service" value="1">
	           <label class="custom-control-label" for="janaadhar_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>RTPS SERVICE- BR </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input rtps_service" id="rtps_service" name="rtps_service" value="1">
	           <label class="custom-control-label" for="rtps_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>FAMILYID SERVICE- HR </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input familyid_service" id="familyid_service" name="familyid_service" value="1">
	           <label class="custom-control-label" for="familyid_service"></label>
	         </div>
	       </div>
	    </div>
	    
	    <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>FARMER SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input farmer_services" id="farmer_services" name="farmer_services" value="1">
	           <label class="custom-control-label" for="farmer_services"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>ELECTRIC-BILL SERVICE </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input electricBill_services" id="electricBill_services" name="electricBill_services" value="1">
	           <label class="custom-control-label" for="electricBill_services"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>AADHAR OTP SERVICE </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input aadhar_otp_service" id="aadhar_otp_service" name="aadhar_otp_service" value="1">
	           <label class="custom-control-label" for="aadhar_otp_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>PAN 2 UID FIND SERVICE </label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input pan2uid_find_service" id="pan2uid_find_service" name="pan2uid_find_service" value="1">
	           <label class="custom-control-label" for="pan2uid_find_service"></label>
	         </div>
	       </div>
	       
	    <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>NPCI SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input npci_service" id="npci_service" name="npci_service" value="1">
	           <label class="custom-control-label" for="npci_service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>RC FATHER FIND SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input vehical_rc_father_find_Service" id="vehical_rc_father_find_Service" name="vehical_rc_father_find_Service" value="1">
	           <label class="custom-control-label" for="vehical_rc_father_find_Service"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>MOBILE/DTH RECHARGE SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input mobile_dth_recharge_services" id="mobile_dth_recharge_services" name="mobile_dth_recharge_services" value="1">
	           <label class="custom-control-label" for="mobile_dth_recharge_services"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>NSDL PAN APPLY/CORRECTION SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input psa_active" id="psa_active" name="psa_active" value="1">
	           <label class="custom-control-label" for="psa_active"></label>
	         </div>
	       </div> 
	       
	    <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>JANAADHAR MEMBER DETAILS</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input janaadhar_member_details_services" id="janaadhar_member_details_services" name="janaadhar_member_details_services" value="1">
	           <label class="custom-control-label" for="janaadhar_member_details_services"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>DL MOBILE FIND SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input dl_mobile_find_services" id="dl_mobile_find_services" name="dl_mobile_find_services" value="1">
	           <label class="custom-control-label" for="dl_mobile_find_services"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>CHASSIS TO RC SERVICE</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input chassis2rc_services" id="chassis2rc_services" name="chassis2rc_services" value="1">
	           <label class="custom-control-label" for="chassis2rc_services"></label>
	         </div>
	       </div>
	      <div class="col">
	         <label>LEARNING PDF</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input learning_pdf_services" id="learning_pdf_services" name="learning_pdf_services" value="1">
	           <label class="custom-control-label" for="learning_pdf_services"></label>
	         </div>
	       </div>
	       
	    <div class="col-md-12 mb-3 row text-center p-2">
	      <div class="col">
	         <label>APPLICATION FIND ( LL )</label>
	         <div class="custom-control custom-switch">
	           <input type="checkbox" class="custom-control-input learning_find_services" id="learning_find_services" name="learning_find_services" value="1">
	           <label class="custom-control-label" for="learning_find_services"></label>
	         </div>
	       </div>
	       
	       
	       </div>
	       </div>
	       </div>
	    </div>
	    </div>
	 <div class="container mt-4">
      <h6 class="mb-3 text-center">ALL SERVICE PRICE</h6><hr>
	    <div class="col-md-12 mb-3 row text-center p-2">
           <div class="col-md-3 mb-3">
             <label>Minimum Amount Add</label>
             <input type="number" class="form-control min_balance" placeholder="Minimum Amount" name="min_balance" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Aadhaar Fingerprint</label>
             <input type="number" class="form-control aadhar_advance_fee" placeholder="Enter Aadhar Price" name="aadhar_advance_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Aadhaar OTP</label>
             <input type="number" class="form-control aadhar_otp_fee" placeholder="Enter Aadhar Price" name="aadhar_otp_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Aadhaar Manual</label>
             <input type="number" class="form-control aadhar_manual_print_fee" placeholder="Enter Aadhar Price" name="aadhar_manual_print_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Aadhaar Verify</label>
             <input type="number" class="form-control aadhar_verify_fee" placeholder="Enter Number veify Price" name="aadhar_verify_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label >Aadhaar 2 Full Details</label>
             <input type="number" class="form-control uid_to_details_fee" placeholder="Enter Number veify Price" name="uid_to_details_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label> Ayushman Print</label>
             <input type="number" class="form-control ayushman_fee" placeholder="Enter Number veify Price" name="ayushman_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>e-Shram Print</label>
             <input type="number" class="form-control eshram_print_fee" placeholder="Enter Number veify Price" name="eshram_print_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Enrollment Status</label>
             <input type="number" class="form-control enrollment_status_fee" placeholder="Enter Price" name="enrollment_status_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>RTPS Download</label>
             <input type="number" class="form-control rtps_br_price" placeholder="Enter Price" name="rtps_br_price" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>JanAadhar Status</label>
             <input type="number" class="form-control janaadhar_status_fee" placeholder="Enter Price" name="janaadhar_status_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>JanAadhar PDF</label>
             <input type="number" class="form-control janaadhar_fee" placeholder="Enter Price" name="janaadhar_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>UID 2 JanAadhar</label>
             <input type="number" class="form-control janaadhar_find_fee" placeholder="Enter Price" name="janaadhar_find_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>DBT Farmer PDF</label>
             <input type="number" class="form-control dbt_farmer_fee" placeholder="Enter Price" name="dbt_farmer_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>ElectricBill Details</label>
             <input type="number" class="form-control electricBill_fee" placeholder="Enter Price" name="electricBill_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Agri Farmer PDF</label>
             <input type="number" class="form-control agriFarmer_fee" placeholder="Enter Price" name="agriFarmer_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Agri Farmer Status</label>
             <input type="number" class="form-control Agrifarmer_Status_fee" placeholder="Enter Price" name="Agrifarmer_Status_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>FamilyID PDF</label>
             <input type="number" class="form-control familid_fee" placeholder="Enter Price" name="familid_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Bank IFSC</label>
             <input type="number" class="form-control ifsc_verify_fee" placeholder="Enter Price" name="ifsc_verify_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Vehical Challan</label>
             <input type="number" class="form-control challan_fee" placeholder="Enter Price" name="challan_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Vehical RC Father Find</label>
             <input type="number" class="form-control vehical_rc_father_find_fee" placeholder="Enter Price" name="vehical_rc_father_find_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Vehical RC</label>
             <input type="number" class="form-control vehical_rc_fee" placeholder="Enter Price" name="vehical_rc_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Driving Licence</label>
             <input type="number" class="form-control dl_pdf_fee" placeholder="Enter Price" name="dl_pdf_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>DL Find</label>
             <input type="number" class="form-control dl_find_fee" placeholder="Enter Price" name="dl_find_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>LL Exam</label>
             <input type="number" class="form-control ll_apply_fee" placeholder="Enter Price" name="ll_apply_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Ration to Uid Find All State</label>
             <input type="number" class="form-control rationto_uid_find_all_fee" placeholder="Enter Price" name="rationto_uid_find_all_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Ration to Uid Find</label>
             <input type="number" class="form-control rationto_uid_find_fee" placeholder="Enter Price" name="rationto_uid_find_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Ration PDF</label>
             <input type="number" class="form-control ration_pdf_fee" placeholder="Enter Price" name="ration_pdf_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label style="color:red; font-weight:bold;" >JanAadhar Member Find</label>
             <input type="number" class="form-control janaadhar_member_details_fee" placeholder="Enter Price" name="janaadhar_member_details_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label style="color:red; font-weight:bold;" >DL To Mobile Find</label>
             <input type="number" class="form-control dl_mobile_find_fee" placeholder="Enter Price" name="dl_mobile_find_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label style="color:red; font-weight:bold;" >Chassis To RC Find</label>
             <input type="number" class="form-control chassis2rc_fee" placeholder="Enter Price" name="chassis2rc_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label style="color:red; font-weight:bold;" >Learning PDF</label>
             <input type="number" class="form-control learning_pdf_fee" placeholder="Enter Price" name="learning_pdf_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label style="color:red; font-weight:bold;" >Application No Find ( LL )</label>
             <input type="number" class="form-control learning_find_fee" placeholder="Enter Price" name="learning_find_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>NSDL Pan Apply/Correction</label>
             <input type="number" class="form-control pan_apply_fee" placeholder="Enter Price" name="pan_apply_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Pan Card Print</label>
             <input type="number" class="form-control pan_card_print_fee" placeholder="Enter Price" name="pan_card_print_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Pan Find</label>
             <input type="number" class="form-control pan_find_fee" placeholder="Enter Price" name="pan_find_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>NPCI Link Status</label>
             <input type="number" class="form-control npci_link_status_fee" placeholder="Enter Price" name="npci_link_status_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Pan 2 UID Find</label>
             <input type="number" class="form-control pan2uid_find_fee" placeholder="Enter Price" name="pan2uid_find_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Pan Details</label>
             <input type="number" class="form-control pandetils_fee" placeholder="Enter Price" name="pandetils_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Pan Aadhar Link Status</label>
             <input type="number" class="form-control pan_uid_status_fee" placeholder="Enter Price" name="pan_uid_status_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Pan to Mask Aadhaar</label>
             <input type="number" class="form-control pan_to_mask_uid_fee" placeholder="Enter Price" name="pan_to_mask_uid_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Voter Verification</label>
             <input type="number" class="form-control voter_advance_fee" placeholder="Enter Price" name="voter_advance_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Voter Mobile Link</label>
             <input type="number" class="form-control voter_mobile_link_fee" placeholder="Enter Price" name="voter_mobile_link_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Voter Orginal PDF</label>
             <input type="number" class="form-control voter_pdf_fee" placeholder="Enter Price" name="voter_pdf_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Pincode Verification</label>
             <input type="number" class="form-control pincode_verify_fee" placeholder="Enter Price" name="pincode_verify_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
           <div class="col-md-3 mb-3">
             <label>Mobile Number Verify</label>
             <input type="number" class="form-control mobile_verify_fee" placeholder="Enter Price" name="mobile_verify_fee" onkeypress="if(this.value.length==3) return false;" required>
           </div>
	 </div>
	</div>
	    <?php } ?>
	      

      </div>
      <div class="modal-footer">
      	<input type="hidden" name="user_id" class="user_id" required>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <?php if(in_array($user_data['usertype'], ['Admin','White Label'])){ ?> 
        <button type="button" class="btn btn-danger" onclick="memberPassword($('.user_id').val())">Password Reset</button>
	    <?php } ?>
        <button type="submit" name="editMember" class="btn btn-primary">Save Changes</button>
      </div>
    </form>
  </div>
</div>



<!-- Transfer Modal -->
<div class="modal fade" id="transferModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <form class="modal-content" method="POST" action="">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Transfer Wallet Balance - <b class="username"></b></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body row py-3">
        <div class="col-md-12 mb-3">
          <label>Amount</label>
          <input type="number" class="form-control" placeholder="Enter Amount" name="transferamount" required>
        </div>
        
        <div class="col-md-12 mb-3">
          <label>Transfer Type</label>
          <select class="form-control" name="transfertype" required>
                <option value="">Select</option>
                <option value="Credit">Credit</option>
                <?php if (in_array($user_data['user_id'], ['1']) && in_array($user_data['usertype'], ['Admin'])){ ?> 
                <option value="Debit">Debit</option>
                <?php } ?>
            </select>
        </div>
        <div class="col-md-12 mb-3">
          <label>Reference Number</label>
          <input type="text" class="form-control" placeholder="Enter Reference Number" value="<?=order_txn_id()?>" name="ref_id" required>
        </div>
      </div>
      <div class="modal-footer">
      	<input type="hidden" name="user_id" class="user_id" required>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" name="transferBalance" class="btn btn-primary">Submit</button>
      </div>
    </form>
  </div>
</div>

<script>
function edit(base64){
var json = atob(base64);
var member_data = JSON.parse(json); 
//console.log(member_data);
$("#editModal").modal("show");
$(".user_id").val(member_data.user_id);
$(".username").html(member_data.username);
$(".name").val(member_data.name);
$(".company").val(member_data.company);
$(".mobile").val(member_data.mobile);
$(".email").val(member_data.email);
$(".aadhaar").val(member_data.aadhaar);
$(".pan").val(member_data.pan);
$(".usertype").val(member_data.usertype);
$(".parent_id").val(member_data.parent_id);
$(".aadhar_advance_fee").val(member_data.aadhar_advance_fee);
$(".aadhar_manual_print_fee").val(member_data.aadhar_manual_print_fee);
$(".pan_card_print_fee").val(member_data.pan_card_print_fee);
$(".aadhar_verify_fee").val(member_data.aadhar_verify_fee);
$(".challan_fee").val(member_data.challan_fee);
$(".dl_pdf_fee").val(member_data.dl_pdf_fee);
$(".ll_apply_fee").val(member_data.ll_apply_fee);
$(".uid_to_details_fee").val(member_data.uid_to_details_fee);
$(".ayushman_fee").val(member_data.ayushman_fee);
$(".rtps_br_price").val(member_data.rtps_br_price);
$(".janaadhar_fee").val(member_data.janaadhar_fee);
$(".janaadhar_find_fee").val(member_data.janaadhar_find_fee);
$(".janaadhar_status_fee").val(member_data.janaadhar_status_fee);
$(".familid_fee").val(member_data.familid_fee);
$(".dbt_farmer_fee").val(member_data.dbt_farmer_fee);
$(".electricBill_fee").val(member_data.electricBill_fee);
$(".aadhar_otp_fee").val(member_data.aadhar_otp_fee);
$(".Agrifarmer_Status_fee").val(member_data.Agrifarmer_Status_fee);
$(".agriFarmer_fee").val(member_data.agriFarmer_fee);
$(".eshram_print_fee").val(member_data.eshram_print_fee);
$(".enrollment_status_fee").val(member_data.enrollment_status_fee);
$(".ration_pdf_fee").val(member_data.ration_pdf_fee);
$(".pan_find_fee").val(member_data.pan_find_fee);
$(".pandetils_fee").val(member_data.pandetils_fee);
$(".npci_link_status_fee").val(member_data.npci_link_status_fee);
$(".vehical_rc_father_find_fee").val(member_data.vehical_rc_father_find_fee);
$(".rationto_uid_find_all_fee").val(member_data.rationto_uid_find_all_fee);
$(".pan_apply_fee").val(member_data.pan_apply_fee);
$(".janaadhar_member_details_fee").val(member_data.janaadhar_member_details_fee);
$(".dl_mobile_find_fee").val(member_data.dl_mobile_find_fee);
$(".chassis2rc_fee").val(member_data.chassis2rc_fee);
$(".learning_pdf_fee").val(member_data.learning_pdf_fee);
$(".min_balance").val(member_data.min_balance);
$(".learning_find_fee").val(member_data.learning_find_fee);
$(".pan2uid_find_fee").val(member_data.pan2uid_find_fee);
$(".pan_uid_status_fee").val(member_data.pan_uid_status_fee);
$(".pan_to_mask_uid_fee").val(member_data.pan_to_mask_uid_fee);
$(".dl_find_fee").val(member_data.dl_find_fee);
$(".rationto_uid_find_fee").val(member_data.rationto_uid_find_fee);
$(".ifsc_verify_fee").val(member_data.ifsc_verify_fee);
$(".pincode_verify_fee").val(member_data.pincode_verify_fee);
$(".mobile_verify_fee").val(member_data.mobile_verify_fee);
$(".vehical_rc_fee").val(member_data.vehical_rc_fee);
$(".voter_advance_fee").val(member_data.voter_advance_fee);
$(".voter_mobile_link_fee").val(member_data.voter_mobile_link_fee);
$(".voter_pdf_fee").val(member_data.voter_pdf_fee);

if(member_data.pan_service=="YES"){
$('#pan_service').attr('checked', 'checked');	
}else{
$('#pan_service').attr('checked', false);	
}

if(member_data.pandetils_service=="YES"){
$('#pandetils_service').attr('checked', 'checked');	
}else{
$('#pandetils_service').attr('checked', false);	
}

if(member_data.aadhar_service=="YES"){
$('#aadhar_service').attr('checked', 'checked');	
}else{
$('#aadhar_service').attr('checked', false);	
}

if(member_data.dl_pdf_service=="YES"){
$('#dl_pdf_service').attr('checked', 'checked');	
}else{
$('#dl_pdf_service').attr('checked', false);	
}

if(member_data.rationpdf_service=="YES"){
$('#rationpdf_service').attr('checked', 'checked');	
}else{
$('#rationpdf_service').attr('checked', false);	
}

if(member_data.vehical_service=="YES"){
$('#vehical_service').attr('checked', 'checked');	
}else{
$('#vehical_service').attr('checked', false);	
}

if(member_data.voter_service=="YES"){
$('#voter_service').attr('checked', 'checked');	
}else{
$('#voter_service').attr('checked', false);	
}

if(member_data.aadhar_fingerPrint_service=="YES"){
$('#aadhar_fingerPrint_service').attr('checked', 'checked');	
}else{
$('#aadhar_fingerPrint_service').attr('checked', false);	
}

if(member_data.aadhar_manual_service=="YES"){
$('#aadhar_manual_service').attr('checked', 'checked');	
}else{
$('#aadhar_manual_service').attr('checked', false);	
}

if(member_data.aadhar_Verify_service=="YES"){
$('#aadhar_Verify_service').attr('checked', 'checked');	
}else{
$('#aadhar_Verify_service').attr('checked', false);	
}

if(member_data.eid_Status_service=="YES"){
$('#eid_Status_service').attr('checked', 'checked');	
}else{
$('#eid_Status_service').attr('checked', false);	
}

if(member_data.aadhar_to_maskpan_service=="YES"){
$('#aadhar_to_maskpan_service').attr('checked', 'checked');	
}else{
$('#aadhar_to_maskpan_service').attr('checked', false);	
}

if(member_data.pan_to_maskuid_service=="YES"){
$('#pan_to_maskuid_service').attr('checked', 'checked');	
}else{
$('#pan_to_maskuid_service').attr('checked', false);	
}

if(member_data.aadhar_to_panLink_service=="YES"){
$('#aadhar_to_panLink_service').attr('checked', 'checked');	
}else{
$('#aadhar_to_panLink_service').attr('checked', false);	
}

if(member_data.pan_print_service=="YES"){
$('#pan_print_service').attr('checked', 'checked');	
}else{
$('#pan_print_service').attr('checked', false);	
}

if(member_data.Rc_pdf_services=="YES"){
$('#Rc_pdf_services').attr('checked', 'checked');	
}else{
$('#Rc_pdf_services').attr('checked', false);	
}

if(member_data.challan_Check_Service=="YES"){
$('#challan_Check_Service').attr('checked', 'checked');	
}else{
$('#challan_Check_Service').attr('checked', false);	
}

if(member_data.ration_to_pdf_Service=="YES"){
$('#ration_to_pdf_Service').attr('checked', 'checked');	
}else{
$('#ration_to_pdf_Service').attr('checked', false);	
}

if(member_data.dl_find_service=="YES"){
$('#dl_find_service').attr('checked', 'checked');	
}else{
$('#dl_find_service').attr('checked', false);	
}

if(member_data.rtps_service=="YES"){
$('#rtps_service').attr('checked', 'checked');	
}else{
$('#rtps_service').attr('checked', false);	
}

if(member_data.janaadhar_service=="YES"){
$('#janaadhar_service').attr('checked', 'checked');	
}else{
$('#janaadhar_service').attr('checked', false);	
}

if(member_data.farmer_services=="YES"){
$('#farmer_services').attr('checked', 'checked');	
}else{
$('#farmer_services').attr('checked', false);	
}

if(member_data.electricBill_services=="YES"){
$('#electricBill_services').attr('checked', 'checked');	
}else{
$('#electricBill_services').attr('checked', false);	
}

if(member_data.psa_active=="YES"){
$('#psa_active').attr('checked', 'checked');	
}else{
$('#psa_active').attr('checked', false);	
}

if(member_data.janaadhar_member_details_services=="YES"){
$('#janaadhar_member_details_services').attr('checked', 'checked');	
}else{
$('#janaadhar_member_details_services').attr('checked', false);	
}

if(member_data.dl_mobile_find_services=="YES"){
$('#dl_mobile_find_services').attr('checked', 'checked');	
}else{
$('#dl_mobile_find_services').attr('checked', false);	
}

if(member_data.chassis2rc_services=="YES"){
$('#chassis2rc_services').attr('checked', 'checked');	
}else{
$('#chassis2rc_services').attr('checked', false);	
}

if(member_data.learning_pdf_services=="YES"){
$('#learning_pdf_services').attr('checked', 'checked');	
}else{
$('#learning_pdf_services').attr('checked', false);	
}

if(member_data.learning_find_services=="YES"){
$('#learning_find_services').attr('checked', 'checked');	
}else{
$('#learning_find_services').attr('checked', false);	
}

if(member_data.mobile_dth_recharge_services=="YES"){
$('#mobile_dth_recharge_services').attr('checked', 'checked');	
}else{
$('#mobile_dth_recharge_services').attr('checked', false);	
}

if(member_data.vehical_rc_father_find_Service=="YES"){
$('#vehical_rc_father_find_Service').attr('checked', 'checked');	
}else{
$('#vehical_rc_father_find_Service').attr('checked', false);	
}

if(member_data.npci_service=="YES"){
$('#npci_service').attr('checked', 'checked');	
}else{
$('#npci_service').attr('checked', false);	
}

if(member_data.pan2uid_find_service=="YES"){
$('#pan2uid_find_service').attr('checked', 'checked');	
}else{
$('#pan2uid_find_service').attr('checked', false);	
}

if(member_data.aadhar_otp_service=="YES"){
$('#aadhar_otp_service').attr('checked', 'checked');	
}else{
$('#aadhar_otp_service').attr('checked', false);	
}

if(member_data.familyid_service=="YES"){
$('#familyid_service').attr('checked', 'checked');	
}else{
$('#familyid_service').attr('checked', false);	
}

if(member_data.ayushman_service=="YES"){
$('#ayushman_service').attr('checked', 'checked');	
}else{
$('#ayushman_service').attr('checked', false);	
}

if(member_data.eshram_services=="YES"){
$('#eshram_services').attr('checked', 'checked');	
}else{
$('#eshram_services').attr('checked', false);	
}

if(member_data.ll_service=="YES"){
$('#ll_service').attr('checked', 'checked');	
}else{
$('#ll_service').attr('checked', false);	
}

if(member_data.rationto_uid_find_service=="YES"){
$('#rationto_uid_find_service').attr('checked', 'checked');	
}else{
$('#rationto_uid_find_service').attr('checked', false);	
}

if(member_data.uid_ration_pdf_Service=="YES"){
$('#uid_ration_pdf_Service').attr('checked', 'checked');	
}else{
$('#uid_ration_pdf_Service').attr('checked', false);	
}

if(member_data.voter_advance_Service=="YES"){
$('#voter_advance_Service').attr('checked', 'checked');	
}else{
$('#voter_advance_Service').attr('checked', false);	
}

if(member_data.voter_Manual_Service=="YES"){
$('#voter_Manual_Service').attr('checked', 'checked');	
}else{
$('#voter_Manual_Service').attr('checked', false);	
}

if(member_data.voter_Mobile_Link_Service=="YES"){
$('#voter_Mobile_Link_Service').attr('checked', 'checked');	
}else{
$('#voter_Mobile_Link_Service').attr('checked', false);	
}

if(member_data.voter_Pdf_Service=="YES"){
$('#voter_Pdf_Service').attr('checked', 'checked');	
}else{
$('#voter_Pdf_Service').attr('checked', false);	
}
if(member_data.recharge_active=="YES"){
$('#recharge').attr('checked', 'checked');	
}else{
$('#recharge').attr('checked', false);	
}

$(".status").val(member_data.status);
}



function transfer(base64){
var json = atob(base64);
var member_data = JSON.parse(json); 
//console.log(member_data);
$("#transferModal").modal("show");
$(".user_id").val(member_data.user_id);
$(".username").html(member_data.username);
}



function remove(base64){
if(confirm('Are you sure you want to delete this account?')){
var json = atob(base64);
var member_data = JSON.parse(json); 	
my_form=document.createElement('form');
my_form.method='POST';
my_form.action=location.href;
my_input=document.createElement('input');
my_input.type='hidden';
my_input.name='remove';
my_input.value=true
my_form.appendChild(my_input);
my_input=document.createElement('input');
my_input.type='hidden';
my_input.name='user_id';
my_input.value=member_data.user_id;
my_form.appendChild(my_input);
document.body.appendChild(my_form);
my_form.submit();
}
} 


function memberPassword(user_id){
if(confirm('Are you sure you want to password reset?')){	
my_form=document.createElement('form');
my_form.method='POST';
my_form.action=location.href;
my_input=document.createElement('input');
my_input.type='hidden';
my_input.name='resetpassword';
my_input.value=true
my_form.appendChild(my_input);
my_input=document.createElement('input');
my_input.type='hidden';
my_input.name='user_id';
my_input.value=user_id;
my_form.appendChild(my_input);
document.body.appendChild(my_form);
my_form.submit();
}
}
</script>  

?>
<?php
require_once("../layouts/members/foot.php");
data_table('#dataTable');
?>