<?php
ob_start();
(@include ('../dt_page/lic.php')) or die("<script>alert(\"You not have a license to use this script on this domain, Please contact www.primadesain.com to purchase a license.\");"."window.location = './index.php'</script>");
$lic=$license;if(!$lic){echo "<script>alert(\"You not have a license to use this script on this domain, Please contact www.primadesain.com to purchase a license.\");"."window.location = './index.php'</script>";}
if (basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__)){
echo "<p align=center><br><br><br><br><br><br><font size=\"6\" color=\"#FF0000\">ILLEGAL ACCESS !!";
echo "<meta http-equiv=\"refresh\" content=\"2; url=../index.php\">";
exit();} 
?>  
  <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <?php echo $currencye; ?> Wallet 
      </h1>
      <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="breadcrumb-item active"><?php echo $currencye; ?> Wallet</li>
      </ol>
    </section>


    <section class="content">
      

<?php
if($db->dataku("status", $user_session) == 0 || $db->dataku("blokir", $user_session) == 1) {
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["status0"]."</div>";
}else{
?>
<?php if($showecash == 1){ ?>



<? if (isset($_GET['page']) && $_GET['page'] == "transfer") {?>

  <div class="row">
                <div class="col-md-4">
                
                   <div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">Transfer</h3>
            </div>
            <div class="box-body">      
  <?php
 if(isset($_GET['result'])&&$_GET['result']=="success_add"){
if(isset($_GET["co"])){ $co = anti_injection(base64_decode($_GET["co"])); }
if(isset($_GET["ca"])){ $ca = anti_injection(base64_decode($_GET["ca"])); }
if(isset($_GET["cd"])){ $cd = anti_injection(base64_decode($_GET["cd"])); }
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Transfer ".$currencye." Balance no ".$co." to user ".$cd." has been sent.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="nocrossline"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You can only transfer ".$currencye." Balance to upline or downline, not to crossline.</div>";
}
?>

<?php
 if(isset($_GET['result'])&&$_GET['result']=="no_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_NO_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="wrong_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_WRONG_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_lock"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_BLOCK_PIN."</div>";
}
?>  

 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_off"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_OFF_PIN."</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="min_trans"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Min transfer ".$currencye." Balance is ".rupiah($mintranswalletcash).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_trans"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max transfer ".$currencye." Balance is ".rupiah($maxtranswalletcash).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pending"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You still have a ".$currencye." Balance transfer transaction previously pending status. Wait until the transaction is processed in order to be able to transfer ".$currencye." Balance again.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="nouser"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Users want to transfer can not be empty.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="usernotfound"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Transfer destination user is not found.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="errors"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You can not transfer ".$currencye." balance to your self.</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="insufficient"){
$mx = $_GET['mx'];
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Your ".$currencye." Balance is insufficient, max transfer is ".rupiah($mx).".</div>";
}
?>
   <?php
$results = $_GET['result'];
if($results == "wrong_auth") { 
echo "<div class='alert alert-danger'>You're enable two factor authentication at your account, Please enter your google authenticator six-digit code!</div>";
}
?>  
 <?php
$results = $_GET['result'];
if($results == "unverified") { 
echo "<div class='alert alert-danger'>Your account is not verified!</div>";
}
?>  

 		<?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_captcha"){
echo "<div class='alert alert-danger'>Wrong Captcha!</div>";
}
?>	 
 
 
 
 
 <?php if($usekyc == 1 && $db->dataku("accpt", $user_session) == 0){ 
				 echo "<div align='center'><img src='../themes/img/unverified.png' width='100' height='100' /><br><p style='font-weight:bold; font-size:20px;margin-top:5px;'>UNVERIFIED</p>Transfer ".$currencye." Balance is disable, to be able transfer your ".$currencye." Balance you must verification first.<br><br><a href='index.php?go=kyc'><button class='btn btn-danger btn-xs' type='button'>Click Here</button></a><br><br></div>";
				  //echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>"; 
				  }else{
				 
				  ?>    
               
                 <?php  if($transwalletcash == 0){ 
				 echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Transfer ".$currencye." Balance has been disable by administrator.</div>";
				 $diss3=" disabled='disabled'";
}else{
	$diss3="";
}
				 
				  ?>
                                	
      <?php    
$initialex = substr(str_shuffle(str_repeat("ABEF123456789GHIJKLMNPR123456789KLEFGHILMNP123456789RRSTUVWXYZ", 46)), 22, 12);
?>           

         
<script type="text/javascript">
 
        function isNumberKey(evt, obj) {
 
            var charCode = (evt.which) ? evt.which : event.keyCode
            var value = obj.value;
            var dotcontains = value.indexOf(".") != -1;
            if (dotcontains)
                if (charCode == 46) return false;
            if (charCode == 46) return true;
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }
 

 
    </script>       
 <script>
		function confirmtransfer(){
      var session_value=document.getElementById('tujuan').value;
      var session_valuex=document.getElementById('amount').value;
      var confirmed = confirm("Are you sure you want to transfer <?php echo $currencye; ?> Balance:" + "\n" + "Amount: "+session_valuex+"\n" + "Transfer To User ID: "+session_value);
      return confirmed;
}
</script>    
<form method="post" id="tab2" name="transfer" action="?go=walletcash&page=trans_balance_cek">
<input type="hidden" id="kode" name="kode" value="<?php echo $initialex; ?>"/>
<input type="hidden" id="user" name="user" value="<?php echo $user_session; ?>"/>
<input type="hidden" id="fee" name="fee" value="<?php echo $feetranswalletcash; ?>"/>
<input type="hidden" id="accid" name="accid" value="<?php echo $db->dataku("accid", $user_session); ?>"/>


         
          <div class="controls-row" style="margin-top:10px;">

            <label>Available Balance</label>
              <div class="input-group">
                   <span class="input-group-addon" id="basic-addon1"><?php echo $currencye; ?></span>
            <?php 
			 
			 $saldobwallete = $db->mycwalet($user_session);
			 $pendingbwallete = $db->mycwaletpending($user_session);
			 $totalbwalete = $saldobwallete-$pendingbwallete;
			 if($totalbwalete > 0){
			 ?>
            <input type="text" value="<?php echo rupiah($totalbwalete); ?>" style='background-color:#009F50; color:#FFF;' class="form-control"/>
            <?php }else{ ?>
            <input type="text" value="No Balance" style='background-color:#DF0000; color:#FFF;' class="form-control"/>
            <?php } ?>
          </div></div>

          <div class="controls-row" style="margin-top:10px;">

            <label>Username Recipient</label>


           <input name="tujuan" class="form-control" id="tujuan"  placeholder="Username Recipient" required='required' <?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>
           <div id="uname_response" style="margin-top:5px;"></div>
          </div>
         

          <div class="controls-row" style="margin-top:10px;">

            <label>Amount Transfered</label>
               <div class="input-group">
                   <span class="input-group-addon" id="basic-addon1"><?php echo $currencye; ?></span>

           <input name="amount" type="number" placeholder="Enter Amount"  class="form-control" id="amount" onkeypress="return isNumberKey(event,this)" required='required' autocomplete="off" <?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>

          </div> </div> 
        
            <?php if($usepins == 1){ ?>
          <div class="controls-row" style="margin-top:10px;">

            <label>Secure PIN</label>

           <input name="pincode" class="form-control" id="pincode" placeholder="Enter Your Secure PIN" type="password" required='required' autocomplete="off"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>

          </div> 
          <?php } ?>

<?php if($db->dataku("authgoogle", $user_session) == 1){ ?>
         
          <div class="controls-row" style="margin-top:10px;">

            <label>2FA Code</label>

           <input type="text" class="form-control" placeholder="Hanya jika anda mengaktifkan 2FA" name="one_time_password">
                                                          

          </div>
          <?php } ?>
 <div>

           &nbsp;

          </div>
          <div>
        
<button type='submit' class='btn btn-<?php echo $buttone; ?>' name="addbalance" <?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>Transfer</button> 

          </div>

        </form>
        
        
      
<script src="../assets/global/plugins/jquery.min.js" type="text/javascript"></script>
  
 <SCRIPT type="text/javascript">
  
  
 $(document).ready(function(){

   $("#tujuan").keyup(function(){

     var tujuan = $(this).val().trim();

     if(tujuan != ''){
		 
$("#uname_response").html('&nbsp;<img src="../images/load.gif" align="absmiddle">&nbsp;&nbsp;Checking Username...');

        $.ajax({
           url: '../dt_page/checkuser.php',
           type: 'post',
           data: {tujuan:tujuan},
           success: function(response){

              $("#uname_response").html(response);

           }
        });
     }else{
        $("#uname_response").html("");
     }

  });

}); 
  
  
//-->
</SCRIPT>         
        
        
        
         <div class="controls-row" style="margin-top:10px;">
        <div class='alert alert-info alert-dismissable'><i class="fa fa-info-circle"></i>&nbsp;<strong>Notice:</strong><br>Min <?php echo rupiah($mintranswalletcash); ?>, Max <?php echo rupiah($maxtranswalletcash); ?>, Fee <?php echo $feetranswalletcash; ?>%.</div></div>
        <?php } ?>
        
                </div></div>
                   <div class="row">
                   
                   
                   	
                   </div>
                </div><!--end .col-->
                
            <div class="col-md-8">
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">Transfer History</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">
                                      <thead class="bg-primary-600">
                                            <tr>
                            <th width="15%"><?php echo $LANG["date"]?></th>
							<th width="15%">To</th>
							<th width="20%"><?php echo $LANG["amount"]?></th>
							<th width="25%"><?php echo $LANG["news"]?></th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
<?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, jenis, fee, jumlahnet", "datacwalet2c", "username='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[2] == "admin-1") {
				$user = "admin";
			} else {
				$user = $row[2];
			}		
			if($row[4] == $user_session) {
				$ket = "$row[1]";
			} else {
				$ket = 	"$row[1]";
			}
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[6] > 0) {
				$st = "<span class='btn btn-success btn-xs'>Done</span>";
				$style = "<font>";
			} else {
				$st = "<span class='btn btn-danger btn-xs'>Pending</span>";
			
	   $style = "<font color='#F00000'>";
			}	
			$tt = $row[5];
				
			$cdo = $row[0];		
$sqlc = mysql_query("SELECT * FROM invoice WHERE kode='$cdo'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$invc = $rowc['file'];				
				
?>
     	<tr>
							<td align="center"><?php echo $style; ?><?= $tt; ?></font></td>
							<td align="center"><?php echo $style; ?><?= $row[4]; ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[3]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= $ket; ?></font></td>
                         
							<td align="center"><?php echo $style; ?><?= $st; ?></font></td>
						  </tr> 
	 
 

	<?
	
		}
	?>

                                                                                </tbody>
                                    </table>
                                    </div>
                                </div>
<input type=hidden id='clr' value='yellow'>
                            <div class="clearfix"></div>
                        </div>
                        </div>
                    </div><!-- End .panel -->        
   



































