$(document).ready(function(){function alert(title,message){alertify.alert(title,message);}
$("#verified").hide();$("#verified1").hide();$("#show_tbl").hide();$("#loan_amount").keyup(function(e){e.preventDefault();var loan_amount=$("#loan_amount").val();if(isNaN(loan_amount)||loan_amount<=0||loan_amount==''){$("#loan_charge").val(0);return false;}
else{$.ajax({url:"includes/validation.php",method:"post",data:"loan_amount="+loan_amount,dataType:"text",cache:false,success:function(value){$("#loan_charge").val("$"+value);}});}});$("#from_calendar").change(function(e){e.preventDefault();Date.prototype.toInputFormat=function(){var yyyy=this.getFullYear().toString();var mm=(this.getMonth()+1).toString();var dd=this.getDate().toString();return yyyy+"-"+(mm[1]?mm:"0"+mm[0])+"-"+(dd[1]?dd:"0"+dd[0]);};$('#to_calendar').val('');var date=new Date($('.date-from').val());var min_date=date.setDate(date.getDate()+1);$('#to_calendar').attr({'min':date.toInputFormat(),'disabled':false});});$("#wallet_change").submit(function(e){e.preventDefault();var wallet_address=$("#wallet_address").val();var perfect_money=$("#perfect_money").val();var ethereum_address=$("#ethereum_address").val();var bitcoin_cash=$("#bitcoin_cash").val();$("#wallet_btn").html("Updating....");$("#wallet_btn").attr("disabled",true);var data="wallet_address="+wallet_address+"&perfect_money="+perfect_money+"&ethereum_address="+ethereum_address+"&bitcoin_cash="+bitcoin_cash;$.ajax({url:"includes/validation.php",method:"post",data:data,dataType:"text",success:function(wallet_upd){var wallet_upd=$.trim(wallet_upd);if(wallet_upd=="success")
{$("#wallet_address").val('');$("#wallet_btn").html("Update Account");$("#wallet_btn").attr("disabled",false);alert("Success!","Payment Address has been Updated!");}
else if(wallet_upd=="failed")
{$("#wallet_btn").html("Update Account");$("#wallet_btn").attr("disabled",false);alert("Error!","Something Went Wrong, Please try Again!");}}});});$("#psw_change").submit(function(e){e.preventDefault();var password=$("#password").val();var confirm_password=$("#confirm_password").val();if(password!=confirm_password){alert("Error!","Passwords Do Not Match!");return false;}
$("#psw_btn").html("Updating...");$("#psw_btn").attr("disabled",true);var data="password="+password;$.ajax({url:"includes/validation.php",method:"post",data:data,dataType:"text",success:function(security){var security=$.trim(security);if(security=="success")
{$("#password").val('');$("#confirm_password").val('');$("#psw_btn").html("Update Password");$("#psw_btn").attr("disabled",false);alert("Success!","Password has been Updated!");}
else if(security=="failed")
{$("#psw_btn").html("Update Password");$("#psw_btn").attr("disabled",false);alert("Error!","Something Went Wrong, Please try Again!");}}});});function id_kyc(){$.ajax({url:"includes/kyc.php",method:"post",data:"id_kyc="+'verify_kyc_id',dataType:"text",cache:false,success:function(kyc_id_chk){if(kyc_id_chk=="found"){$("#grid1").hide();$("#verified1").show();}}});}
id_kyc();setInterval(function(){id_kyc();},5000);function check_kyc(){$.ajax({url:"includes/kyc.php",method:"post",data:"check_kyc_id="+'kyc_id',dataType:"text",cache:false,success:function(kyc_id_chk){if(kyc_id_chk=="found"){$("#grid").hide();$("#verified").show();}}});}
check_kyc();setInterval(function(){check_kyc();},5000);function check_loan(){$.ajax({url:"includes/kyc.php",method:"post",data:"check_loan="+'loan_check',dataType:"json",cache:false,success:function(loan_check){if(loan_check.message=="found"){$("#loan_body_hide").hide();$("#show_tbl").hide();$("#show_loan_status").append('<div class="item-wrapper"><p style="text-transform: uppercase;">You requested for a loan recently, constantly check your mail box to know if it has been approved</p></div>');}else if(loan_check.message=="approved"){$("#loan_body_hide").hide();$("#show_tbl").show();$("#loan_body").append('<tr><td>$'+loan_check.loan_amount+'</td><td>'+loan_check.loan_status+'</td><td>'+loan_check.loan_due_date+'</td><td>'+loan_check.date_approved+'</td></tr>');}}});}
check_loan();$("#id_form").submit(function(e){e.preventDefault();var data=$("#id_form").serialize();$("#id_btn").html("Updating....");$("#id_btn").attr("disabled",true);$.ajax({url:'includes/kyc.php',method:'post',data:data,dataType:'text',cache:false,success:function(id_status){var id_status=$.trim(id_status);if(id_status=="success"){$("#id_btn").html("Begin Verification");$("#id_btn").attr("disabled",false);alert("Updated KYC INFORMATION!","Success!");}
else if(id_status=="failed"){$("#id_btn").html("Begin Verification");$("#id_btn").attr("disabled",true);alert("Failed to Update KYC INFORMATION!","Error!");}}});});$("#id_verification").submit(function(e){e.preventDefault();$("#verification_btn").html("Updating....");$("#verification_btn").attr("disabled",true);$.ajax({url:'includes/kyc.php',method:'post',data:new FormData(this),dataType:'text',cache:false,contentType:false,processData:false,success:function(verify_id_status){var verify_id_status=$.trim(verify_id_status);if(verify_id_status=="incomplete"){$("#verification_btn").html("<i class='icon icon-lock'></i> submit");$("#verification_btn").attr("disabled",false);alert("Update your Basic Information!","Error!");}else if(verify_id_status=="too_large"){$("#verification_btn").html("<i class='icon icon-lock'></i> submit");$("#verification_btn").attr("disabled",false);toastr.info("Image size is too lagre!","Error!");}else if(verify_id_status=="failed"){$("#verification_btn").html("<i class='icon icon-lock'></i> submit");$("#verification_btn").attr("disabled",false);alert("Failed to Update Identity verification. Try Again!","Error!");}
else if(verify_id_status=="success"){$("#verification_btn").html('<i class="icon icon-lock"></i> submit');$("#verification_btn").attr("disabled",true);alert("Identity Verification Updated successfully!","Great!");$("#id_verification")[0].reset();}}});});$("#user_profile").submit(function(e){e.preventDefault();var phone_number=$("#phone_number").val();var firstname=$("#firstname").val();var lastname=$("#lastname").val();if(isNaN(phone_number)){alert("Error!","Wrong Number Format!");return false;}
var data="phone_number="+phone_number+"&firstname="+firstname+"&lastname="+lastname;$("#phone_btn").html("Updating...");$("#phone_btn").attr("disabled",true);$.ajax({url:'includes/validation.php',method:'post',data:data,dataType:'text',cache:false,success:function(edited){var edited=$.trim(edited);if(edited=="success"){$("#phone_btn").html("Update Details");$("#phone_btn").attr("disabled",false);alert("Success!","Your Profile has been Updated!");}
else if(edited=="failed"){$("#phone_btn").html("Update Details");$("#phone_btn").attr("disabled",false);alert("Error!","Failed to Update Profile!");}}});});$("#deposit_funds").submit(function(e){e.preventDefault();var method=$("#pay_method").val();var amount=$("#deposit_amount").val();$("#submit_request").attr('disabled',true);$("#submit_request").html("Submitting...");var data='deposit_amount='+amount+'&payment_option='+method;$.ajax({url:'includes/validation.php',method:'post',data:data,dataType:'json',success:function(requests){if(method=='btc'){var payment_address=$.trim(requests.btc_txn_address);var payment_amount=$.trim(requests.amount);if(requests.message=='paymentok'){alert("Success!","Payment Adress has been Generated!");$("#pay_method").val('');$("#deposit_amount").val('');$("#submit_request").attr('disabled',false);$("#submit_request").html("Process Payment");$("#wallet_img").html('<img src="../images/'+method+'.png">');$('#wallet_addr').html('<div class="input-group"><input type="text" class="form-control" value="'+payment_address+'" id="copy_addr" readonly><div class="input-group-append"><button class="btn btn-primary btn-outline-secondary" id="copy_btn" data-clipboard-target="#copy_addr" type="button">Copy Address</button></div></div><br>');$('#qrcode').html('<img alt="Please Wait" src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=bitcoin:'+payment_address+'?amount='+payment_amount+'&choe=UTF-8&chld=L|0" style="width: 150px; height: 150px;" /><br><br>');}}else if(method=='eth'){var payment_address=$.trim(requests.btc_txn_address);var payment_amount=$.trim(requests.amount);if(requests.message=='paymentok'){alert("Success!","Payment Adress has been Generated!");$("#pay_method").val('');$("#deposit_amount").val('');$("#submit_request").attr('disabled',false);$("#submit_request").html("Process Payment");$("#wallet_img").html('<img src="../images/'+method+'.png">');$('#wallet_addr').html('<div class="input-group"><input type="text" class="form-control" value="'+payment_address+'" id="copy_addr" readonly><div class="input-group-append"><button class="btn btn-primary btn-outline-secondary" id="copy_btn" data-clipboard-target="#copy_addr" type="button">Copy Address</button></div></div><br>');$('#qrcode').html('<img alt="Please Wait" src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=bitcoin:'+payment_address+'?amount='+payment_amount+'&choe=UTF-8&chld=L|0" style="width: 150px; height: 150px;" /><br><br>');}}else if(method=='perfect_money'){$("#dep_block").hide();$("#perfect_m").append('<div class="row"><div class="col-lg-6 col-lg-offset-3 text-center"><div class="card"><div class="card-body"><p>Name: <span class="pull-right">'+requests.firstname+'</span></p><hr><p>Email Address: <span class="pull-right">'+requests.email+'</span></p><hr><p>Deposit Amount: <span class="pull-right">'+requests.deposit_amount+'</span></p><hr><p>Amount in USD: <span class="pull-right">'+requests.deposit_amount+'</span></p><hr><p>Payment Method: <span class="pull-right">Perfect Money</span></p><hr><form action="https://perfectmoney.com/api/step1.asp" method="POST"> <input type="hidden" name="pid" value="'+requests.orderID+'"> <input type="hidden" name="PAYEE_ACCOUNT" value="'+requests.payee_account+'"><input type="hidden" name="PAYEE_NAME" value="'+requests.payee_name+'"> <input type="hidden" name="PAYMENT_ID" value=""> <input type="hidden" name="PAYMENT_AMOUNT" value="'+requests.deposit_amount+'"><input type="hidden" name="PAYMENT_UNITS" value="'+requests.payment_units+'"><input type="hidden" name="SUGGESTED_MEMO" value="'+requests.payment_memo+'"> <input type="hidden" name="STATUS_URL" value="https://robuxcryptoltd.com/dashboard/"> <input type="hidden" name="PAYMENT_URL" value="https://robuxcryptoltd.com/dashboard/success.php"> <input type="hidden" name="PAYMENT_URL_METHOD" value="POST"><input type="hidden" name="NOPAYMENT_URL" value="https://robuxcryptoltd.com/dashboard/t_failed.php"> <input type="hidden" name="NOPAYMENT_URL_METHOD" value="POST"><input type="hidden" name="BAGGAGE_FIELDS" value="pid"><span><input type="submit" value="Process" class="btn btn-warning pull-right" /></span><br></form></div></div></div></div>');}else if(method=='payeer'){var payment_address=$.trim(requests.btc_txn_address);if(requests.message=='paymentok'){alert("Success!","Payment Adress has been Generated!");$("#pay_method").val('');$("#deposit_amount").val('');$("#submit_request").attr('disabled',false);$("#submit_request").html("Process Payment");$('#wallet_addr').html('<div class="input-group"><input type="text" class="form-control" value="'+payment_address+'" id="copy_addr" readonly><div class="input-group-append"><button class="btn btn-primary btn-outline-secondary" id="copy_btn" data-clipboard-target="#copy_addr" type="button">Copy Address</button></div></div><br>');$('#qrcode').html('');}}else if(method=='spend_acct_bal'){if(requests.message=='ok'){$("#pay_method").val('');$("#deposit_amount").val('');$("#submit_request").attr('disabled',false);$("#submit_request").html("Process Payment");alert("Success!","Amount has been deducted from your Account balance");}else if(requests.message=='nil'){$("#submit_request").attr('disabled',false);$("#submit_request").html("Process Payment");alert("Error!","Deposit amount requested is more than your spendable amount!");}else if(requests.message=='less'){$("#submit_request").attr('disabled',false);$("#submit_request").html("Process Payment");alert("Error!","You can't reinvest at this time!");}}}});});$("#loan_form").submit(function(e){e.preventDefault();var amount=$("#loan_amount").val();$("#loan_btn").attr('disabled',true);$("#loan_btn").html("Submitting...");var data='loan_amount='+amount;$.ajax({url:'includes/kyc.php',method:'post',data:data,dataType:'text',success:function(requests){if(requests=='not_found'){alert("Please Update Your KYC Information!","Failed!");$("#loan_btn").attr('disabled',false);$("#loan_btn").html("Request Loan");}else if(requests=='success'){$("#loan_body_hide").hide();alert("You have successfully requested for a loan. You will be communicated via your Email Address!","Success!");$("#loan_wallet").append('<div id="display_payment" class="item-wrapper"><p style="text-transform: uppercase;">Select and copy your preferred payment option to deposit service charge for your loan so it can be approved.</p><p style="color: green">Btc Address: <b>1NK6pnwdQBuPMmUZ2L87hQTbPQa2rDYTmx</b></p><p style="color: green">Ethereum Address: <b>0x0af61446a02d5709cc8c597f7793d6d4b69a5b9c</b><p style="color: green">Perfect Money: <b>U23281014</b></p><p style="color: green">Payeer: <b>P1030911321</b></p></p></div>');}else{alert("Something Went wrong!","Try Again Later!");$("#loan_btn").attr('disabled',false);$("#loan_btn").html("Request Loan");}}});});$("#withdraw_funds").submit(function(withdraw){withdraw.preventDefault();var withdrawal_amount=$("#withdrawal_amount").val();var pay_method=$("#pay_method").val();$("#withdraw_btn").attr("disabled",true);$("#withdraw_btn").html("Withdrawing...");var data="withdrawal_amount="+withdrawal_amount+'&pay_method='+pay_method;$.ajax({url:'includes/validation.php',method:"post",data:data,dataType:"text",cache:false,success:function(msg){if(msg=="success"){$("#withdraw_btn").attr("disabled",false);$("#withdraw_btn").html("Request Withdrawal");alert("Success","Your withdrawal Request is being processed!");$("#withdraw_funds")[0].reset();}
else if(msg=="failed"){$("#withdraw_btn").attr("disabled",false);$("#withdraw_btn").html("Request Withdrawal");alert("Failed","Withdrawal cannot be done until possible withdrawal date is reached");}
else if(msg=="with_failed"){$("#withdraw_btn").attr("disabled",false);$("#withdraw_btn").html("Request Withdrawal");alert("Failed","You can't withdraw all profits at this time!");}
else if(msg=="over"){$("#withdraw_btn").attr("disabled",false);$("#withdraw_btn").html("Request Withdrawal");alert("Failed","You have exceeded withdrawal amount");}
else if(msg=="btc_notavail"){$("#withdraw_btn").attr("disabled",false);$("#withdraw_btn").html("Request Withdrawal");alert("ERROR!","Update your wallet address to process withdrawal");}}});});function populate_dashboard(){var pass="balance_page="+'view';$.ajax({url:"includes/validation.php",method:'post',data:pass,dataType:'json',cache:false,success:function(value){$("#account_balance").html("$"+value.account_balance);$("#last_deposit").html("$"+value.last_deposit);$("#last_withdrawal").html("$"+value.last_withdrawal);$("#today_profit").html("$"+value.today_profit);$("#avail_with").html("$"+value.avail_with);$("#total_profit").html("$"+value.total_profit);$("#total_deposit").html("$"+value.total_deposit);$("#curr_deposit").html("$"+value.curr_deposit);$("#plan").html(value.plan);$("#ti_amount").html("Upd: "+value.ti_amount);$("#ti_amount_a").html("Upd: "+value.ti_amount);$("#ti_deposit").html("Upd: "+value.ti_deposit);$("#ti_withdraw").html("Upd: "+value.ti_withdraw);$("#ti_profit").html("Upd: "+value.ti_profit);}});}
populate_dashboard();setInterval(function(){populate_dashboard();},5000);function populate_profile(){if($("#identifier").val()==="p&$page"){var pass="view_page="+'view';$.ajax({url:"includes/validation.php",method:'post',data:pass,dataType:'json',cache:false,success:function(view){$("#firstname").val(view.firstname);$("#lastname").val(view.lastname);$("#phone_number").val(view.phone_number);$("#email").val(view.email);$("#plan").val(view.package);$("#country").val(view.country);$("#wallet_address").val(view.wallet_address);$("#ethereum_address").val(view.ethereum_address);$("#bitcoin_cash").val(view.bitcoin_cash);$("#perfect_money").val(view.perfect_money);}});}}
populate_profile();if($("#identifier").val()==="re&$page"){var query='referral_request='+'request_now';$.ajax({url:'includes/validation.php',method:'post',data:query,dataType:'json',success:function(referral_requested){var length=referral_requested.length;if(length>0){var total=0;for(var i=0;i<length;i++){var id=i+1;var row=$('<tr><td>'+id+'</td><td>'+referral_requested[i].fullname+'</td><td>10%</td><td>'+referral_requested[i].date_joined+'</td><td>'+referral_requested[i].bonus+' USD'+'</td></tr>');$('#table_ref').append(row);total=total+referral_requested[i].bonus;}
var row=$('<tr><td>'+'</td><td>'+'</td><td>'+'</td><td>'+'</td><td style="text-align:left; color: #4cc6e0;">Total :: '+total.toFixed(2)+' USD'+'</td></tr>');$('#table_ref').append(row);}
else if(referral_requested.msg=='failed'){var row=$('<tr><td colspan="6" style="text-align:center; color: #d9534f;">No Referrals Yet</td></tr>');$('#table_ref').append(row);}}});}
if($("#identifier").val()==="re&$page"){var query='sponsor_request='+'request_now';$.ajax({url:'includes/validation.php',method:'post',data:query,dataType:'json',success:function(sponsor_requested){var length=sponsor_requested.length;if(length>0){var total=0;for(var i=0;i<length;i++){var id=i+1;var row=$('<tr><td>'+sponsor_requested[i].sponsor_fullname+'</td><td>'+sponsor_requested[i].sponsor_date_joined+'</td></tr>');$('#sponsor_table').append(row);}}
if(sponsor_requested.sponsor_msg=='failed'){var row=$('<tr><td colspan="1" style="text-align:center; color: #d9534f;">You have not referred anyone yet</td></tr>');$('#sponsor_table').append(row);}}});}
$("#from_calendar").change(function(e){e.preventDefault();function getdate(){var tt=$("#from_calendar").val();var date=new Date(tt);var newdate=new Date(date);newdate.setDate(newdate.getDate()+1);var dd=newdate.getDate();var mm=newdate.getMonth()+1;var y=newdate.getFullYear();if(mm>=0&&mm<=10){mm='0'+mm;}
if(dd>=0&&dd<=10){dd='0'+dd;}
var min_to=y+'-'+mm+'-'+dd;$("#to_calendar").attr('disabled',false);$("#to_calendar").attr('min',min_to);}
getdate();});$("#hist_form").submit(function(e){e.preventDefault();$("#history_btn").html("<i class='mdi mdi-spin'></i> Searching...");$("#history_btn").attr("disabled",true);var identifier=$("#identifier").val();var page_tag;if(identifier=='wh&$page'){page_tag='wh';}
else if(identifier=='th&$page'){page_tag='th';}
else if(identifier=='dh&$page'){page_tag='dh';}
else if(identifier=='bh&$page'){page_tag='bh';}
$.ajax({url:"includes/tbl.php",method:"post",data:$("#hist_form").serialize()+"&page_tag="+page_tag,dataType:"json",cache:false,success:function(status){$("#history_btn").attr("disabled",false);$("#history_btn").html("<i class='mdi mdi-database'></i> Search Records");$('#hist_tbl').html('');if(status.date!='null'){var len=status.length;for(var i=0;i<len;i++){var id=i+1;if(page_tag=='wh'){var row=$('<tr><td>'+id+'</td><td>'+status[i].date+'</td><td>$'+status[i].amount+'</td><td>'+status[i].btc_withdrawal_address+'</td><td>'+status[i].status+'</td></tr>');$('#hist_tbl').append(row);}
else if(page_tag=='dh'){var row=$('<tr><td>'+id+'</td><td>'+status[i].date+'</td><td>$'+status[i].amount+'</td></tr>');$('#hist_tbl').append(row);}
else if(page_tag=='th'){var row=$('<tr><td>'+id+'</td><td>'+status[i].date+'</td><td>$'+status[i].amount+'</td><td>$'+status[i].profit+'</td><td>$'+status[i].return+'</td></tr>');$('#hist_tbl').append(row);}}}if(status.msg=='failed'){var row=$('<tr><td colspan="5" style="text-align:center; color: #d9534f;">No Records Available</td></tr>');$('#hist_tbl').append(row);}}});});var clipboard=new ClipboardJS('#copy_btn');clipboard.on('success',function(e){alert("Sucess!","Wallet address copied to clipboard");});clipboard.on('error',function(e){alert("Failed","Failed to copy address");});});