<? }else if (isset($_GET['page']) && $_GET['page'] == "trans_balance_cek") {
	
	
if($usekyc == 1 && $db->dataku("accpt", $user_session) == 0){
header("location: index.php?go=walletcash&page=transfer&result=unverified");
exit;
} else {		


	  $authgoogles=$db->dataku("authgoogle", $user_session);
$code    = anti_injection($_POST['one_time_password']);	  
$result  = $authenticator->verifyCode($secret,$code,$tolerance);
if($googleauntentic == 1 && $authgoogles == 1 && !$result){
header("location: index.php?go=walletcash&page=transfer&result=wrong_auth");
exit;
} else {	


$pincods = md5($_POST['pincode']);	
$sqlc = mysql_query("SELECT * FROM pincode WHERE username='$user_session'");
$numc = mysql_num_rows($sqlc);
while($rowc = mysql_fetch_array($sqlc)){
$tgl = formatgl($rowc['tgl']);
$pin = $rowc['pin'];
$sts = $rowc['status'];
$lock = $rowc['locks'];
	}
	if($usepins == 1 && !$numc) {
	header("location: index.php?go=walletcash&page=transfer&result=no_pin");
	exit;
} else {
if($usepins == 1 && !$pincods || $usepins == 1 && $pincods <> $pin) {
	header("location: index.php?go=walletcash&page=transfer&result=wrong_pin");
	exit;
} else {
if($usepins == 1 && $lock == 1) {
	header("location: index.php?go=walletcash&page=transfer&result=pin_lock");
exit;
	} else {
if($usepins == 1 && $sts == 0) {
	header("location: index.php?go=walletcash&page=transfer&result=pin_off");
	exit;
} else {	
	
$username = anti_injection($_POST['user']);	
$kode = anti_injection($_POST['kode']);	
$amount = anti_injection($_POST['amount']);	
$fee = anti_injection($_POST['fee']);	
$uraiannya = anti_injection($_POST['uraian']);	
//$accid = anti_injection($_POST['accid']);
$tujuan = anti_injection($_POST['tujuan']);	


$queryupline = "SELECT username FROM upline WHERE 
username='$username' and upline0='$tujuan' or 
username='$username' and upline1='$tujuan' or username='$username' and upline2='$tujuan' or 
username='$username' and upline3='$tujuan' or username='$username' and upline4='$tujuan' or 
username='$username' and upline5='$tujuan' or username='$username' and upline6='$tujuan' or 
username='$username' and upline7='$tujuan' or username='$username' and upline8='$tujuan' or 
username='$username' and upline9='$tujuan' or username='$username' and upline10='$tujuan' or 
username='$username' and upline11='$tujuan' or username='$username' and upline12='$tujuan' or 
username='$username' and upline13='$tujuan' or username='$username' and upline14='$tujuan' or 
username='$username' and upline15='$tujuan' or username='$username' and upline16='$tujuan' or 
username='$username' and upline17='$tujuan' or username='$username' and upline18='$tujuan' or 
username='$username' and upline19='$tujuan' or username='$username' and upline20='$tujuan' or 
username='$username' and upline21='$tujuan' or username='$username' and upline22='$tujuan' or 
username='$username' and upline23='$tujuan' or username='$username' and upline24='$tujuan' or 
username='$username' and upline25='$tujuan' or username='$username' and upline26='$tujuan' or 
username='$username' and upline27='$tujuan' or username='$username' and upline28='$tujuan' or 
username='$username' and upline29='$tujuan' or username='$username' and upline30='$tujuan' or 
username='$username' and upline31='$tujuan' or username='$username' and upline32='$tujuan' or 
username='$username' and upline33='$tujuan' or username='$username' and upline34='$tujuan' or 
username='$username' and upline35='$tujuan' or username='$username' and upline36='$tujuan' or 
username='$username' and upline37='$tujuan' or username='$username' and upline38='$tujuan' or 
username='$username' and upline39='$tujuan' or username='$username' and upline40='$tujuan' or 
username='$username' and upline41='$tujuan' or username='$username' and upline42='$tujuan' or 
username='$username' and upline43='$tujuan' or username='$username' and upline44='$tujuan' or 
username='$username' and upline45='$tujuan' or username='$username' and upline46='$tujuan' or 
username='$username' and upline47='$tujuan' or username='$username' and upline48='$tujuan' or 
username='$username' and upline49='$tujuan' or username='$username' and upline50='$tujuan' or 
username='$username' and upline51='$tujuan' or username='$username' and upline52='$tujuan' or 
username='$username' and upline53='$tujuan' or username='$username' and upline54='$tujuan' or 
username='$username' and upline55='$tujuan' or username='$username' and upline56='$tujuan' or 
username='$username' and upline57='$tujuan' or username='$username' and upline58='$tujuan' or 
username='$username' and upline59='$tujuan' or username='$username' and upline60='$tujuan' or 
username='$username' and upline61='$tujuan' or username='$username' and upline62='$tujuan' or 
username='$username' and upline63='$tujuan' or username='$username' and upline64='$tujuan' or 
username='$username' and upline65='$tujuan' or username='$username' and upline66='$tujuan' or 
username='$username' and upline67='$tujuan' or username='$username' and upline68='$tujuan' or 
username='$username' and upline69='$tujuan' or username='$username' and upline70='$tujuan' or 
username='$username' and upline71='$tujuan' or username='$username' and upline72='$tujuan' or 
username='$username' and upline73='$tujuan' or username='$username' and upline74='$tujuan' or 
username='$username' and upline75='$tujuan' or username='$username' and upline76='$tujuan' or 
username='$username' and upline77='$tujuan' or username='$username' and upline78='$tujuan' or 
username='$username' and upline79='$tujuan' or username='$username' and upline80='$tujuan' or 
username='$username' and upline81='$tujuan' or username='$username' and upline82='$tujuan' or 
username='$username' and upline83='$tujuan' or username='$username' and upline84='$tujuan' or 
username='$username' and upline85='$tujuan' or username='$username' and upline86='$tujuan' or 
username='$username' and upline87='$tujuan' or username='$username' and upline88='$tujuan' or 
username='$username' and upline89='$tujuan' or username='$username' and upline90='$tujuan' or 
username='$username' and upline91='$tujuan' or username='$username' and upline92='$tujuan' or 
username='$username' and upline93='$tujuan' or username='$username' and upline94='$tujuan' or 
username='$username' and upline95='$tujuan' or username='$username' and upline96='$tujuan' or 
username='$username' and upline97='$tujuan' or username='$username' and upline98='$tujuan' or 
username='$username' and upline99='$tujuan' or username='$username' and upline100='$tujuan'"; 
$resultupline = mysql_query($queryupline);
$ada_upline = mysql_num_rows($resultupline); 


$querydownline = "SELECT username FROM upline WHERE 
username='$tujuan' and upline0='$username' or 
username='$tujuan' and upline1='$username' or username='$tujuan' and upline2='$username' or 
username='$tujuan' and upline3='$username' or username='$tujuan' and upline4='$username' or 
username='$tujuan' and upline5='$username' or username='$tujuan' and upline6='$username' or 
username='$tujuan' and upline7='$username' or username='$tujuan' and upline8='$username' or 
username='$tujuan' and upline9='$username' or username='$tujuan' and upline10='$username' or 
username='$tujuan' and upline11='$username' or username='$tujuan' and upline12='$username' or 
username='$tujuan' and upline13='$username' or username='$tujuan' and upline14='$username' or 
username='$tujuan' and upline15='$username' or username='$tujuan' and upline16='$username' or 
username='$tujuan' and upline17='$username' or username='$tujuan' and upline18='$username' or 
username='$tujuan' and upline19='$username' or username='$tujuan' and upline20='$username' or 
username='$tujuan' and upline21='$username' or username='$tujuan' and upline22='$username' or 
username='$tujuan' and upline23='$username' or username='$tujuan' and upline24='$username' or 
username='$tujuan' and upline25='$username' or username='$tujuan' and upline26='$username' or 
username='$tujuan' and upline27='$username' or username='$tujuan' and upline28='$username' or 
username='$tujuan' and upline29='$username' or username='$tujuan' and upline30='$username' or 
username='$tujuan' and upline31='$username' or username='$tujuan' and upline32='$username' or 
username='$tujuan' and upline33='$username' or username='$tujuan' and upline34='$username' or 
username='$tujuan' and upline35='$username' or username='$tujuan' and upline36='$username' or 
username='$tujuan' and upline37='$username' or username='$tujuan' and upline38='$username' or 
username='$tujuan' and upline39='$username' or username='$tujuan' and upline40='$username' or 
username='$tujuan' and upline41='$username' or username='$tujuan' and upline42='$username' or 
username='$tujuan' and upline43='$username' or username='$tujuan' and upline44='$username' or 
username='$tujuan' and upline45='$username' or username='$tujuan' and upline46='$username' or 
username='$tujuan' and upline47='$username' or username='$tujuan' and upline48='$username' or 
username='$tujuan' and upline49='$username' or username='$tujuan' and upline50='$username' or 
username='$tujuan' and upline51='$username' or username='$tujuan' and upline52='$username' or 
username='$tujuan' and upline53='$username' or username='$tujuan' and upline54='$username' or 
username='$tujuan' and upline55='$username' or username='$tujuan' and upline56='$username' or 
username='$tujuan' and upline57='$username' or username='$tujuan' and upline58='$username' or 
username='$tujuan' and upline59='$username' or username='$tujuan' and upline60='$username' or 
username='$tujuan' and upline61='$username' or username='$tujuan' and upline62='$username' or 
username='$tujuan' and upline63='$username' or username='$tujuan' and upline64='$username' or 
username='$tujuan' and upline65='$username' or username='$tujuan' and upline66='$username' or 
username='$tujuan' and upline67='$username' or username='$tujuan' and upline68='$username' or 
username='$tujuan' and upline69='$username' or username='$tujuan' and upline70='$username' or 
username='$tujuan' and upline71='$username' or username='$tujuan' and upline72='$username' or 
username='$tujuan' and upline73='$username' or username='$tujuan' and upline74='$username' or 
username='$tujuan' and upline75='$username' or username='$tujuan' and upline76='$username' or 
username='$tujuan' and upline77='$username' or username='$tujuan' and upline78='$username' or 
username='$tujuan' and upline79='$username' or username='$tujuan' and upline80='$username' or 
username='$tujuan' and upline81='$username' or username='$tujuan' and upline82='$username' or 
username='$tujuan' and upline83='$username' or username='$tujuan' and upline84='$username' or 
username='$tujuan' and upline85='$username' or username='$tujuan' and upline86='$username' or 
username='$tujuan' and upline87='$username' or username='$tujuan' and upline88='$username' or 
username='$tujuan' and upline89='$username' or username='$tujuan' and upline90='$username' or 
username='$tujuan' and upline91='$username' or username='$tujuan' and upline92='$username' or 
username='$tujuan' and upline93='$username' or username='$tujuan' and upline94='$username' or 
username='$tujuan' and upline95='$username' or username='$tujuan' and upline96='$username' or 
username='$tujuan' and upline97='$username' or username='$tujuan' and upline98='$username' or 
username='$tujuan' and upline99='$username' or username='$tujuan' and upline100='$username'"; 
$resultdownline = mysql_query($querydownline);
$ada_downline = mysql_num_rows($resultdownline); 
	
	
if(!$ada_upline && !$ada_downline){	
	    header("location: index.php?go=walletcash&page=transfer&result=nocrossline");
	exit;
	
      } else {		

if (!$tujuan) {
        header("location: index.php?go=walletcash&page=transfer&result=nouser");
	exit;
      } else {
		  
if ($username == $tujuan) {
        header("location: index.php?go=walletcash&page=transfer&result=nosame");
	exit;
      } else {	

$saldobwallete = $db->mycwalet($user_session);
$pendingbwallete = $db->mycwaletpending($user_session);
$jmlsaldone = $saldobwallete-$pendingbwallete;

$fee = $_POST['fee'];
$jumlah=$amount;	

$jml_fee=($fee/100)*$amount;
$jml_fee=sprintf("%.2f",$jml_fee);

$jml_byr=$amount-$jml_fee;
$jml_byr=sprintf("%.2f",$jml_byr);
$jmlfeex = rupiah($jml_fee);
$jmlrecx = rupiah($jml_byr);


if ($amount > $jmlsaldone) {
        header("location: index.php?go=walletcash&page=transfer&result=insufficient&mx=$jmlsaldone");
	exit;
      } else {		 

$db->select("status", "datacwalet2c", "status='0' and username='$username'");
				$ada = $db->num_rows();
if ($ada >0) {
  header("location: index.php?go=walletcash&page=transfer&result=pending");
	exit;
} else {


	  
		  
$cektujuan = mysql_query("select * from member where username='$tujuan'");
$ada_tujuan = mysql_num_rows($cektujuan); //---flush out hari ini
if (!$ada_tujuan) {
header("location: index.php?go=walletcash&page=transfer&result=usernotfound");
	exit;
}else{	

if (!$amount || $amount < $mintranswalletcash) {
        header("location: index.php?go=walletcash&page=transfer&result=min_trans");
	exit;
      } else {


$tgl_skr = (date("Y-m-d"));
			$dtfromnya = "$tgl_skr 00:00:00";
			$dttonya = "$tgl_skr 23:59:59";
  $cekjmlah=mysql_query("select SUM(jumlah) from datacwalet2c where username='$username' and (tgl between '$dtfromnya' and '$dttonya')");
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0];
		             }
$btsharinie=$maxtranswalletcash-$tothariini;
if ($amount > $btsharinie) {
        header("location: index.php?go=walletcash&page=transfer&result=max_trans");
	exit;
      } else {	  
	
	?>




 <div class="row">
                <div class="col-md-4">
                
                   <div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">Transfer</h3>
            </div>
            <div class="box-body"> 

 
 
 <?php if($usekyc == 1 && $db->dataku("accpt", $user_session) == 0){ 
				 echo "<div align='center'><img src='../themes/img/unverified.png' width='100' height='100' /><br><p style='font-weight:bold; font-size:20px;margin-top:5px;'>UNVERIFIED</p>Transfer ".$currencye." Balance is disable, to be able transfer your ".$currencye." Balance you must verification first.<br><br><a href='index.php?go=kyc'><button class='btn btn-danger btn-xs' type='button'>Click Here</button></a><br><br></div>";
				  //echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>"; 
				  }else{
				 
				  ?>    
               
                 <?php  if($transwalletcash == 0){ 
				 echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Transfer ".$currencye." Balance has been disable by administrator.</div>";
				 $diss3=" disabled='disabled'";
}else{
	$diss3="";
}
				 
				  ?>
         
<script type="text/javascript">
 
        function isNumberKey(evt, obj) {
 
            var charCode = (evt.which) ? evt.which : event.keyCode
            var value = obj.value;
            var dotcontains = value.indexOf(".") != -1;
            if (dotcontains)
                if (charCode == 46) return false;
            if (charCode == 46) return true;
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }
 

 
    </script>       
 <script>
		function confirmtransfer(){
      var session_value=document.getElementById('tujuan').value;
      var session_valuex=document.getElementById('amount').value;
      var confirmed = confirm("Are you sure you want to transfer <?php echo $currencye; ?> Balance:" + "\n" + "Amount: "+session_valuex+"\n" + "Transfer To User ID: "+session_value);
      return confirmed;
}
</script>    



          

<form method="post" id="tab2" name="transfer" action="?go=walletcash&page=trans_balance_go">

<input type="hidden" id="kode" name="kode" value="<?php echo $kode; ?>"/>
<input type="hidden" id="user" name="user" value="<?php echo $username; ?>"/>
<input type="hidden" id="fee" name="fee" value="<?php echo $fee; ?>"/>
<input type="hidden" id="accid" name="accid" value="<?php echo $accid; ?>"/>
<input type="hidden" id="tujuan" name="tujuan" value="<?php echo $tujuan; ?>"/>
<input type="hidden" id="uraiannya" name="uraiannya" value="<?php echo $uraiannya; ?>"/>
<input type="hidden" id="amount" name="amount" value="<?php echo $amount; ?>"/>

          <div class="controls-row" style="margin-top:10px;">

            <label>Amount Transfered</label>
<div class="input-group">
                   <span class="input-group-addon" id="basic-addon1"><?php echo $currencye; ?></span>
           <input name="" type="text" class="form-control" value="<?php echo rupiah($amount); ?>" disabled="disabled">

          </div> </div> 
       
       

          <div class="controls-row" style="margin-top:10px;">

            <label>Username Recipient</label>
        <input name="" type="text" class="form-control" value="<?php echo $tujuan; ?>" disabled="disabled">

          </div>
         
 <div class="controls-row" style="margin-top:10px;">

            <label>Name Recipient</label>
        <input name="" type="text" class="form-control" value="<?php echo $db->dataku("nama",$tujuan); ?>" disabled="disabled">

          </div>
         
    <div class="controls-row" style="margin-top:10px;">

            <label>Email Recipient</label>
        <input name="" type="text" class="form-control" value="<?php echo $db->dataku("email",$tujuan); ?>" disabled="disabled">

          </div>   
          
 <div>

           &nbsp;

          </div>
           <div class="controls-row" style="margin-top:10px;">
        <div class='alert alert-info alert-dismissable'><i class="fa fa-info-circle"></i>&nbsp;<strong>Notice:</strong><br>if it is appropriate please click Transfer
        </div> </div>  
          <hr />
          <div>
        <a href="index.php?go=walletcash&page=transfer"><button type="button" class="btn btn-danger"><i class="fa fa-undo"></i>&nbsp;Back</button></a>
<button type='submit' class='btn btn-<?php echo $buttone; ?>' name="addbalance" <?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>Transfer</button> 

          </div>

        </form>
       
        <?php } ?>
        
                </div></div>
                   <div class="row">
                   
                   
                   	
                   </div>
                </div><!--end .col-->
             <div class="col-md-8">
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">Transfer History</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">
                                      <thead class="bg-primary-600">
                                            <tr>
                            <th width="15%"><?php echo $LANG["date"]?></th>
							<th width="15%">To</th>
							<th width="20%"><?php echo $LANG["amount"]?></th>
							<th width="25%"><?php echo $LANG["news"]?></th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
<?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, jenis, fee, jumlahnet", "datacwalet2c", "username='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[2] == "admin-1") {
				$user = "admin";
			} else {
				$user = $row[2];
			}		
			if($row[4] == $user_session) {
				$ket = "$row[1]";
			} else {
				$ket = 	"$row[1]";
			}
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[6] > 0) {
				$st = "<span class='btn btn-success btn-xs'>Done</span>";
				$style = "<font>";
			} else {
				$st = "<span class='btn btn-danger btn-xs'>Pending</span>";
			
	   $style = "<font color='#F00000'>";
			}	
				$tt = $row[5];
				
			$cdo = $row[0];		
$sqlc = mysql_query("SELECT * FROM invoice WHERE kode='$cdo'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$invc = $rowc['file'];				
				
?>
     	<tr>
							<td align="center"><?php echo $style; ?><?= $tt; ?></font></td>
							<td align="center"><?php echo $style; ?><?= $row[4]; ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[3]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= $ket; ?></font></td>
                       
            
							<td align="center"><?php echo $style; ?><?= $st; ?></font></td>
						  </tr> 
	 
 

	<?
	
		}
	?>

                                                                                </tbody>
                                    </table>
                                    </div>
                                </div>
<input type=hidden id='clr' value='yellow'>
                            <div class="clearfix"></div>
                        </div>
                        </div>
                    </div><!-- End .panel -->        
   




<?
	
		}}}}}}}}}}}}}}
	?>




    
    
    

  
 
 <?php
 } else if (isset($_GET['page']) && $_GET['page'] == "trans_balance_go") {


$username = anti_injection($_POST['user']);	
$kode = anti_injection($_POST['kode']);	
$amount = anti_injection($_POST['amount']);	
$uraiannya = anti_injection($_POST['uraian']);	
//$accid = anti_injection($_POST['accid']);
$tujuan = anti_injection($_POST['tujuan']);

if (!$tujuan) {
        header("location: index.php?go=walletcash&page=transfer&result=nouser");
	exit;
      } else {
		  
if ($username == $tujuan) {
        header("location: index.php?go=walletcash&page=transfer&result=nosame");
	exit;
      } else {	


$saldobwallete = $db->mycwalet($user_session);
$pendingbwallete = $db->mycwaletpending($user_session);
$jmlsaldone = $saldobwallete-$pendingbwallete;

$fee = $_POST['fee'];
$jumlah=$amount;	

$jml_fee=($fee/100)*$amount;
$jml_fee=sprintf("%.2f",$jml_fee);

$jml_byr=$amount-$jml_fee;
$jml_byr=sprintf("%.2f",$jml_byr);
$jmlfeex = rupiah($jml_fee);
$jmlrecx = rupiah($jml_byr);


if ($amount > $jmlsaldone) {
        header("location: index.php?go=walletcash&page=transfer&result=insufficient&mx=$jmlsaldone");
	exit;
      } else {		 

$db->select("status", "datacwalet2c", "status='0' and username='$username'");
				$ada = $db->num_rows();
if ($ada >0) {
  header("location: index.php?go=walletcash&page=transfer&result=pending");
	exit;
} else {


	  
		  
$cektujuan = mysql_query("select * from member where username='$tujuan'");
$ada_tujuan = mysql_num_rows($cektujuan); //---flush out hari ini
if (!$ada_tujuan) {
header("location: index.php?go=walletcash&page=transfer&result=usernotfound");
	exit;
}else{	

if (!$amount || $amount < $mintranswalletcash) {
        header("location: index.php?go=walletcash&page=transfer&result=min_trans");
	exit;
      } else {


$tgl_skr = (date("Y-m-d"));
			$dtfromnya = "$tgl_skr 00:00:00";
			$dttonya = "$tgl_skr 23:59:59";
  $cekjmlah=mysql_query("select SUM(jumlah) from datacwalet2c where username='$username' and (tgl between '$dtfromnya' and '$dttonya')");
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0];
		             }
$btsharinie=$maxtranswalletcash-$tothariini;
if ($amount > $btsharinie) {
        header("location: index.php?go=walletcash&page=transfer&result=max_trans");
	exit;
      } else {	  
	
	
	
$db->insert("datacwalet2c", "", "'', '$kode', '$username', '$jumlah', '$uraian', '$tujuan', '$clientdate', '1', '$jenis', '$jml_fee', '$jml_byr', '$accid', '$accid2'");
//$db->insert("dataewalet2c", "", "'', '$kode', '$username', '$jumlah', '$uraian', '$tujuan', '$clientdate', '1', 'cash', '$jml_fee', '$jml_byr', '$accid', '$accid2'");		
	
	
if($fee > 0){	
$uraian1 = "Transfer Fee ".$fee."% (".rupiah($jml_fee).")";
}else{
$uraian1 = "Transfer";
}
		
$cekadane = mysql_query("select kode from datacwalet where kode='$kode'");
$ada_adane = mysql_num_rows($cekadane); 
if(!$ada_adane) {
$db->insert("datacwalet", "", "'', '$kode', '$username', '$jml_byr', '".mysql_real_escape_string($uraian1)."', '$tujuan', '$clientdate', 1, '$clientdate', '$accid', '$accid2'");		
if($jml_fee > 0){
$db->insert("datacwalet", "", "'', '$kode', '$username', '$jml_fee', '".mysql_real_escape_string($uraian1)."', 'administrator', '$clientdate', 1, '$clientdate', '$accid', 'administrator'"); 
}	
}	
	$spon_nama = $db->dataku("nama", $user_session);
		$spon_mail = $db->dataku("email", $user_session);
		$nama = $db->dataku("nama", $user_session);
		$jumlahdepone = rupiah($amount);
		$jumlahdeponec = rupiahwa($amount);
		$namadmin = $db->config("name");
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");


$sess = substr(str_shuffle(str_repeat("4453141119066764203711128717497783625536342396411241472162223777", 64)), 0, 22);
			$invc="TRANSFER".$user_session."_".$sess."_".$kode;
			$inv="http://".$domain."/invoice/".$invc.".pdf";
			$db->insert("invoice","","'', '$user_session', '$kode', '$invc', '$clientdate'");
			$nama_ku = $db->dataku("nama",$user_session);
			$email_ku = $db->dataku("email",$user_session);
			$hp_ku = $db->dataku("hp",$user_session);
			$nama_nya = $db->dataku("nama",$tujuan);
			$hptujuan = $db->dataku("hp",$tujuan);
			$emailtujuan = $db->dataku("email",$tujuan);
	

if($hp_ku){
$isipesane = "Hello ".$nama_ku." (".$user_session."), You have to transfer ".$currencye." balance (".$kode.") To: ".$nama_nya." (".$tujuan."), amount: ".$jumlahdeponec.", date: ".$tgl.".";
sendwa($hp_ku, $isipesane, $apikeywoowa);	
		}	
		
			if($hptujuan){
$isipesanec = "Hello ".$nama_nya." (".$tujuan."), You have get transfer ".$currencye." balance (".$kode.") From: ".$nama_ku." (".$user_session."), amount: ".$jumlahdeponec.", date: ".$tgl.".";
sendwa($hptujuan, $isipesanec, $apikeywoowa);	
		}	
//$isipesan = "".$nama_ku.", pembelian balance ".$jenis." sebesar ".$jumlahdepone." telah berhasil, selanjutnya silahkan lakukan pembayaran.";
//mysql_query("insert into outbox values('', '$kode', '".$user_session."', '$hp_ku', '$isipesan', '$clientdate', '1')") or die(mysql_error());
//sendsms($hp_ku, $isipesan) ;
	
//$isipesan2 = "Ada member beli balance ".$jenis." sebesar ".$jumlahdepone.", Kode: ".$kode.", User: ".$user_session.", Nama: ".$nama_ku."";
//sendsms($hpadmin, $isipesan2) ;
	
$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Hello ".$nama_ku." (".$user_session."),</p>
<p>You have to transfer ".$currencye." balance,</p>
<p>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Transfer: ".$jmlrecx."<br>
Recipient: ".$nama_nya."<br>
Date: ".$tgl."<br>
Status: success<br>
<p>
Notes: ".$uraian."
</p>
</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
		if($smaile == 1){	
//$mail3->IsSMTP(); // telling the class to use SMTP
$mail3->Host       = $smtphost; // SMTP server
$mail3->SMTPAuth   = true;                  // enable SMTP authentication
$mail3->Host       = $smtphost; // sets the SMTP server
$mail3->Port       = $smtport;                    // set the SMTP port for the GMAIL server
$mail3->Username   = $smtpuser; // SMTP account username
$mail3->Password   = $smtpass;        // SMTP account password
}
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email_ku, $nama_ku);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama_ku.', your transfer '.$currencye.' balance';
        $mail3->msgHTML($isimail);
	   // $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();		
	
	

$isimail2="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Hello ".$nama_nya." (".$tujuan."),</p>
<p>You have to get the ".$currencye." Balance,</p>
<p>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Transfer: ".$jmlrecx."<br>
From: ".$nama_ku."<br>
Date: ".$tgl."<br>
Status: success<br>
<p>
Notes: ".$uraian."
</p>
</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";


 $mail3b = new PHPMailer;
 if($smaile == 1){	
//$mail3b->IsSMTP(); // telling the class to use SMTP
$mail3b->Host       = $smtphost; // SMTP server
$mail3b->SMTPAuth   = true;                  // enable SMTP authentication
$mail3b->Host       = $smtphost; // sets the SMTP server
$mail3b->Port       = $smtport;                    // set the SMTP port for the GMAIL server
$mail3b->Username   = $smtpuser; // SMTP account username
$mail3b->Password   = $smtpass;        // SMTP account password
}
        $mail3b->setFrom($emailadmin, $bisnisname);
        $mail3b->addAddress($emailtujuan, $nama_nya);
	    $mail3b->IsHTML(true);       
        $mail3b->Subject = ''.$nama_nya.', you get '.$currencye.' Balance';
        $mail3b->msgHTML($isimail2);
        $mail3b->send();		

$db->insert("notifikasi", "", "'', '$username', 'Transfer ".$currencye." Balance', '', '', 'Transfer ".$currencye." Balance ".$kode." has been processed.', '$clientdate', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kode'");

$db->insert("notifikasi", "", "'', '$tujuan', 'Transfer ".$currencye." Balance', '', '', 'You get a ".$currencye." Balance ".$kode." from ".$accid." (".$nama_ku.").', '$clientdate', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kode'");

  header("location: index.php?go=walletcash&page=transfer&result=success_add&co=".base64_encode($kode)."&ca=".base64_encode($jumlahdepone)."&cd=".base64_encode($accid2)."");
	exit;
}
}
}
}
}
}
}
?>

 
 
 
 
 
 
 
 
 
 
 
 
    
    
    
    
    
    
 
    
 <?php
 } else if (isset($_GET['page']) && $_GET['page'] == "buybalance") {

?>
<div class="row">
                <div class="col-md-4">
                
                   <div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">Buy Balance</h3>
            </div>
            <div class="box-body">       

               
                 <?php  if($buywalletcash == 0){ 
				 echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Buy ".$currencye." Balance is curently disable by administrator.</div>";
				 $diss3=" disabled='disabled'";
}else{
	$diss3="";
}
				 
				  ?>
                                	
      <?php    
$initialex = substr(str_shuffle(str_repeat("ABEF123456789GHIJKLMNPR123456789KLEFGHILMNP123456789RRSTUVWXYZ", 46)), 22, 12);
?>           
<?php
 if(isset($_GET['result'])&&$_GET['result']=="success_add"){
if(isset($_GET["co"])){ $co = anti_injection(base64_decode($_GET["co"])); }
if(isset($_GET["ca"])){ $ca = anti_injection(base64_decode($_GET["ca"])); }
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Buy ".$currencye." Balance ".$co." has been successfully, please make payment according to the value balance of your order".$ca.".</div>";
}
?>

<?php
 if(isset($_GET['result'])&&$_GET['result']=="no_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_NO_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="wrong_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_WRONG_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_lock"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_BLOCK_PIN."</div>";
}
?>  

 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_off"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_OFF_PIN."</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="min_buy"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Minimum Buy ".$currencye." Balance is ".rupiah($minimalbuywalletcash).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_buy"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max Buy ".$currencye." Balance is ".rupiah($maksimalbuywalletcash).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pending"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You still have a transaction pending status. Wait until the transaction is processed in order to be able to buy ".$currencye." balance again.</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="type"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Select type balance.</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="success"){
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Buy ".$currencye." Balance Has been successfully submitted. Please make payment according to your add balance value.</div>";
}
?>
<?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_captcha"){
echo "<div class='alert alert-danger'>Wrong Captcha!</div>";
}
?>	
    <?php
$results = $_GET['result'];
if($results == "wrong_auth") { 
echo "<div class='alert alert-danger'>You're enable two factor authentication at your account, Please enter your google authenticator six-digit code!</div>";
}
?>          
<script language="JavaScript">
	<!--
	function roundNumber(number,decimals) {
	var newString;// The new rounded number
	decimals = Number(decimals);
	if (decimals < 1) {
		newString = (Math.round(number)).toString();
	} else {
		var numString = number.toString();
		if (numString.lastIndexOf(".") == -1) {
			numString += ".";
		}
		var cutoff = numString.lastIndexOf(".") + decimals;
		var d1 = Number(numString.substring(cutoff,cutoff+1));
		var d2 = Number(numString.substring(cutoff+1,cutoff+2));
		if (d2 >= 5) {
			if (d1 == 9 && cutoff > 0) {
				while (cutoff > 0 && (d1 == 9 || isNaN(d1))) {
					if (d1 != ".") {
						cutoff -= 1;
						d1 = Number(numString.substring(cutoff,cutoff+1));
					} else {
						cutoff -= 1;
					}
				}
			}
			d1 += 1;
		} 
		newString = numString.substring(0,cutoff) + d1.toString();
	}
	if (newString.lastIndexOf(".") == -1) {
		newString += ".";
	}
	var decs = (newString.substring(newString.lastIndexOf(".")+1)).length;
	for(var i=0;i<decimals-decs;i++) newString += "0";
	var newNumber = Number(newString);
	return newNumber;
}

function format_num(num){
		
		var res = "";
		num = num.toString();
		counter = 0;
		var c = num.indexOf('.');
		var end = num.length-1;
		if(c>-1) {
			res = ","+num.substring(c+1,c+3);
			end = c-1;
			if(res.length==2) res = res + "0";
		}
		
		
		for(var i=end;i>=0;i--){
			res = num.substring(i,i+1) + res;
			counter ++;
			if(counter%3 == 0 && i > 0)
				res = "." + res;
		}
		return res;
	}


function numbersonly(e){
		var unicode=e.charCode? e.charCode : e.keyCode
		
		if (unicode!=8 && unicode!=46){ //if the key isn't the backspace key (which we should allow)
			if (unicode<48||unicode>57) {
				var temp = document.getElementById('amount').value;
				var totalfound = 0;
				var titik = temp.indexOf('.');
				if(titik>-1){
					totalfound=1;
					var temp2 = temp.substring(temp.indexOf('.')+1,temp.length);
					if(temp2.indexOf('.')>-1) totalfound=2;
				}
				if(unicode!=46 && unicode!=37 && unicode!=39) return false; //disable key press
				if(unicode==46 && totalfound>0) return false;
			}
		}
	}

	function cekQ(){
		var temp = document.getElementById('amount').value;
		var totalfound = 0;
		var titik = temp.indexOf('.');
		if(titik>-1){
			totalfound=1;
			var temp2 = temp.substring(temp.indexOf('.')+1,temp.length);
			if(temp2.indexOf('.')>-1) totalfound=2;
		}
if(totalfound>1) temp = temp.substring(0,temp.length-1);
else if(totalfound==1 && titik==temp.length-1) temp = document.getElementById('amount').value;
		//if(totalfound>1) temp = parseFloat(document.getElementById('quant').value);
		//else if(totalfound==0) temp = parseFloat(document.getElementById('quant').value);
		//else if(totalfound==1 && titik==temp.length-1) temp = document.getElementById('quant').value;
		//else temp = parseFloat(document.getElementById('quant').value);
		//var q = parseFloat(document.getElementById('quant').value);
		var q = parseFloat(temp);
		
		var p = document.getElementById('price').value;
		if(isNaN(q)) {q = 0;temp="";}
		if(q<0) {q = 0;temp=0;}
		document.getElementById('amount').value = temp;
		document.getElementById('total').value = format_num(roundNumber(q*p,2));
	}

	
	//-->
	</script>	               
               
                <form id="tab2" name="wallet_depo" method="post" action="?go=walletcash&page=buy_balance_go">
                                         
<input type="hidden" id="kode" name="kode" value="<?php echo $initialex; ?>"/>
<input type="hidden" id="user" name="user" value="<?php echo $user_session; ?>"/>   
<input type="hidden" id="jenis" name="jenis" value="dataewalet"/>   
<input type="hidden" id="accid" name="accid" value="<?php echo $db->dataku("accid", $user_session); ?>"/> 
<input type="hidden" id="fee" name="fee" value="<?php echo $feebuywalletcash; ?>"/>  

       
          

        
 <div class="controls-row" style="margin-top:10px;">

            <label>Amount Buy</label>
 <div class="input-group">
                   <span class="input-group-addon" id="basic-addon1"><?php echo $currencye; ?></span>

           <input name="amount" type="number" class="form-control" id="amount" onKeyUp='cekQ();'; placeholder="Enter Amount" onkeypress="return numbersonly(event)" required='required' autocomplete="off">

          </div></div>
          
         
          
          
  <?php if($usepins == 1){ ?>
          <div class="controls-row" style="margin-top:10px;">

            <label>Secure PIN</label>

           <input name="pincode" class="form-control" id="pincode" placeholder="Enter Your Secure PIN" type="password" required='required' autocomplete="off"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>

          </div> 
          <?php } ?>

<?php if($db->dataku("authgoogle", $user_session) == 1){ ?>
            
 <div class="controls-row" style="margin-top:10px;">

            <label>2FA Code</label>


           <input type="text" class="form-control" placeholder="Hanya jika anda mengaktifkan 2FA" name="one_time_password">
                                                          
</div>
         
<?php } ?>
         
 <div>

           &nbsp;

          </div>
          <div>
        
<button type='submit' class='btn btn-<?php echo $buttone; ?>' name="addbalance" <?php echo $diss3; ?><?php echo $diss4; ?>>Add Balance</button> 

          </div>

        </form>
        <div class="controls-row" style="margin-top:10px;">
        <div class='alert alert-info alert-dismissable'><i class="fa fa-info-circle"></i>&nbsp;<strong>Notice:</strong><br>Min <?php echo rupiah($minimalbuywalletcash); ?>, Max <?php echo rupiah($maksimalbuywalletcash); ?>, Fee <?php echo $feebuywalletcash; ?>%.</div></div>
        
        
                </div></div>
                </div><!--end .col-->
               <div class="col-md-8">
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">Buy Cash Balance History</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">
                                      <thead class="bg-primary-600">
                                            <tr>
                            <th width="15%"><?php echo $LANG["date"]?></th>
							<th width="15%"><?php echo $LANG["amount"]?></th>
							<th width="7%">Pay</th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
                                               
                                            <?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, tglproses, jenis", "datacwalet2", "username='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[8] == "ewalet") {
				$jenise = "Balance";
			} else if($row[8] == "bwalet") {
				$jenise = "B-Walet";
			} else {
				$jenise = "R-Walet";
			}		
			
			
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[6] > 0) {
				$st = "<span class='btn btn-success btn-xs tooltips' data-original-title='Lunas tanggal ".formatgl($row[7])."' style='font-size:10px;'>Done</span>";
				$sxt = "---";
				$style = "<font>";
			} else {
				$st = "<span class='btn btn-danger btn-xs' style='font-size:10px;'>Pending</span>";
				$sxt = '<a href="#null" onClick="newWindow(\'page.php?go=payment_walet&sc='.$row[0].'\',\'\',\'800\',\'800\',\'resizable,scrollbars,status\')">
	   <button class="btn btn-success btn-xs tooltips" type="button" data-original-title="Pembayaran">Detail Pembayaran</button></a>';
				$style = "<font color='#F00000'>";
			}	
			
			
				$tt = $row[5];
				
			$cdo = $row[0];		
$sqlc = mysql_query("SELECT * FROM invoice WHERE kode='$cdo'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$invc = $rowc['file'];				
				
?> 
     	<tr>
							<td align="center"><?= $style; ?><?= $tt; ?></font></td>
							<td align="center"><?= $style; ?><?= rupiah($row[3]); ?></font></td>
                           
            
							<td align="center"><?= $style; ?>
							
							 <?php if($row[6] == 1){ ?>
                          <a href="index.php?go=payment_ecash&sc=<?php echo $row[0]; ?>" class='btn btn-success' style='font-size:11px; font-weight:bold;'><i class="fa fa-money"></i>&nbsp;&nbsp;Payment</a>
                          <?php } else{ ?>
                          <a href="index.php?go=payment_ecash&sc=<?php echo $row[0]; ?>" class='btn btn-danger' style='font-size:11px; font-weight:bold;'><i class="fa fa-money"></i>&nbsp;&nbsp;Payment</a>
                          <?php } ?> 
							</font></td>
							<td align="center"><?= $style; ?><?= $st; ?></font></td>
						  </tr> 
	 
 

	<?
	
		}
	?>

                                                                                </tbody>
                                    </table>
                                    </div></div>
                                </div>
<input type=hidden id='clr' value='yellow'>
                            <div class="clearfix"></div>
                        </div>
                    </div><!-- End .panel -->     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   










		
    
   <?php
 } else if (isset($_GET['page']) && $_GET['page'] == "buy_balance_go") {

?>
<?


	  $authgoogles=$db->dataku("authgoogle", $user_session);
$code    = anti_injection($_POST['one_time_password']);	  
$result  = $authenticator->verifyCode($secret,$code,$tolerance);
if($googleauntentic == 1 && $authgoogles == 1 && !$result){
header("location: index.php?go=walletcash&page=buybalance&result=wrong_auth");
exit;
} else {	


$pincods = md5($_POST['pincode']);	
$sqlc = mysql_query("SELECT * FROM pincode WHERE username='$user_session'");
$numc = mysql_num_rows($sqlc);
while($rowc = mysql_fetch_array($sqlc)){
$tgl = formatgl($rowc['tgl']);
$pin = $rowc['pin'];
$sts = $rowc['status'];
$lock = $rowc['locks'];
	}
	if($usepins == 1 && !$numc) {
	header("location: index.php?go=walletcash&page=buybalance&result=no_pin");
	exit;
} else {
if($usepins == 1 && !$pincods || $usepins == 1 && $pincods <> $pin) {
	header("location: index.php?go=walletcash&page=buybalance&result=wrong_pin");
	exit;
} else {
if($usepins == 1 && $lock == 1) {
	header("location: index.php?go=walletcash&page=buybalance&result=pin_lock");
exit;
	} else {
if($usepins == 1 && $sts == 0) {
	header("location: index.php?go=walletcash&page=buybalance&result=pin_off");
	exit;
} else {	



$kode = $_POST['kode'];
$username = anti_injection($_POST['user']);	
$accid = anti_injection($_POST['accid']);	
$amount = anti_injection($_POST['amount']);


$db->select("status", "datacwalet2", "status='0' and tujuan='$username'");
				$ada = $db->num_rows();
if ($ada >0) {
  header("location: index.php?go=walletcash&page=buybalance&result=pending");
	exit;
} else {

		

if (!$amount || $amount < $minimalbuywalletcash) {
        header("location: index.php?go=walletcash&page=buybalance&result=min_buy");
	exit;
      } else {

if ($amount > $maksimalbuywalletcash) {
        header("location: index.php?go=walletcash&page=buybalance&result=max_buy");
	exit;
      } else {


$db->insert("datacwalet2", "", "'', '$kode', '$username', '$amount', '', '$username', '$clientdate', '0', '$kurspoin', '', '$accid', ''"); 	
//$db->insert("dataewalet2", "", "'', '$kode', '$username', '$amount', '', '$username', '$clientdate', '0', '$kurspoin', '', '$accid', '', 'cash'"); 		
			
$jenise="Wallet Balance";

$spon_nama = $db->dataku("nama", $username);

		$spon_mail = $db->dataku("email", $username);
		$nama = $db->dataku("nama", $username);
		$jumlahdepone = rupiah($amount);
		$jumlahdeponec = rupiahwa($amount);
		$namadmin = $db->config("name");
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");



             $jmldlrs = $amount/$kurse; 	
             $jmldollare = round($jmldlrs, 2);
$jmlrp = idr($amount);
$jmldlr = dolar($jmldollare);

setcookie("Amounts",$jmldlrs, time()+3600);
setcookie("Email",$spon_mail, time()+3600);
setcookie("Nama",$spon_nama, time()+3600);




$sess = substr(str_shuffle(str_repeat("4453141119066764203711128717497783625536342396411241472162223777", 64)), 0, 22);
			$invc="ADDBALANCE_".$user_session."_".$sess."_".$kode;
			$inv="http://".$domain."/invoice/".$invc.".pdf";
			$db->insert("invoice","","'', '$user_session', '$kode', '$invc', '$clientdate'");
			$nama_ku = $db->dataku("nama",$user_session);
			$email_ku = $db->dataku("email",$user_session);
			$hp_ku = $db->dataku("hp",$user_session);
			$nama_nya = $db->dataku("nama",$tujuan);
			
			
 $bank = $db->config("bank");if($bank){ $banke = $bank."<br>"; }
 $bank1 = $db->config("bank1");if($bank1){ $banke1 = $bank1."<br>"; }
 $bank2 = $db->config("bank2");if($bank2){ $banke2 = $bank2."<br>"; }
 $bank3 = $db->config("bank3");if($bank3){ $banke3 = $bank3."<br>"; }
 $bank4 = $db->config("bank4");if($bank4){ $banke4 = $bank4."<br>"; }
 $bank5 = $db->config("bank5");if($bank5){ $banke5 = $bank5."<br>"; }
 $bank6 = $db->config("bank6");if($bank6){ $banke6 = $bank6.""; }
 
 if($bank){ $bankex = $bank.", "; }
 if($bank1){ $bankex1 = $bank1.", "; }
 if($bank2){ $bankex2 = $bank2.", "; }
 if($bank3){ $bankex3 = $bank3.", "; }
 if($bank4){ $bankex4 = $bank4.", "; }
 if($bank5){ $bankex5 = $bank5.", "; }
 if($bank6){ $bankex6 = $bank6.""; }
 
 $bankadmins=$banke."".$banke1."".$banke2."".$banke3."".$banke4."".$banke5."".$banke6;
 $bankadminsx=$bankex."".$bankex1."".$bankex2."".$bankex3."".$bankex4."".$bankex5."".$bankex6;


	if($hp_ku){
$isipesanec = "Hello ".$nama_ku." (".$user_session."), Your buy Cash Wallet balance (".$kode.") amount: ".$jumlahdeponec.", date: ".$tgl.". Please login and make payment.";
sendwa($hp_ku, $isipesanec, $apikeywoowa);	
		}	


$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$nama_ku." (".$user_session."),</p>
<p>Buy ".$currencye." Balance</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Date: ".$tgl."<br>
</p>
<p>Please login and make payment according to the value that you add balance.</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
		if($smaile == 1){	
//$mail3->IsSMTP(); // telling the class to use SMTP
$mail3->Host       = $smtphost; // SMTP server
$mail3->SMTPAuth   = true;                  // enable SMTP authentication
$mail3->Host       = $smtphost; // sets the SMTP server
$mail3->Port       = $smtport;                    // set the SMTP port for the GMAIL server
$mail3->Username   = $smtpuser; // SMTP account username
$mail3->Password   = $smtpass;        // SMTP account password
}
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email_ku, $nama_ku);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama_ku.', Buy '.$currencye.' Balance';
        $mail3->msgHTML($isimail);
	//    $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	


$db->insert("notifikasi", "", "'', '$username', 'Buy ".$currencye." Balance', '', '', 'Buy ".$currencye." Balance No Transaction ".$kode.", Please make payment according to the value that you add balance', '$clientdate', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kode'");



 header("location: index.php?go=payment_ecash&sc=".$kode."&result=success");
	exit;


	  }
}
}
}
}
	}
}
}
?>	
    
    
    
    
    
    
    
   <?php
 } else if (isset($_GET['page']) && $_GET['page'] == "sellbalance") {


?>

<div class="row">
                <div class="col-md-4">
                
                   <div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">Withdrawal</h3>
            </div>
            <div class="box-body">     
    
              
                         <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_sell"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Your max withdrawal ".$currencye." Balance is ".rupiah($_GET["mx"])." /days.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="max_sellb"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$db->config("vwdadd").".</div>";
}
?>
				
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_sellc"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Maximum withdrawal ".$currencye." Balance today is ".rupiah($_GET["d"]).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_sell2"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max withdrawal ".$currencye." Balance ".rupiah($maxwdwalletcash).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="min_sell"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Your min withdrawal ".$currencye." Balance is ".rupiah($_GET["mx"]).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pending"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You still have your previous withdrawal transactions pending status. Wait until the transaction is processed to be able to withdraw again.</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="insufficient"){
$mx = $_GET['mx'];
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Your ".$currencye." balance is insufficient, maximum withdraw is ".rupiah($mx).".</div>";
}
?>

<?php
 if(isset($_GET['result'])&&$_GET['result']=="success_add"){
if(isset($_GET["co"])){ $co = anti_injection(base64_decode($_GET["co"])); }
if(isset($_GET["ca"])){ $ca = anti_injection(base64_decode($_GET["ca"])); }
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Withdrawal ".$currencye." Balance no ".$co." has been successfully, please wait we will process your withdrawal.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="no_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_NO_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="wrong_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_WRONG_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_lock"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_BLOCK_PIN."</div>";
}
?>  
<?php
 if(isset($_GET['result'])&&$_GET['result']=="err_gateway"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Please update your ".$_GET['acc']." first in your profile setting to withdrawal to ".$_GET['acc']."!</div>";
}
?>   
<?php
 if(isset($_GET['result'])&&$_GET['result']=="err_btc"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Please select BTC address to withdrawal with currency BTC</div>";
}
?>   
<?php
 if(isset($_GET['result'])&&$_GET['result']=="err_usdt"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Please select USDT Wallet address to withdrawal with currency USDT</div>";
}
?>   
<?php
 if(isset($_GET['result'])&&$_GET['result']=="err_bank"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Please select Bank Account to withdrawal with currency ".strtoupper($_GET['cr'])."</div>";
}
?>   
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_off"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_OFF_PIN."</div>";
}
 if(isset($_GET['result'])&&$_GET['result']=="disable"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Withdrawal ".$currencye." balance is curently disable by administrator.</div>";
}
?>
   <?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_captcha"){
echo "<div class='alert alert-danger'>Wrong Captcha!</div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "datewd") { 
echo "<div class='alert alert-danger'>".base64_decode($_GET['dtl'])."</div>";
}
?>                    	           
<?php
$results = $_GET['result'];
if($results == "wrong_auth") { 
echo "<div class='alert alert-danger'>You're enable two factor authentication at your account, Please enter your google authenticator six-digit code!</div>";
}
?>              
  <?php
$results = $_GET['result'];
if($results == "unverified") { 
echo "<div class='alert alert-danger'>Your account is not verified!</div>";
}
?>                
              
               
                 
                                	
      <?php    
$initialex = substr(str_shuffle(str_repeat("ABEF123456789GHIJKLMNPR123456789KLEFGHILMNP123456789RRSTUVWXYZ", 46)), 22, 12);
?>           

 <?php if($usekyc == 1 && $db->dataku("accpt", $user_session) == 0){ 
				 echo "<div align='center'><img src='../themes/img/unverified.png' width='100' height='100' /><br><p style='font-weight:bold; font-size:20px;margin-top:5px;'>UNVERIFIED</p>Withdrawal ".$currencye." Balance is disable, to be able Withdrawal your ".$currencye." Balance you must verification first.<br><br><a href='index.php?go=kyc'><button class='btn btn-danger btn-xs' type='button'>Click Here</button></a><br><br></div>";
				  //echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>"; 
				  }else{
				 
				  ?>    
			   
               
                 <?php  if($wdwalletcash == 0){ 
				 echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Withdrawal ".$currencye." balance is curently disable by administrator.</div>";
				 $diss3=" disabled='disabled'";
}else{
	$diss3="";
}
				 
				  ?>





<script language="JavaScript">
	<!--
	function roundNumber(number,decimals) {
	var newString;// The new rounded number
	decimals = Number(decimals);
	if (decimals < 1) {
		newString = (Math.round(number)).toString();
	} else {
		var numString = number.toString();
		if (numString.lastIndexOf(".") == -1) {
			numString += ".";
		}
		var cutoff = numString.lastIndexOf(".") + decimals;
		var d1 = Number(numString.substring(cutoff,cutoff+1));
		var d2 = Number(numString.substring(cutoff+1,cutoff+2));
		if (d2 >= 5) {
			if (d1 == 9 && cutoff > 0) {
				while (cutoff > 0 && (d1 == 9 || isNaN(d1))) {
					if (d1 != ".") {
						cutoff -= 1;
						d1 = Number(numString.substring(cutoff,cutoff+1));
					} else {
						cutoff -= 1;
					}
				}
			}
			d1 += 1;
		} 
		newString = numString.substring(0,cutoff) + d1.toString();
	}
	if (newString.lastIndexOf(".") == -1) {
		newString += ".";
	}
	var decs = (newString.substring(newString.lastIndexOf(".")+1)).length;
	for(var i=0;i<decimals-decs;i++) newString += "0";
	var newNumber = Number(newString);
	return newNumber;
}

function format_num(num){
		
		var res = "";
		num = num.toString();
		counter = 0;
		var c = num.indexOf('.');
		var end = num.length-1;
		if(c>-1) {
			res = ","+num.substring(c+1,c+3);
			end = c-1;
			if(res.length==2) res = res + "0";
		}
		
		
		for(var i=end;i>=0;i--){
			res = num.substring(i,i+1) + res;
			counter ++;
			if(counter%3 == 0 && i > 0)
				res = "." + res;
		}
		return res;
	}


function numbersonly(e){
		var unicode=e.charCode? e.charCode : e.keyCode
		
		if (unicode!=8 && unicode!=46){ //if the key isn't the backspace key (which we should allow)
			if (unicode<48||unicode>57) {
				var temp = document.getElementById('amount').value;
				var totalfound = 0;
				var titik = temp.indexOf('.');
				if(titik>-1){
					totalfound=1;
					var temp2 = temp.substring(temp.indexOf('.')+1,temp.length);
					if(temp2.indexOf('.')>-1) totalfound=2;
				}
				if(unicode!=46 && unicode!=37 && unicode!=39) return false; //disable key press
				if(unicode==46 && totalfound>0) return false;
			}
		}
	}

	function cekQ(){
		var temp = document.getElementById('amount').value;
		var totalfound = 0;
		var titik = temp.indexOf('.');
		if(titik>-1){
			totalfound=1;
			var temp2 = temp.substring(temp.indexOf('.')+1,temp.length);
			if(temp2.indexOf('.')>-1) totalfound=2;
		}
if(totalfound>1) temp = temp.substring(0,temp.length-1);
else if(totalfound==1 && titik==temp.length-1) temp = document.getElementById('amount').value;
		//if(totalfound>1) temp = parseFloat(document.getElementById('quant').value);
		//else if(totalfound==0) temp = parseFloat(document.getElementById('quant').value);
		//else if(totalfound==1 && titik==temp.length-1) temp = document.getElementById('quant').value;
		//else temp = parseFloat(document.getElementById('quant').value);
		//var q = parseFloat(document.getElementById('quant').value);
		var q = parseFloat(temp);
		
		var p = document.getElementById('price').value;
		if(isNaN(q)) {q = 0;temp="";}
		if(q<0) {q = 0;temp=0;}
		document.getElementById('amount').value = temp;
		document.getElementById('total').value = roundNumber(q*p,8);
	}

	function cekQx(){
		var temp = document.getElementById('amountsell').value;
		var totalfound = 0;
		var titik = temp.indexOf('.');
		if(titik>-1){
			totalfound=1;
			var temp2 = temp.substring(temp.indexOf('.')+1,temp.length);
			if(temp2.indexOf('.')>-1) totalfound=2;
		}
if(totalfound>1) temp = temp.substring(0,temp.length-1);
else if(totalfound==1 && titik==temp.length-1) temp = document.getElementById('amountsell').value;
		//if(totalfound>1) temp = parseFloat(document.getElementById('quant').value);
		//else if(totalfound==0) temp = parseFloat(document.getElementById('quant').value);
		//else if(totalfound==1 && titik==temp.length-1) temp = document.getElementById('quant').value;
		//else temp = parseFloat(document.getElementById('quant').value);
		//var q = parseFloat(document.getElementById('quant').value);
		var q = parseFloat(temp);
		
		var p = document.getElementById('pricesell').value;
		if(isNaN(q)) {q = 0;temp="";}
		if(q<0) {q = 0;temp=0;}
		document.getElementById('amountsell').value = temp;
		document.getElementById('totalsell').value = roundNumber(q*p,8);
	}
	//-->
	</script>  
  
              
               <?php if($otpnya == 0){ ?>
                <form id="tab2" name="wallet_depo" method="post" action="?go=walletcash&page=sell_balance_wdgo">
                <?php } else {?>
                <form id="tab2" name="wallet_depo" method="post" action="?go=walletcash&page=sell_balance_confirm">
                <?php } ?>
                
  
<input type="hidden" id="kode" name="kode" value="<?php echo $initialex; ?>"/>
<input type="hidden" id="user" name="user" value="<?php echo $user_session; ?>"/>
<input type="hidden" id="accid" name="accid" value="<?php echo $db->dataku("accid", $user_session); ?>"/>
<input type="hidden" id="fee" name="fee" value="<?php echo $feewdwalletcash; ?>"/>
                 


           <div class="controls-row">

            <label>Available Balance</label>
<div class="input-group">
                   <span class="input-group-addon" id="basic-addon1"><?php echo $currencye; ?></span>

       <?php 
			 
			 $saldobwallete = $db->mycwalet($user_session);
			 $pendingbwallete = $db->mycwaletpending($user_session);
			 $totalbwalete = $saldobwallete-$pendingbwallete;
			 if($totalbwalete > 0){
			 ?>
            <input type="text" value="<?php echo rupiah($totalbwalete); ?>" style='background-color:#009F50; color:#FFF;' class="form-control"/>
            <?php }else{ ?>
            <input type="text" value="No Balance" style='background-color:#DF0000; color:#FFF;' class="form-control"/>
            <?php } ?>

          </div></div>
          
     
             
 <div class="controls-row" style="margin-top:10px;">
            <label>Withdrawal Currency</label>
              <select name="curewd" class="form-control"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss4b; ?> required='required'>
              <?php if($currencye == "USD"){ ?>
   <?php if($bankwd == 1){ ?><?php if($exchangeidr == 1){ ?><option value='idr'>IDR (Indonesian Rupiahs)</option><?php } ?><?php } ?>
   <?php if($wdmyr == 1){ ?><?php if($exchangerm == 1){ ?><option value='rm'>RM (Malaysian Ringgits)</option><?php } ?><?php } ?>
   <?php if($db->config("wdsgd") == 1){ ?><?php if($db->config("exchangesgd") == 1){ ?><option value='jod'>JOD (Jordanian Dinar)</option><?php } ?><?php } ?>
   <?php if($wdbnd == 1){ ?><?php if($exchangebnd == 1){ ?><option value='sgd'>SGD (Singapore Dollars)</option><?php } ?><?php } ?>
   <?php if($wdeur == 1){ ?><?php if($exchangeeur == 1){ ?><option value='eur'>EUR (Euro)</option><?php } ?><?php } ?>
   <?php if($usdtwd == 1){ ?><option value='usdt'>USDT</option><?php } ?>
   <option value='usd'>USD</option>
  <?php } else if($currencye == "IDR"){ ?>
   <?php if($bankwd == 1){ ?><option value='idr'>IDR (Indonesian Rupiahs)</option><?php } ?>
  <?php } else if($currencye == "RM"){ ?>
   <?php if($wdmyr == 1){ ?><option value='rm'>RM (Malaysian Ringgits)</option><?php } ?>
  <?php } else if($currencye == "JOD"){ ?>
   <?php if($db->config("wdsgd") == 1){ ?><option value='jod'>JOD (Jordanian Dinar)</option><?php } ?>
  <?php } else if($currencye == "SGD"){ ?>
   <?php if($wdbnd == 1){ ?><option value='sgd'>SGD (Singapore Dollars)</option><?php } ?>
  <?php } else if($currencye == "EUR"){ ?>
   <?php if($wdeur == 1){ ?><option value='eur'>EUR (Euro)</option><?php } ?>
  
   <?php } ?>
   
   
   
   <?php if($syswdtobtc == 1){ ?><option value='btc'>BTC (Bitcoin)</option><?php } ?>
		  </select> 
            
          </div> 
  

  <div class="controls-row" style="margin-top:10px;">
            <label>Withdrawal To</label>
            
            
              <select name="tujuan" id="tujuan" class="form-control"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss4b; ?> required='required'>
     <?php if($syswdtobtc == 1){ ?>
   <?php if($db->dataku("btcaddress", $user_session)) { ?>
   <option value='btc'>BTC : <?php echo $db->dataku("btcaddress", $user_session);?></option>
   <?php } else{ ?>
   <option value='' style="background-color:#F00; color:#FFF;" disabled="disabled">Update your BTC Wallet Address</option>
   <?php } ?><?php } ?>
   
   <?php if($bankwd == 1 || $wdmyr == 1 || $wdbnd == 1 || $db->config("wdsgd") == 1 || $wdeur == 1){ ?>
   <?php if($db->dataku("bank", $user_session)) { ?>
   <option value='bank'>Bank : <?php echo $db->dataku("bank", $user_session);?></option>
   <?php } else{ ?>
   <option value='' style="background-color:#F00; color:#FFF;" disabled="disabled">Update your Bank Account</option>
   <?php } ?><?php } ?>
   
   
		  </select> 
            
          </div>  

         <div class="controls-row" style="margin-top:10px;">

            <label>Amount Withdrawal</label>
          <div class="input-group">
                   <span class="input-group-addon" id="basic-addon1"><?php echo $currencye; ?></span>

                                  <input class="form-control" name="amount"  id="amount" type="text" onKeyUp='cekQ();'; onkeypress="return numbersonly(event)" autocomplete="off" placeholder="Amount Withdrawal">
                                                                                    </div>
         </div>
          <div><hr /></div>
         <?php if($usepins == 1){ ?>
          <div class="controls-row" style="margin-top:10px;">

            <label>Secure PIN</label>

           <input name="pincode" class="form-control" id="pincode" placeholder="Enter Your Secure PIN" type="password" required='required' autocomplete="off"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>

          </div> 
          <?php } ?>

           <?php if($db->dataku("authgoogle", $user_session) == 1){ ?>
           <div class="controls-row" style="margin-top:10px;">

            <label>2FA Code</label>
           <input type="text" class="form-control" placeholder="Enter 2FA Google Authenticator" name="one_time_password">
                                                          
</div>
          <?php } ?>
          
          
          
 <div>

           &nbsp;

          </div>
          <div>
        	    
			  
            <input type="submit" value="Submit"class="btn btn-<?php echo $buttone; ?>" name="addbalance" <?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>
          </div>

        </form>
          <div class="controls-row" style="margin-top:10px;">
        <div class='alert alert-info alert-dismissable'><i class="fa fa-info-circle"></i>&nbsp;<strong>Notice:</strong><br>Min <?php echo rupiah($minwdwalletcash); ?>, <?php if($db->config("convertbalance") == 1){?><?php if($db->dataku("dana", $user_session) == 1){?>Max <?php echo rupiah($db->config("maxwdro")); ?><?php }else{ ?><?php echo rupiah($maxwdwalletcash); ?><?php } ?><?php }else{ ?><?php echo rupiah($maxwdwalletcash); ?><?php } ?>, Fee <?php echo $feewdwalletcash; ?>%.<br />
         
         <?php if($syswdtobtc == 1) { ?><br />Rate To BTC <?php echo btc($kursbtc_wd); ?>/<?php echo $currencye; ?><br /><?php } ?>
        <?php if($currencye == "USD"){ ?>
		<?php if($syswdtobank == 1) { ?>
        <?php if($exchangeidr == 1){ ?>Rate To IDR <?php echo idr($kursidr); ?>/<?php echo $currencye; ?><br /><?php } ?><?php } ?>
		<?php if($wdmyr == 1) { ?>
        <?php if($exchangerm == 1){ ?> <?php } ?><?php } ?>
		<?php if($db->config("wdsgd") == 1) { ?>
        <?php if($db->config("exchangesgd") == 1){ ?>Rate To JOD <?php echo jod($kurssgd); ?>/<?php echo $currencye; ?><br /><?php } ?><?php } ?>
		<?php if($wdbnd == 1) { ?>
        <?php if($exchangebnd == 1){ ?>Rate To SGD <?php echo sgd($kursbnd); ?>/<?php echo $currencye; ?><br /><?php } ?><?php } ?>
		<?php if($wdmyr == 1) { ?>
        <?php if($exchangemyr == 1){ ?>Rate To RM <?php echo rm($kursmyr); ?>/<?php echo $currencye; ?><br /><?php } ?><?php } ?>
			<?php if($wdeur == 1) { ?>
        <?php if($exchangeeur == 1){ ?>Rate To EUR <?php echo eur($kurseur); ?>/<?php echo $currencye; ?><br /><?php } ?><?php } ?>
		<?php } ?>
        
        </div></div>
        <?php } ?>
        
            </div></div></div><!--end .col-->
                
              <div class="col-md-8">
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">Withdrawal History</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">
                                      <thead class="bg-primary-600">
                                            <tr>
                           
                            <th width="15%"><?php echo $LANG["date"]?></th>
							<th width="15%"><?php echo $LANG["amount"]?></th>
							<th width="15%">Fee</th>
							<th width="15%">Received</th>
							<th width="25%"><?php echo $LANG["news"]?></th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
                                               
                                        <?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, jenis, fee, jumlahnet, tglproses", "datacwalet2b", "username='$user_session' or tujuan='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[2] == "admin-1") {
				$user = "admin";
			} else {
				$user = $row[2];
			}		
			if($row[4] == $user_session) {
				$ket = "$row[1]";
			} else {
				$ket = 	"$row[1]";
			}
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[6] > 0) {
				$st = "<span class='btn btn-success btn-sm tooltips' data-original-title='Lunas tanggal ".formatgl($row[10])."'>Done</span>";	
				$style = "<font>";
			} else {
				$st = "<span class='btn btn-danger btn-sm'>Pending</span>";
	   $style = "<font color='#F00000'>";
			}	
				$tt = $row[5];
				
			$cdo = $row[0];		
$sqlc = mysql_query("SELECT * FROM invoice WHERE kode='$cdo'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$invc = $rowc['file'];				
				
?>
     	<tr>
							<td align="center"><?php echo $style; ?><?= $tt; ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[3]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[8]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[9]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= $ket; ?></font></td>
                            
            

							<td align="center"><?php echo $style; ?><?= $st; ?></font></td>
						  </tr> 
	 
 

	<?
	
		}
	?>

                                                                                </tbody>
                                    </table>
                                    </div>
                                </div>
                                </div>
                        </div>
                    </div><!-- End .panel -->                       
             




<?php
 } else if (isset($_GET['page']) && $_GET['page'] == "sell_balance_wdgo") {
	
$toe = $_POST['to'];	
if($toe){
	$getho="&to=".$toe;
}	
	
	if($wdwalletcash == 0){
        header("location: index.php?go=walletcash&page=sellbalance&result=disable$getho");
	exit;
      } else {
		


if($usekyc == 1 && $db->dataku("accpt", $user_session) == 0){
header("location: index.php?go=walletcash&page=sellbalance&result=unverified$getho");
exit;
} else {
	
$authgoogles=$db->dataku("authgoogle", $user_session);
$code    = anti_injection($_POST['one_time_password']);	  
$result  = $authenticator->verifyCode($secret,$code,$tolerance);
if($googleauntentic == 1 && $authgoogles == 1 && !$result){
header("location: index.php?go=walletcash&page=sellbalance&result=wrong_auth$getho");
exit;
} else {

$pincods = md5($_POST['pincode']);	
$sqlc = mysql_query("SELECT * FROM pincode WHERE username='$user_session'");
$numc = mysql_num_rows($sqlc);
while($rowc = mysql_fetch_array($sqlc)){
$tgl = formatgl($rowc['tgl']);
$pin = $rowc['pin'];
$sts = $rowc['status'];
$lock = $rowc['locks'];
	}
	if($usepins == 1 && !$numc) {
	header("location: index.php?go=walletcash&page=sellbalance&result=no_pin$getho");
	exit;
} else {
if($usepins == 1 && !$pincods || $usepins == 1 && $pincods <> $pin) {
	header("location: index.php?go=walletcash&page=sellbalance&result=wrong_pin$getho");
	exit;
} else {
if($usepins == 1 && $lock == 1) {
	header("location: index.php?go=walletcash&page=sellbalance&result=pin_lock$getho");
exit;
	} else {
if($usepins == 1 && $sts == 0) {
	header("location: index.php?go=walletcash&page=sellbalance&result=pin_off$getho");
	exit;
} else {	
		
$username = anti_injection($_POST['user']);	
$kode = anti_injection($_POST['kode']);	
$amount = anti_injection($_POST['amount']);	
$fee = $_POST['fee'];
$tujuan = $_POST['tujuan'];
$jenis = $_POST['jenis'];
$curewd = $_POST['curewd'];
$accid = anti_injection($_POST['accid']);	

$jumlah=$amount;
//$jml_fee=($fee/100)*$jumlah;
$jml_fee=($fee/100)*$jumlah;
$jml_byr=$amount-$jml_fee;

if($curewd == 'btc' && $tujuan == "bank"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_btc$getho");
	exit;
      } else { 
	  if($curewd == 'usdt' && $tujuan == "bank" || $curewd == 'usdt' && $tujuan == "btc"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_usdt$getho");
	exit;
		  
		  
      } else { 
		  
		  
if($curewd == 'idr' && $tujuan == "btc" || $curewd == 'rm' && $tujuan == "btc" || $curewd == 'sgd' && $tujuan == "btc" || $curewd == 'jod' && $tujuan == "btc" || $curewd == 'eur' && $tujuan == "btc"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_bank&cr=$curewd$getho");
	exit;
      } else { 

if($currencye == "USD"){
	
if($tujuan == "bank" && $curewd == 'idr'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (IDR)";
		 $curree="idr";
		 $kursnyaexc=$kursidr;
		 $paymentnee=$jml_byr*$kursidr;
		 
}else if($tujuan == "bank" && $curewd == 'rm'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (RM)";
		 $curree="rm";
		 $kursnyaexc=$kursmyr;
		 $paymentnee=$jml_byr*$kursmyr;
		 
}else if($tujuan == "bank" && $curewd == 'sgd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (SGD)";
		 $curree="sgd";
		 $kursnyaexc=$kursbnd;
		 $paymentnee=$jml_byr*$kursbnd;
		 
}else if($tujuan == "bank" && $curewd == 'jod'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (JOD)";
		 $curree="jod";
		 $kursnyaexc=$kurssgd;
		 $paymentnee=$jml_byr*$kurssgd;
		 
}else if($tujuan == "bank" && $curewd == 'eur'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (EUR)";
		 $curree="eur";
		 $kursnyaexc=$kurseur;
		 $paymentnee=$jml_byr*$kurseur;
		 
}else if($tujuan == "bank" && $curewd == 'usd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (USD)";
		 $curree="usd";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "btc"){
		 $tujuane=$db->dataku("btcaddress", $username);
		 $tujuanex="Bitcoin Address";
		 $curree="btc";
		 $kursnyaexc=$kursbtc_wd;
		 $paymentnee=$jml_byr*$kursbtc_wd;
         $paymentnee=sprintf("%.8f",$paymentnee);
		 
} else if($tujuan == "usdt"){
		 $tujuane=$db->dataku("usdtwallet", $username);
		 $tujuanex="USDT Wallet Address Address";
		 $curree="usdt";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
}
}else{
if($tujuan == "bank" && $curewd == 'rm'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (RM)";
		 $curree="rm";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'idr'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (IDR)";
		 $curree="idr";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'sgd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (SGD)";
		 $curree="sgd";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'eur'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (EUR)";
		 $curree="eur";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'jod'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (JOD)";
		 $curree="jod";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "btc"){
		 $tujuane=$db->dataku("btcaddress", $username);
		 $tujuanex="Bitcoin Address";
		 $curree="btc";
		 $kursnyaexc=$kursbtc_wd;
		 $paymentnee=$jml_byr*$kursbtc_wd;
         $paymentnee=sprintf("%.8f",$paymentnee);
}
}

if(!$tujuane){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_gateway&acc=$tujuanex$getho");
	exit;
      } else { 
	  
	  
$saldobwallete = $db->mycwalet($user_session);
$pendingbwallete = $db->mycwaletpending($user_session);
$jmlsaldone = $saldobwallete-$pendingbwallete;

if ($amount > $jmlsaldone) {
        header("location: index.php?go=walletcash&page=sellbalance&result=insufficient&mx=$jmlsaldone$getho");
	exit;
      } else {	  

$db->select("status", "datacwalet2b", "status='0' and username='$username'");
				$ada = $db->num_rows();
if ($ada >0) {
  header("location: index.php?go=walletcash&page=sellbalance&result=pending$getho");
	exit;
} else {

if ($amount < $minwdwalletcash) {
        header("location: index.php?go=walletcash&page=sellbalance&result=min_sell&mx=$minwdwalletpurchase$getho");
	exit;
      } else {
	
	
	 $tgl_skr = (date("Y-m-d"));
			$dtfromnya = "$tgl_skr 00:00:00";
			$dttonya = "$tgl_skr 23:59:59";

$cekjmlah=mysql_query("select SUM(jumlah) from datacwalet2b where username='$username' and (tgl between '$dtfromnya' and '$dttonya')");
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0];
		             }
	
	
	
$btsharinie=$maxwdwalletcash-$tothariini;
if ($db->dataku("dana", $user_session) == 0 && $amount > $btsharinie) {
        header("location: index.php?go=walletcash&page=sellbalance&result=max_sellb&d=$btsharinie$getho");
	exit;
      } else {
		  

$btsharinie2=$db->config("maxwdro")-$tothariini;
if ($db->dataku("dana", $user_session) == 1 && $amount > $btsharinie2) {
        header("location: index.php?go=walletcash&page=sellbalance&result=max_sellc&d=$btsharinie$getho");
	exit;
      } else {		  
		  

$tujuanec=$tujuanex." ".$tujuane;
if($currencye == "USD" || $currencye == "EUR" || $currencye == "USDT"){
$uraian1 = "Withdrawal ".$currencye." Balance To: ".$tujuanec." Total ".$curree($paymentnee)."";
}else{
$uraian1 = "Withdrawal ".$currencye." Balance To: ".$tujuanec."";
}

$db->insert("datacwalet2b", "", "'', '$kode', '$username', '$amount', '$jml_fee', '$jml_byr', '$uraian1', '$username', '$clientdate', '0', 'cash', '', '$tujuanec', '$kurswd', '$accid', '', '$curree', '$kursnyaexc', '$paymentnee'");  		

$cekadane = mysql_query("select kode from datacwalet where kode='$kode' and username='$username'");
$ada_adane = mysql_num_rows($cekadane); 
if(!$ada_adane) {
$db->insert("datacwalet", "", "'', '$kode', '$username', '$amount', '$uraian1', 'administrator', '$clientdate', 0, '', '$accid', 'administrator'"); 
}
	
	$spon_nama = $db->dataku("nama", $user_session);
		$spon_mail = $db->dataku("email", $user_session);
		$nama = $db->dataku("nama", $user_session);
		$jumlahdepone = rupiah($amount);
		$jumlahdeponec = rupiahwa($amount);
		$namadmin = $db->config("name");
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");


             $jmldlrs = $amount/$kurse; 	
             $jmldollare = round($jmldlrs, 2);
$jmlrp = idr($amount);
$jmldlr = dolar($jmldollare);

setcookie("Amounts",$jmldlrs, time()+3600);
setcookie("Email",$spon_mail, time()+3600);
setcookie("Nama",$spon_nama, time()+3600);




$sess = substr(str_shuffle(str_repeat("4453141119066764203711128717497783625536342396411241472162223777", 64)), 0, 22);
			$invc="WITHDRAWAL".$user_session."_".$sess."_".$kode;
			$inv="http://".$domain."/invoice/".$invc.".pdf";
			$db->insert("invoice","","'', '$user_session', '$kode', '$invc', '$clientdate'");
			$nama_ku = $db->dataku("nama",$user_session);
			$email_ku = $db->dataku("email",$user_session);
			$hp_ku = $db->dataku("hp",$user_session);
			$nama_nya = $db->dataku("nama",$tujuan);
			
			

if($hp_ku){
$isipesanec = "Hello ".$nama_ku." (".$user_session."), Your withdrawal ".$currencye." balance (".$kode.") amount: ".$jumlahdeponec.", To: ".$tujuanec.", Please wait, we will process your withdrawal as soon as possible.";
sendwa($hp_ku, $isipesanec, $apikeywoowa);	
		}	
//$isipesan = "".$nama_ku.", pembelian balance ".$jenis." sebesar ".$jumlahdepone." telah berhasil, selanjutnya silahkan lakukan pembayaran.";
//mysql_query("insert into outbox values('', '$kode', '".$user_session."', '$hp_ku', '$isipesan', '$clientdate', '1')") or die(mysql_error());
//sendsms($hp_ku, $isipesan) ;
	
//$isipesan2 = "Ada member beli balance ".$jenis." sebesar ".$jumlahdepone.", Kode: ".$kode.", User: ".$user_session.", Nama: ".$nama_ku."";
//sendsms($hpadmin, $isipesan2) ;
	
$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$nama_ku." (".$user_session."),</p>
<p>Your withdrawal ".$currencye." Balance.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Amount Transfered: ".rupiah($jml_byr)."<br>
To: ".$tujuanex."<br>
".$tujuanex." : ".$tujuane."<br>
Amount: ".$curree($paymentnee)."<br>
Date: ".$tgl."<br>
</p>
<p>Please wait, we will process your withdrawal as soon as possible.</p>

<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email_ku, $nama_ku);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama_ku.', Your Withdrawal '.$currencye.' Balance';
        $mail3->msgHTML($isimail);
	  //  $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	
		
		
$isimailx="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$bisnisname.",</p>
<p>Withdrawal ".$currencye." Balance.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Amount Transfered: ".rupiah($jml_byr)."<br>
To: ".$tujuanex."<br>
".$tujuanex." : ".$tujuane."<br>
Amount: ".$curree($paymentnee)."<br>
Date: ".$tgl."<br>
</p>
<p>
Username: ".$user_session."<br>
Name: ".$nama_ku."<br>
Email: ".$email_ku."<br>
Phone: ".$hp_ku."

</p>

<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3b = new PHPMailer;
        $mail3b->setFrom($emailadmin, $bisnisname);
        $mail3b->addAddress($emailadmin, $bisnisname);
	    $mail3b->IsHTML(true);       
        $mail3b->Subject = ''.$bisnisname.', Withdrawal '.$currencye.' Balance';
        $mail3b->msgHTML($isimailx);
	  //  $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3b->send();			
		


$db->insert("notifikasi", "", "'', '$username', 'Withdrawal ".$currencye." Balance', '', '', '".$uraian1." kode ".$kode.", will be processed as soon as possible.', '$clientdate', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kode'");

        header("location: index.php?go=walletcash&page=sellbalance&result=success_add&co=".base64_encode($kode)."&ca=".base64_encode($jumlahdepone)."$getho");
	exit;
}
}
}
}
}
}
	}
	}
}
}
	  }
	  }
	  }
	  }
}}
?>	




 
 
 
 
<?php
} else if (isset($_GET['page']) && $_GET['page'] == "sell_balance_confirm") {
	
if(isset($_GET["i"])){ 
$toe=base64_decode($_GET["i"]); 
}else{
$toe = anti_injection($_POST['to']);
}	
if($toe){
	$getho="&to=".$toe;
}	
	

if(isset($_GET["a"])){ 
$pincods=base64_decode($_GET["a"]); 
}else{
$pincods = anti_injection($_POST['pincode']);
}		
if(isset($_GET["b"])){ 
$username=base64_decode($_GET["b"]); 
}else{
$username = anti_injection($_POST['user']);
}	
if(isset($_GET["c"])){ 
$kode=base64_decode($_GET["c"]); 
}else{
$kode = anti_injection($_POST['kode']);
}	
if(isset($_GET["d"])){ 
$amount=base64_decode($_GET["d"]); 
}else{
$amount = anti_injection($_POST['amount']);
}	
if(isset($_GET["e"])){ 
$fee=base64_decode($_GET["e"]); 
}else{
$fee = anti_injection($_POST['fee']);
}	
if(isset($_GET["f"])){ 
$tujuan=base64_decode($_GET["f"]); 
}else{
$tujuan = anti_injection($_POST['tujuan']);
}	
if(isset($_GET["g"])){ 
$jenis=base64_decode($_GET["g"]); 
}else{
$jenis = anti_injection($_POST['jenis']);
}	
if(isset($_GET["h"])){ 
$accid=base64_decode($_GET["h"]); 
}else{
$accid = anti_injection($_POST['accid']);
}		
if(isset($_GET["i"])){ 
$curewd=base64_decode($_GET["i"]); 
}else{
$curewd = anti_injection($_POST['curewd']);
}	


if($wdwalletcash == 0){
        header("location: index.php?go=walletcash&page=sellbalance&result=disable$getho");
	exit;
      } else {
		  
		  
if($usekyc == 1 && $db->dataku("accpt", $user_session) == 0){
header("location: index.php?go=walletcash&page=sellbalance&result=unverified$getho");
exit;
} else {
	

$authgoogles=$db->dataku("authgoogle", $user_session);
$code    = anti_injection($_POST['one_time_password']);	  
$result  = $authenticator->verifyCode($secret,$code,$tolerance);
if($googleauntentic == 1 && $authgoogles == 1 && !$result){
header("location: index.php?go=walletcash&page=sellbalance&result=wrong_auth$getho");
exit;
} else {		  

$pincodse = md5($pincods);	
$sqlc = mysql_query("SELECT * FROM pincode WHERE username='$username'");
$numc = mysql_num_rows($sqlc);
while($rowc = mysql_fetch_array($sqlc)){
$tgl = formatgl($rowc['tgl']);
$pin = $rowc['pin'];
$sts = $rowc['status'];
$lock = $rowc['locks'];
	}
	if($usepins == 1 && !$numc) {
	header("location: index.php?go=walletcash&page=sellbalance&result=no_pin$getho");
	exit;
} else {
if($usepins == 1 && !$pincodse || $usepins == 1 && $pincodse <> $pin) {
	header("location: index.php?go=walletcash&page=sellbalance&result=wrong_pin$getho");
	exit;
} else {
if($usepins == 1 && $lock == 1) {
	header("location: index.php?go=walletcash&page=sellbalance&result=pin_lock$getho");
exit;
	} else {
if($usepins == 1 && $sts == 0) {
	header("location: index.php?go=walletcash&page=sellbalance&result=pin_off$getho");
	exit;
} else {	


$jumlah=$amount;
$jml_fee=($fee/100)*$jumlah;
$jml_byr=$amount-$jml_fee;


if($curewd == 'btc' && $tujuan == "bank"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_btc$getho");
	exit;
      } else { 
	  if($curewd == 'usdt' && $tujuan == "bank" || $curewd == 'usdt' && $tujuan == "btc"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_usdt$getho");
	exit;
      } else { 

		  
if($curewd == 'idr' && $tujuan == "btc" || $curewd == 'rm' && $tujuan == "btc" || $curewd == 'sgd' && $tujuan == "btc" || $curewd == 'jod' && $tujuan == "btc" || $curewd == 'eur' && $tujuan == "btc"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_bank&cr=$curewd$getho");
	exit;
      } else { 

if($currencye == "USD"){
	
if($tujuan == "bank" && $curewd == 'idr'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (IDR)";
		 $curree="idr";
		 $kursnyaexc=$kursidr;
		 $paymentnee=$jml_byr*$kursidr;
		 
}else if($tujuan == "bank" && $curewd == 'rm'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (RM)";
		 $curree="rm";
		 $kursnyaexc=$kursmyr;
		 $paymentnee=$jml_byr*$kursmyr;
		 
}else if($tujuan == "bank" && $curewd == 'sgd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (SGD)";
		 $curree="sgd";
		 $kursnyaexc=$kursbnd;
		 $paymentnee=$jml_byr*$kursbnd;
		 
}else if($tujuan == "bank" && $curewd == 'jod'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (JOD)";
		 $curree="jod";
		 $kursnyaexc=$kurssgd;
		 $paymentnee=$jml_byr*$kurssgd;
		 
}else if($tujuan == "bank" && $curewd == 'eur'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (EUR)";
		 $curree="eur";
		 $kursnyaexc=$kurseur;
		 $paymentnee=$jml_byr*$kurseur;
		 
}else if($tujuan == "bank" && $curewd == 'usd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (USD)";
		 $curree="usd";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "btc"){
		 $tujuane=$db->dataku("btcaddress", $username);
		 $tujuanex="Bitcoin Address";
		 $curree="btc";
		 $kursnyaexc=$kursbtc_wd;
		 $paymentnee=$jml_byr*$kursbtc_wd;
         $paymentnee=sprintf("%.8f",$paymentnee);
		 
} else if($tujuan == "usdt"){
		 $tujuane=$db->dataku("usdtwallet", $username);
		 $tujuanex="USDT Wallet Address Address";
		 $curree="usdt";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
}
}else{
if($tujuan == "bank" && $curewd == 'rm'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (RM)";
		 $curree="rm";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'idr'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (IDR)";
		 $curree="idr";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'sgd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (SGD)";
		 $curree="sgd";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'eur'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (EUR)";
		 $curree="eur";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'jod'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (JOD)";
		 $curree="jod";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "btc"){
		 $tujuane=$db->dataku("btcaddress", $username);
		 $tujuanex="Bitcoin Address";
		 $curree="btc";
		 $kursnyaexc=$kursbtc_wd;
		 $paymentnee=$jml_byr*$kursbtc_wd;
         $paymentnee=sprintf("%.8f",$paymentnee);
}
}
	
if(!$tujuane){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_gateway&acc=$tujuanex$getho");
	exit;
      } else { 

$saldobwallete = $db->mycwalet($user_session);
$pendingbwallete = $db->mycwaletpending($user_session);
$jmlsaldone = $saldobwallete-$pendingbwallete;

if ($amount > $jmlsaldone) {
        header("location: index.php?go=walletcash&page=sellbalance&result=insufficient&mx=$jmlsaldone$getho");
	exit;
      } else {	  


$db->select("status", "datacwalet2b", "status='0' and username='$username'");
				$ada = $db->num_rows();
if ($ada >0) {
  header("location: index.php?go=walletcash&page=sellbalance&result=pending$getho");
	exit;
} else {

if ($amount < $minwdwalletcash) {
        header("location: index.php?go=walletcash&page=sellbalance&result=min_sell&mx=$minwdwalletcash$getho");
	exit;
      } else {
	
	
	 $tgl_skr = (date("Y-m-d"));
			$dtfromnya = "$tgl_skr 00:00:00";
			$dttonya = "$tgl_skr 23:59:59";

$cekjmlah=mysql_query("select SUM(jumlah) from datacwalet2b where username='$username' and (tgl between '$dtfromnya' and '$dttonya')");
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0];
		             }
$btsharinie=$maxwdwalletcash-$tothariini;
if ($db->dataku("dana", $user_session) == 0 && $amount > $btsharinie) {
        header("location: index.php?go=walletcash&page=sellbalance&result=max_sellb&d=$btsharinie$getho");
	exit;
      } else {
		  

$btsharinie2=$db->config("maxwdro")-$tothariini;
if ($db->dataku("dana", $user_session) == 1 && $amount > $btsharinie2) {
        header("location: index.php?go=walletcash&page=sellbalance&result=max_sellc&d=$btsharinie$getho");
	exit;
      } else {		  

$hp=$db->dataku("hp", $username);
$email=$db->dataku("email", $username);
$nama=$db->dataku("nama", $username);

$time=time();
$time_checks=$time+300; 

$cdvr = substr(str_shuffle(str_repeat("1234567898765432145875263985675412532897548693256875482", 64)), 0, 6);
$sqlo = mysql_query("SELECT * FROM otp WHERE username='$username'");
$numo = mysql_num_rows($sqlo);
if(!$numo) {
$db->insert("otp", "", "'', '$username', '$clientdate', '$cdvr', '$hp', '$email', '$time_checks', '$kode', '0'");

if($otpnya == 1 || $otpnya == 3){
if($hp){	
$isipesan = $nama.", Kode OTP Withdrawal Anda ".$cdvr.".";
	//mysql_query("insert into outbox values('', '', '$username', '$hp', '$isipesan', '$clientdate', '1')");
	if($smsgtw == 1 && $jsms == 1){
	$hpne = preg_replace('/\D+/', '', $hp);
	$sms = new smsreguler();
	$sms->username = $userkey;
		$sms->password = $passkey;
		$sms->apikey   = $apikey;
		$sms->setTo($hpne);
		$sms->setText($isipesan);
		$sms->smssend();
	}else if($smsgtw == 1 && $jsms == 2){
	$hpne = preg_replace('/\D+/', '', $hp);
	$sms = new smsmasking();
	$sms->username = $userkey;
		$sms->password = $passkey;
		$sms->apikey   = $apikey;
		$sms->setTo($hpne);
		$sms->setText($isipesan);
		$sms->smssend();
	}else if($smsgtw == 2){
	sendsms($hp, $isipesan) ;
	}else{}
sendwa($hp, $isipesan, $apikeywoowa);	
}
}

if($otpnya == 2 || $otpnya == 3){
	
$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Halo ".$nama." (".$username."),<br>
Your Withdrawal OTP Code:</p>
<p style='font-size:36px; color:#069; font-weight:bold;'>".$cdvr."</p>
<p>The code is only valid for 5 Minutes</p>
<p><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
//$mail3->IsSMTP(); // telling the class to use SMTP
$mail3->Host       = $smtphost; // SMTP server
$mail3->SMTPAuth   = true;                  // enable SMTP authentication
$mail3->Port       = $smtport;                    // set the SMTP port for the GMAIL server
$mail3->Username   = $smtpuser; // SMTP account username
$mail3->Password   = $smtpass;        // SMTP account password
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email, $nama);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama.', Your Withdrawal OTP Code';
        $mail3->msgHTML($isimail);
        $mail3->send();	
}
}
?>
<div class="row">
                <div class="col-md-4">
                
                   <div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">Withdrawal</h3>
            </div>
            <div class="box-body">     

 <?php
 if(isset($_GET['result'])&&$_GET['result']=="wrong_kode"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Incorrect OTP Code!</div>";
}
?>
  
<?php
$results = $_GET['result'];
if($results == "err_user") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>User Not Found.</div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "err_users") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>User Not Found.</div>";
}
?>
<?php
$results = $_GET['result'];
$rem = $_GET['rem'];
if($results == "restricts") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You have just resent the SMS verification code, please wait a few moments to resend it.</div>";
}
?>
<?php
$results = $_GET['result'];
$hpxx = $_GET['hx'];
if($results == "send_sms") { 
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>OTP code has been sent to mobile phone number : $hpxx.</div>";
}
?>
<?php
$results = $_GET['result'];
$emxx = $_GET['em'];
if($results == "send_mail") { 
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>OTP code has been sent to email : $emxx.</div>";
}
?>      
 <?php
$results = $_GET['result'];
$emxx = $_GET['em'];
$hpxx = $_GET['hx'];
if($results == "send_to") { 
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>OTP code has been sent to email : $emxx and mobile phone number : $hpxx.</div>";
}
?>              
               
                 <?php  if($wdwalletcash == 0){ 
				 echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Withdrawal Wallet balance is curently disable by administrator.</div>";
				 $diss3=" disabled='disabled'";
}else{
	$diss3="";

				 
				  ?>
                  
                  
                                	
      <?php    
$initialex = substr(str_shuffle(str_repeat("ABEF123456789GHIJKLMNPR123456789KLEFGHILMNP123456789RRSTUVWXYZ", 46)), 22, 12);
?>           

  <?php if($usekyc == 1 && $db->dataku("accpt", $user_session) == 0){ 
				 echo "<div align='center'><img src='../themes/img/unverified.png' width='100' height='100' /><br><p style='font-weight:bold; font-size:20px;margin-top:5px;'>UNVERIFIED</p>Withdrawal ".$currencye." Balance is disable, to be able withdrawal your ".$currencye." balance you must verification first.<br><br><a href='index.php?go=kyc'><button class='btn btn-danger btn-sm' type='button'><i class='fa fa-user-circle' aria-hidden='true'></i>&nbsp;&nbsp;Verification Now</button></a><br><br></div>";
				  }else{
				  ?>    


<script type="text/javascript">
 
        function isNumberKey(evt, obj) {
 
            var charCode = (evt.which) ? evt.which : event.keyCode
            var value = obj.value;
            var dotcontains = value.indexOf(".") != -1;
            if (dotcontains)
                if (charCode == 46) return false;
            if (charCode == 46) return true;
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }
 

 
    </script> 
    <?php if($otpnya == 1){ 
	$cekotpnya="Enter OTP Code";
	$cekotnyax="Mobile Phone Number ".$db->dataku("hp", $user_session);
	}else if($otpnya == 3){ 
	$cekotpnya="Enter OTP Code";
	$cekotnyax="Mobile Phone Number ".$db->dataku("hp", $user_session)." & Email ".$db->dataku("email", $user_session);
	}else{
	$cekotpnya="Enter OTP Code";
	$cekotnyax="Email ".$db->dataku("email", $user_session);
	}
?>   


<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Enter OTP Code that we have sent to <?php echo $cekotnyax;?>.</div>


     
                <form id="tab2" name="wallet_depo" method="post" action="?go=walletcash&page=sell_balance_go">
                               <input name="pincode" value="<?php echo $pincods;?>" readonly="readonly" type="hidden" />
                              <input name="user" value="<?php echo $username;?>" readonly="readonly" type="hidden" />
                              <input name="kode" value="<?php echo $kode;?>" readonly="readonly" type="hidden" />
                              <input name="amount" value="<?php echo $amount;?>" readonly="readonly" type="hidden" />
                              <input name="fee" value="<?php echo $fee;?>" readonly="readonly" type="hidden" />
                              <input name="tujuan" value="<?php echo $tujuan;?>" readonly="readonly" type="hidden" />
                              <input name="jenis" value="<?php echo $jenis;?>" readonly="readonly" type="hidden" />
                              <input name="accid" value="<?php echo $accid;?>" readonly="readonly" type="hidden" />
                              <input name="curewd" value="<?php echo $curewd;?>" readonly="readonly" type="hidden" />
<input name="to" value="<?php echo $toe;?>" readonly="readonly" type="hidden" />

 

          <div class="controls-row">

            <label><?php echo $cekotpnya;?></label>

              <input type="text" class="form-control" placeholder="Masukan Kode OTP" name="verifycode">
           

          </div>
<div>

           &nbsp;

          </div>
          <div>
        
            <input type="submit" value="Submit"class="btn btn-<?php echo $buttone; ?>" name="submitconfirm">

          </div>

        
        
        
        <div class="controls-row" style="margin-top:10px;">
        <div class='alert alert-default alert-dismissable'><i class="fa fa-info-circle"></i>&nbsp;<strong>Notice:</strong><br><i>Not receive OTP code?</i><br /><?php if($db->dataotp("batas", $username) == 0){ ?>&nbsp;<button type="submit" class="btn btn-danger btn-sm" name="submitconfirm" style="margin-top:10px;">Resend</button><?php } else { ?>&nbsp; <a href="validation.php?u=<?php echo base64_encode($username);?>&refer=<?php echo $bsurl;?>"><button type="button" class="btn btn-info btn-sm" style="margin-top:10px;">Resend</button></a><?php } ?></div></div>
        
        
        </form>
        <?php }} ?>
        
                   
                </div></div></div><!--end .col-->
                  <div class="col-md-8">
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">History</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">
                                       <thead class="bg-primary-600">
                                            <tr>
                           
                            <th width="15%"><?php echo $LANG["date"]?></th>
							<th width="15%"><?php echo $LANG["amount"]?></th>
							<th width="15%">Fee</th>
							<th width="15%">Received</th>
							<th width="25%"><?php echo $LANG["news"]?></th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
                                               
                                        <?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, jenis, fee, jumlahnet, tglproses", "datacwalet2b", "username='$user_session' or tujuan='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[2] == "admin-1") {
				$user = "admin";
			} else {
				$user = $row[2];
			}		
			if($row[4] == $user_session) {
				$ket = "$row[1]";
			} else {
				$ket = 	"$row[1]";
			}
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[6] > 0) {
				$st = "<span class='btn btn-success btn-xs tooltips' data-original-title='Lunas tanggal ".formatgl($row[10])."'>Done</span>";	
				$style = "<font>";
			} else {
				$st = "<span class='btn btn-danger btn-xs'>Pending</span>";
	   $style = "<font color='#F00000'>";
			}	
			$tt = $row[5];

				
			$cdo = $row[0];		
$sqlc = mysql_query("SELECT * FROM invoice WHERE kode='$cdo'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$invc = $rowc['file'];				
				
?>
     	<tr>
							<td align="center"><?php echo $style; ?><?= $tt; ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[3]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[8]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[9]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= $ket; ?></font></td>
                            
            

							<td align="center"><?php echo $style; ?><?= $st; ?></font></td>
						  </tr> 
	 
 

	<?
	
		}
	?>

                                                                                </tbody>
                                    </table>
                                    </div>
                                </div>
                                </div>
                        </div>
                    </div><!-- End .panel -->                       
             
<?
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
?>

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  <?php
 } else if (isset($_GET['page']) && $_GET['page'] == "sell_balance_go") {
	
	
	
$toe = $_POST['to'];	
if($toe){
	$getho="&to=".$toe;
}

$pincods = anti_injection($_POST['pincode']);	
$username = anti_injection($_POST['user']);	
$kode = anti_injection($_POST['kode']);	
$amount = anti_injection($_POST['amount']);	
$fee = $_POST['fee'];
$tujuan = $_POST['tujuan'];
$jenis = $_POST['jenis'];
$accid = anti_injection($_POST['accid']);
$verifycode = anti_injection($_POST['verifycode']);	
$curewd = anti_injection($_POST['curewd']);	

$a=base64_encode($pincods); 
$b=base64_encode($username);
$c=base64_encode($kode);
$d=base64_encode($amount);
$e=base64_encode($fee);
$f=base64_encode($tujuan);
$g=base64_encode($jenis);
$h=base64_encode($accid);
$i=base64_encode($curewd);

$jumlah=$amount;
$jml_fee=($fee/100)*$jumlah;
$jml_byr=$amount-$jml_fee;

if($curewd == 'btc' && $tujuan == "bank"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_btc$getho");
	exit;
      } else { 
	  if($curewd == 'usdt' && $tujuan == "bank" || $curewd == 'usdt' && $tujuan == "btc"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_usdt$getho");
	exit;
      } else { 

if($curewd == 'idr' && $tujuan == "btc" || $curewd == 'rm' && $tujuan == "btc" || $curewd == 'sgd' && $tujuan == "btc" || $curewd == 'jod' && $tujuan == "btc" || $curewd == 'eur' && $tujuan == "btc"){
 header("location: index.php?go=walletcash&page=sellbalance&result=err_bank&cr=$curewd$getho");
	exit;
      } else { 

if($currencye == "USD"){
	
if($tujuan == "bank" && $curewd == 'idr'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (IDR)";
		 $curree="idr";
		 $kursnyaexc=$kursidr;
		 $paymentnee=$jml_byr*$kursidr;
		 
}else if($tujuan == "bank" && $curewd == 'rm'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (RM)";
		 $curree="rm";
		 $kursnyaexc=$kursmyr;
		 $paymentnee=$jml_byr*$kursmyr;
		 
}else if($tujuan == "bank" && $curewd == 'sgd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (SGD)";
		 $curree="sgd";
		 $kursnyaexc=$kursbnd;
		 $paymentnee=$jml_byr*$kursbnd;
		 
}else if($tujuan == "bank" && $curewd == 'jod'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (JOD)";
		 $curree="jod";
		 $kursnyaexc=$kurssgd;
		 $paymentnee=$jml_byr*$kurssgd;
		 
}else if($tujuan == "bank" && $curewd == 'eur'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (EUR)";
		 $curree="eur";
		 $kursnyaexc=$kurseur;
		 $paymentnee=$jml_byr*$kurseur;
		 
}else if($tujuan == "bank" && $curewd == 'usd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (USD)";
		 $curree="usd";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "btc"){
		 $tujuane=$db->dataku("btcaddress", $username);
		 $tujuanex="Bitcoin Address";
		 $curree="btc";
		 $kursnyaexc=$kursbtc_wd;
		 $paymentnee=$jml_byr*$kursbtc_wd;
         $paymentnee=sprintf("%.8f",$paymentnee);
		 
} else if($tujuan == "usdt"){
		 $tujuane=$db->dataku("usdtwallet", $username);
		 $tujuanex="USDT Wallet Address Address";
		 $curree="usdt";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
}
}else{
if($tujuan == "bank" && $curewd == 'rm'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (RM)";
		 $curree="rm";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'idr'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (IDR)";
		 $curree="idr";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'sgd'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (SGD)";
		 $curree="sgd";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'eur'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (EUR)";
		 $curree="eur";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "bank" && $curewd == 'jod'){
		 $tujuane=$db->dataku("bank", $username);
		 $tujuanex="Bank Account (JOD)";
		 $curree="jod";
		 $kursnyaexc="";
		 $paymentnee=$jml_byr;
		 
} else if($tujuan == "btc"){
		 $tujuane=$db->dataku("btcaddress", $username);
		 $tujuanex="Bitcoin Address";
		 $curree="btc";
		 $kursnyaexc=$kursbtc_wd;
		 $paymentnee=$jml_byr*$kursbtc_wd;
         $paymentnee=sprintf("%.8f",$paymentnee);
}
}
if(!$tujuane){
header("location: index.php?go=walletcash&page=sellbalance&result=err_gateway&acc=$tujuanex$getho");
exit;
      } else { 
		

$db->update("otp", "batas='1'", "username='$username' and batas='0'");
$sql_sp3x = mysql_query("select * from otp where username='".$username."' and kode='".$verifycode."'");
$ada_sp3x = mysql_num_rows($sql_sp3x);
if(!$ada_sp3x){
header("location: index.php?go=walletcash&page=sell_balance_confirm&result=wrong_kode&a=$a&b=$b&c=$c&d=$d&e=$e&f=$f&g=$g&h=$h&i=$i");
exit;
} else {
$db->delete("otp", "kode='$verifycode'");


$saldobwallete = $db->mycwalet($user_session);
$pendingbwallete = $db->mycwaletpending($user_session);
$jmlsaldone = $saldobwallete-$pendingbwallete;

if ($amount > $jmlsaldone) {
        header("location: index.php?go=walletcash&page=sellbalance&result=insufficient&mx=$jmlsaldone$getho");
	exit;
      } else {	  


$db->select("status", "datacwalet2b", "status='0' and username='$username'");
				$ada = $db->num_rows();
if ($ada >0) {
  header("location: index.php?go=walletcash&page=sellbalance&result=pending$getho");
	exit;
} else {

if ($amount < $minwdwalletcash) {
        header("location: index.php?go=walletcash&page=sellbalance&result=min_sell&mx=$minwdwalletcash$getho");
	exit;
      } else {
	
	
	 $tgl_skr = (date("Y-m-d"));
			$dtfromnya = "$tgl_skr 00:00:00";
			$dttonya = "$tgl_skr 23:59:59";

 $cekjmlah=mysql_query("select SUM(jumlah) from datacwalet2b where username='$username' and (tgl between '$dtfromnya' and '$dttonya')");
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0];
		             }
$btsharinie=$maxwdwalletcash-$tothariini;
if ($db->dataku("dana", $user_session) == 0 && $amount > $btsharinie) {
        header("location: index.php?go=walletcash&page=sellbalance&result=max_sellb&d=$btsharinie$getho");
	exit;
      } else {
		  

$btsharinie2=$db->config("maxwdro")-$tothariini;
if ($db->config("convertbalance") == 1 && $db->dataku("dana", $user_session) == 1 && $amount > $btsharinie2) {
        header("location: index.php?go=walletcash&page=sellbalance&result=max_sellc&d=$btsharinie$getho");
	exit;
      } else {		  
		  

$tujuanec=$tujuanex." ".$tujuane;
if($currencye == "USD" || $currencye == "EUR" || $currencye == "USDT"){
$uraian1 = "Withdrawal ".$currencye." Balance To: ".$tujuanec." Total ".$curree($paymentnee)."";
}else{
$uraian1 = "Withdrawal ".$currencye." Balance To: ".$tujuanec."";
}


$db->insert("datacwalet2b", "", "'', '$kode', '$username', '$amount', '$jml_fee', '$jml_byr', '$uraian1', '$username', '$clientdate', '0', 'cash', '', '$tujuanec', '$kurswd', '$accid', '', '$curree', '$kursnyaexc', '$paymentnee'");  		

$cekadane = mysql_query("select kode from datacwalet where kode='$kode' and username='$username'");
$ada_adane = mysql_num_rows($cekadane); 
if(!$ada_adane) {
$db->insert("datacwalet", "", "'', '$kode', '$username', '$amount', '$uraian1', 'administrator', '$clientdate', 0, '', '$accid', 'administrator'"); 
}
	
	$spon_nama = $db->dataku("nama", $user_session);
		$spon_mail = $db->dataku("email", $user_session);
		$nama = $db->dataku("nama", $user_session);
		$jumlahdepone = rupiah($amount);
		$namadmin = $db->config("name");
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");


             $jmldlrs = $amount/$kurse; 	
             $jmldollare = round($jmldlrs, 2);
$jmlrp = idr($amount);
$jmldlr = dolar($jmldollare);

setcookie("Amounts",$jmldlrs, time()+3600);
setcookie("Email",$spon_mail, time()+3600);
setcookie("Nama",$spon_nama, time()+3600);




$sess = substr(str_shuffle(str_repeat("4453141119066764203711128717497783625536342396411241472162223777", 64)), 0, 22);
			$invc="WITHDRAWAL".$user_session."_".$sess."_".$kode;
			$inv="http://".$domain."/invoice/".$invc.".pdf";
			$db->insert("invoice","","'', '$user_session', '$kode', '$invc', '$clientdate'");
			$nama_ku = $db->dataku("nama",$user_session);
			$email_ku = $db->dataku("email",$user_session);
			$hp_ku = $db->dataku("hp",$user_session);
			$nama_nya = $db->dataku("nama",$tujuan);
			
			

if($hp_ku){
$isipesanec = "Hello ".$nama_ku." (".$user_session."), Your withdrawal ".$currencye." balance (".$kode.") amount: ".$jumlahdepone.", To: ".$tujuanec.", Please wait, we will process your withdrawal as soon as possible.";
sendwa($hp_ku, $isipesanec, $apikeywoowa);	
		}
//$isipesan = "".$nama_ku.", pembelian balance ".$jenis." sebesar ".$jumlahdepone." telah berhasil, selanjutnya silahkan lakukan pembayaran.";
//mysql_query("insert into outbox values('', '$kode', '".$user_session."', '$hp_ku', '$isipesan', '$clientdate', '1')") or die(mysql_error());
//sendsms($hp_ku, $isipesan) ;
	
//$isipesan2 = "Ada member beli balance ".$jenis." sebesar ".$jumlahdepone.", Kode: ".$kode.", User: ".$user_session.", Nama: ".$nama_ku."";
//sendsms($hpadmin, $isipesan2) ;
	
$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$nama_ku." (".$user_session."),</p>
<p>Your withdrawal ".$currencye." Balance.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Amount Transfered: ".rupiah($jml_byr)."<br>
To: ".$tujuanex."<br>
".$tujuanex." : ".$tujuane."<br>
Amount: ".$curree($paymentnee)."<br>
Date: ".$tgl."<br>
</p>
<p>Please wait, we will process your withdrawal as soon as possible.</p>

<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email_ku, $nama_ku);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama_ku.', Your Withdrawal '.$currencye.' Balance';
        $mail3->msgHTML($isimail);
	  //  $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	
		
		
$isimailx="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$bisnisname.",</p>
<p>Withdrawal ".$currencye." Balance.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Amount Transfered: ".rupiah($jml_byr)."<br>
To: ".$tujuanex."<br>
".$tujuanex." : ".$tujuane."<br>
Amount: ".$curree($paymentnee)."<br>
Date: ".$tgl."<br>
</p>
<p>
Username: ".$user_session."<br>
Name: ".$nama_ku."<br>
Email: ".$email_ku."<br>
Phone: ".$hp_ku."

</p>


<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3b = new PHPMailer;
        $mail3b->setFrom($emailadmin, $bisnisname);
        $mail3b->addAddress($emailadmin, $bisnisname);
	    $mail3b->IsHTML(true);       
        $mail3b->Subject = ''.$bisnisname.', Withdrawal '.$currencye.' Balance';
        $mail3b->msgHTML($isimailx);
	  //  $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3b->send();			
		


$db->insert("notifikasi", "", "'', '$username', 'Withdrawal ".$currencye." Balance', '', '', '".$uraian1." kode ".$kode.", will be processed as soon as possible.', '$clientdate', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kode'");

        header("location: index.php?go=walletcash&page=sellbalance&result=success_add&co=".base64_encode($kode)."&ca=".base64_encode($jumlahdepone)."$getho");
	exit;
}
}
}
}
}
}
}
}
	  }
}


?>	


    
<?php
} else {
?>

   <?php
 if(isset($_GET['result'])&&$_GET['result']=="success_sell"){
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Sale your Wallet balance has been successfully activated.</div>";
}
?>  
    <div class="row">
            	<div class="col-md-12">
                
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">Balance [<?  $saldoawalete = $db->mycwalet($user_session);
			 $pendingawalete = $db->mycwaletpending($user_session);
			 $totalawalete = $saldoawalete-$pendingawalete; 
			 if($totalawalete > 0){ echo rupiah($totalawalete); }else{ echo rupiah(0);} ?>]</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">            
                
     <thead class="bg-primary-600">
                <tr>
                	<th width="10%">NO</th>
							<th width="20%">DATE</th>
							<th width="10%">TYPE</th>
							<th width="20%">AMOUNT</th>
							<th width="30%">NOTE</th>
							<th width="6%">STATUS</th>
                </tr>
              </thead>
              <tbody>          
                
	<?


	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, tglproses, accid, accid2", "datacwalet", "username='$user_session' or tujuan='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[2] == "admin-1") {
				$user = "admin";
			} else {
				$user = $row[2];
			}		
			if($row[2] == "administrator" || $row[4] == "administrator"){
				$ket = 	"$row[1]";
		}else{
		if($row[4] == $user_session) {
				$ket = "$row[1] (Credit ".$row[2].")";
			} else {
				$ket = 	"$row[1] (Debit ".$row[4].")";
			}	
			}
			if($row[2] == $user_session) {
				$type = "<span class='btn btn-warning btn-xs'>Debet</span>";
			} else {
				$type = "<span class='btn btn-info btn-xs'>Credit</span";
			}	
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[7] == "0000-00-00 00:00:00"){
		$dtpros = "<span class='btn btn-success btn-xs' onMouseover=\"ddrivetip('Date process not found')\" onMouseout='hideddrivetip()' >Done</span>";
	}else{
		$dtpros = "<span class='btn btn-success btn-xs' onMouseover=\"ddrivetip('Process : ".formatgl($row[7])."')\" onMouseout='hideddrivetip()'>Done</span>";
	}
			if($row[6] > 0) {
				$st = $dtpros;
			} else {
				$st = "<span class='btn btn-danger btn-xs'>Pending</span>";
			}	
			
			if($row[2] == $user_session) {
				$style = "<font color='#FF6600'>";
			} else {
				$style = "<font>";
			}		
			
		
	$cdo = $row[0];		
$sqlc = mysql_query("SELECT * FROM invoice WHERE kode='$cdo'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$invc = $rowc['file'];			
				
?>
          <tr>
            <td align="center"><?php echo $style; ?><?= $row[0]; ?></font></td>
            <td align="center"><?php echo $style; ?><?= $row[5]; ?></font></td>
            <td align="center"><?php echo $style; ?><?= $type; ?></font></td>
            
            <td align="center"><?php echo $style; ?><?= rupiah($row[3]); ?></font></td>
            <td align="center"><?php echo $style; ?><?= $ket; ?></font></td>
           
            <td align="center"><?php echo $style; ?><?= $st; ?></font></td>
    </tr>
	<?
		}
	?>
              </tbody>
            </table>
                  </div>
                    </div>
                </div>
			</div>
			</div>
			<!-- END PAGE CONTENT -->       
   
   
 
 
 
 
 
    <?
   
}
   ?>
 
 
 
 
<?php } else {
	echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Wallet disable by administrator.</div>";
}?>  

   <?
   
}
   ?>
 
</section>
<?php ob_flush(); ?>