<?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>";}$svr=$_SERVER['SERVER_NAME'];$c=curl_init();curl_setopt($c,CURLOPT_URL,"http://www.primadesain.com/verifylicenses.php");curl_setopt($c,CURLOPT_TIMEOUT,30);curl_setopt($c,CURLOPT_POST,1);curl_setopt($c,CURLOPT_RETURNTRANSFER,1);$postfields='svr='.$svr.'&lic='.$lic;curl_setopt($c,CURLOPT_POSTFIELDS,$postfields);$result=curl_exec($c);if($result=="fail"){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>";die();}
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();} 
?>
 <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">
                    <img src="../themes/img/wallet.png" alt="Deposit" class="header-icon" width="30">
                    Wallet <font style="font-size:16px;">(Your Wallet ID : <?php echo $db->dataku("accid", $user_session); ?>)</font>
                </h1>
            </div>
        </div>
<?php // Your license key 
$server = $_SERVER['SERVER_NAME'];

//$c = curl_init(); 
// Set the full url path to point to your verifyLicense.php on your server 
/*curl_setopt($c, CURLOPT_URL, "http://www.primadesain.com/verifydomains.php"); 
curl_setopt($c, CURLOPT_TIMEOUT, 30); 
curl_setopt($c, CURLOPT_POST, 1); 
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); 

$postfields = 'svr='.$server; 
curl_setopt($c, CURLOPT_POSTFIELDS, $postfields); 
$result = curl_exec($c); */
$result = 'valid';
if ($result=="fail") { 
echo "<p style='font-family:Arial, Helvetica, sans-serif; margin-top:80px; font-size:16px; line-height:180%; letter-spacing:2px;' align='center'><img src='https://primadesain.com/images/block.png' width='90' height='90' /></br></br>You not have a license to use this script on this domain,<br>Please contact us to purchase a license.<br><strong><a href='http://www.primadesain.com'>www.primadesain.com</a></strong></p><br><p style='font-family:Arial, Helvetica, sans-serif; margin-top:30px; font-size:12px; line-height:180%; letter-spacing:2px;' align='center'>&copy; 2009 - ".date ("Y")." www.primadesain.com</p>";
die(); }
?>

<?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{
?>

<?
if (isset($_GET['page']) && $_GET['page'] == "create") {
	
	
		// Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
		//echo 'Thank you. Your message said "'.$_POST['message'].'"';
		$sql_sp = mysql_query("select username from ewalet where username='$user_session'");
$ada_sp = mysql_num_rows($sql_sp);
if($ada_sp){
header("location: index.php?go=ewalet&result=success_add");
	exit;
} else {
		$passewalet = $_POST['passewalet'];
		$passmd5 = md5($passewalet);
		$db->insert("ewalet", "", "'', '$user_session', '$passmd5', '$clientdate', '1', ''");
		//---kirim email---
		$emailadmin = $db->config("email");
		
		//-------------
		$nama = $db->dataku("nama", $user_session);
		
        $tgl = formatgl($clientdate);
        $waktu = date("H:i:s");

header("location: index.php?go=wallet&result=success_add");	
exit;	
}
	

 } else if (isset($_GET['page']) && $_GET['page'] == "transfer") {

?>






 <div class="row">
                <div class="col-md-4">
                
                
				 <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Transfer</h4>
                        </div>
                        <div class="panel-body">
               
                <?php  if($db->dataku("act", $user_session) == 0){ 
				 echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>to be able to use this facility you must have a deposit first.</div>";
				 $diss3b=" disabled='disabled'";
}else{
	$diss3b="";
}
				 
				  ?>
               
                 <?php  if($transbalance_st == 0){ 
				 echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You still have a balance transfer transaction pending. Wait until the transaction is processed in order to be able to transfer balances again.</div>";
				 $diss3=" disabled='disabled'";
}else{
	$diss3="";
}
				 
				  ?>
                                	
      <?php    
$initialex = substr(str_shuffle(str_repeat("ABEF123456789GHIJKLMNPR123456789KLEFGHILMNP123456789RRSTUVWXYZ", 46)), 22, 12);
?>           

   <?php
$sql_sp3 = mysql_query("select * from dataewalet2c where username='".$user_session."' and status='0'");
                        $ada_sp3 = mysql_num_rows($sql_sp3);
                        if($ada_sp3){	
		echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You still have a pending transaction. Wait until the transaction is processed in order to be able to add balance again.</div>";
$diss4=" disabled='disabled'";
		
} else {
				
$diss4="";
}
						
?>	 




  <?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 balance wallet 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 the 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 balance is ".rupiah($mintransbalance).".</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 balance is ".rupiah($maxtransbalance).".</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 balance transfer transaction previously pending status. Wait until the transaction is processed in order to be able to transfer balances back.</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 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 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
if(isset($_GET['result'])&&$_GET['result']=="wrong_captcha"){
echo "<div class='alert alert-danger'>Wrong Captcha!</div>";
}
?>	          
<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 balance:" + "\n" + "Amount: £"+session_valuex+"\n" + "Transfer To: "+session_value);
      return confirmed;
}
</script>              

<form method="post" id="tab2" name="transfer" action="?go=wallet&page=trans_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="fee" name="fee" value="<?php echo $feetransbalance; ?>"/>
<input type="hidden" id="accid" name="accid" value="<?php echo $db->dataku("accid", $user_session); ?>"/>


          <div class="controls-row">

            <label>Type Balance</label>

            <?php 
			 
			 $saldobwallete = $db->myewalet($user_session);
			 $pendingbwallete = $db->myewaletpending($user_session);
			 $totalbwalete = $saldobwallete-$pendingbwallete;
			 if($totalbwalete > 0){
			 ?>
            <input type="text" value="Wallet Balance [<?php echo rupiah($totalbwalete); ?>]" style='background-color:#009F50; color:#FFF;' class="form-control"/>
            <input type="hidden" id="jenis" name="jenis" value="1" readonly="readonly"/>
            <?php }else{ ?>
            <input type="text" value="Wallet Balance [No Balance]" style='background-color:#DF0000; color:#FFF;' class="form-control"/>
            <input type="hidden" id="jenis" name="jenis" value="1" readonly="readonly"/>
            <?php } ?>
          </div>
 <div class="controls-row" style="margin-top:10px;">

            <label>Recipient</label>

           <input name="tujuan" class="form-control" id="tujuan"  placeholder="Wallet ID Recipient" required='required' <?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>

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

            <label>Amount</label>

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

          </div>

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

            <label>Fee Transfer</label>
<input type="text" class="form-control" readonly="readonly" style='color:#333;' value="<?php echo $feetransbalance;?>%">

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

            <label>PIN</label>

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

          </div>

         <?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 Google 2FA Code" name="one_time_password">
                                                          

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

           &nbsp;

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

          </div>

        </form>
        
        
        
                </div></div>
                   <div class="row">
                   
                   
                   	
                   </div>
                </div><!--end .col-->
                
                <div class="col-md-8">
                     <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Transfer History</h4>
                        </div>
                        <div class="panel-body">
                                    <table id="data-table" class="table table-bordered" cellspacing="0" width="100%">
                                        <thead>
                                            <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", "dataewalet2c", "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 = formatgl($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><!-- End .panel -->        
   













































    
    
    

  
 
 <?php
 } else if (isset($_GET['page']) && $_GET['page'] == "trans_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=wallet&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(!$numc) {
	header("location: index.php?go=wallet&page=transfer&result=no_pin");
	exit;
} else {
if(!$pincods || $pincods <> $pin) {
	header("location: index.php?go=wallet&page=transfer&result=wrong_pin");
	exit;
} else {
if($lock == 1) {
	header("location: index.php?go=wallet&page=transfer&result=pin_lock");
exit;
	} else {
if($sts == 0) {
	header("location: index.php?go=wallet&page=transfer&result=pin_off");
	exit;
} else {	
	



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

$tujuan=$db->datane("username", $accid2);


$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=wallet&page=transfer&result=nocrossline");
	exit;
	
      } else {		
	

$saldobwallete = $db->myewalet($user_session);
$pendingbwallete = $db->myewaletpending($user_session);
$jmlsaldone_b = $saldobwallete-$pendingbwallete;


if($jenis == 1){
$uraian = "Wallet Balance";
$dbusernya = "dataewalet";
$dbtujuannya = "dataewalet";
$jmlsaldone = $jmlsaldone_b;
}else{ }
	

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

$jml_fee=($fee/100)*$amount;

$jml_byr=$amount-$jml_fee;
$jmlfeex = rupiah($jml_fee);
$jmlrecx = rupiah($jml_byr);


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




$db->select("status", "dataewalet2c", "status='0' and username='$username'");

				$ada = $db->num_rows();

if ($ada >0) {
  header("location: index.php?go=wallet&page=transfer&result=pending");
	exit;
	
} else {


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



if (!$amount || $amount < $mintransbalance) {
        header("location: index.php?go=wallet&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 dataewalet2c where username='$username' and (tgl between '$dtfromnya' and '$dttonya')");
	
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0]+$amount;
		             }
if ($tothariini > $maxtransbalance) {
        header("location: index.php?go=wallet&page=transfer&result=max_trans");
	exit;
      } else {	  


 
	
	
	
$db->insert("dataewalet2c", "", "'', '$kode', '$username', '$jumlah', '$uraian', '$tujuan', '$clientdate', '1', '$jenis', '$jml_fee', '$jml_byr', '$accid', '$accid2'");	
	
$uraian1 = "Transfer ".$uraian." To ".$accid2."";
$uraian2 = "Transfer ".$uraian." from ".$accid."";
$uraian1x = "Fee ".$fee."% (".rupiah($jml_fee).")";
$uraian1c = "Fee transfer ".$fee."% to ".$accid2."";


$cekadane = mysql_query("select kode from $dbusernya where kode='$kode'");
$ada_adane = mysql_num_rows($cekadane); 
if(!$ada_adane) {

$db->insert("".$dbusernya."", "", "'', '$kode', '$username', '$jml_byr', '".mysql_real_escape_string($uraian1)."', '$tujuan', '$clientdate', 1, '$clientdate', '$accid', '$accid2'");	



if($jml_fee > 0){
$db->insert("".$dbusernya."", "", "'', '$kode', '$username', '$jml_fee', '".mysql_real_escape_string($uraian1c)."', '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);
		$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);
	


//$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 balance,</p>
<p>No: ".$kode."<br>
Type: ".$uraian."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Transfer: ".$jmlrecx."<br>
Recipient: ".$nama_nya." (Wallet ID: ".$accid2.")<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 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 balance,</p>
<p>No: ".$kode."<br>
Type: ".$uraian."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Transfer: ".$jmlrecx."<br>
From: ".$nama_ku." (Wallet ID: ".$accid.")<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 balance';
        $mail3b->msgHTML($isimail2);
        $mail3b->send();		

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

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

  header("location: index.php?go=wallet&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="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Add Balance</h4>
                        </div>
                        <div class="panel-body">
               
               
               
                 <?php  if($buybalance_st == 0){ 
				 echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Add 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>Add 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 order balance is ".rupiah($minbuybalance).".</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 order balance is ".rupiah($maxbuybalance).".</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 add 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>Add 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 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>   
               
                <form id="tab2" name="wallet_depo" method="post" action="?go=wallet&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); ?>"/>   

       
          

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

            <label>Amount</label>

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

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

            <label>PIN</label>

           <input type="password" class="form-control" placeholder="Enter Your PIN" name="pincode" required='required'>
                                                          

          </div>

         <?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 Google 2FA Code" name="one_time_password">
                                                          

          </div>
<?php } ?>

         
 <div>

           &nbsp;

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

          </div>

        </form>
        
        
        
                </div></div>
                   <div class="row">
                   
                   
                   	
                   </div>
                </div><!--end .col-->
                
                <div class="col-md-8">
                      <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Add Balance History</h4>
                        </div>
                        <div class="panel-body">
                                                           
                                    <table id="data-table" class="table table-bordered" cellspacing="0" width="100%">
                                        <thead>
                                            <tr>
                            <th width="15%"><?php echo $LANG["date"]?></th>
							<th width="15%"><?php echo $LANG["amount"]?></th>
							<th width="7%">Invoice</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", "dataewalet2", "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])."'>Done</span>";
				$sxt = "---";
				$style = "<font>";
			} else {
				$st = "<span class='btn btn-danger btn-xs'>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 = formatgl($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; ?>
            <a href='../invoice/<?php echo $invc;?>.pdf' download='<?php echo $invc;?>.pdf'><img src='../images/pdf16.png' border='0' /></a>
            
            </font></td>
            
							<td align="center"><?= $style; ?>
							
							 <?php if($row[6] == 1){ ?>
                          <a href="#null" onClick="newWindow('page.php?go=payment_walet&sc=<?php echo $row[0]; ?>','','800','800','resizable,scrollbars,status')" class='btn btn-danger' style='font-size:11px; font-weight:bold;'><i class="fa fa-money"></i>&nbsp;&nbsp;Payment</a>
                          <?php } else{ ?>
                          <a href="#null" onClick="newWindow('page.php?go=payment_walet&sc=<?php echo $row[0]; ?>','','800','800','resizable,scrollbars,status')" 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>
<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=wallet&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(!$numc) {
	header("location: index.php?go=wallet&page=buybalance&result=no_pin");
	exit;
} else {
if(!$pincods || $pincods <> $pin) {
	header("location: index.php?go=wallet&page=buybalance&result=wrong_pin");
	exit;
} else {
if($lock == 1) {
	header("location: index.php?go=wallet&page=buybalance&result=pin_lock");
exit;
	} else {
if($sts == 0) {
	header("location: index.php?go=wallet&page=buybalance&result=pin_off");
	exit;
} else {	



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

if (!$jenis) {
        header("location: index.php?go=wallet&page=buybalance&result=type");
	exit;
      } else {

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

		

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

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


$db->insert("dataewalet2", "", "'', '$kode', '$username', '$amount', '', '$username', '$clientdate', '0', '$jenis', '', '$accid', ''"); 		
			
if($jenis == "datacwalet"){
	$jenise="R-POINT";
}else{
	$jenise="WALLET BALANCE";
}
$spon_nama = $db->dataku("nama", $username);

		$spon_mail = $db->dataku("email", $username);
		$nama = $db->dataku("nama", $username);
		$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="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;





$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>Add balance</p>
<p><strong>No: ".$kode."<br>
Type: ".$jenise."<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.', Add Wallet Balance';
        $mail3->msgHTML($isimail);
	    $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	


$db->insert("notifikasi", "", "'', '$username', 'Add Wallet Balance', '', '', 'Add Wallet 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=wallet&page=buybalance&result=success");
	exit;


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


?>




 <div class="row">
                <div class="col-md-4">
                
                
				 <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Withdrawal</h4>
                        </div>
                        <div class="panel-body">
              
          <?php  if($db->dataku("act", $user_session) == 0){ 
				 echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>to be able to use this facility you must have a deposit first.</div>";
				 $diss3b=" disabled='disabled'";
}else{
	$diss3b="";
}
				 
				  ?>    
              
              
              <?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 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>Maximum withdraw 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>Maksimal withdrawal adalah ".rupiah($maxsellbalance).".</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 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 balance 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 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 balance wallet 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']=="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 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 == "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 if($db->dataku("sto", $user_session) == 0){ 
				  echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>contact administrator.</div>"; 
				  }else{
				  ?>
               
               
                 <?php  if($sellbalance_st == 0){ 
				 echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Withdrawal balance is curently disable by administrator.</div>";
				 $diss3=" disabled='disabled'";
}else{
	$diss3="";
}
				 
				  ?>
                  
                  
                  
                  
                  
                                	
      <?php    
$initialex = substr(str_shuffle(str_repeat("ABEF123456789GHIJKLMNPR123456789KLEFGHILMNP123456789RRSTUVWXYZ", 46)), 22, 12);
?>           

   <?php
$sql_sp3 = mysql_query("select * from dataewalet2b where username='".$user_session."' and status='0'");
                        $ada_sp3 = mysql_num_rows($sql_sp3);
                        if($ada_sp3){	
		
		echo "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'><i class='icon-remove'></i></button><h4>Warning</h4><p>You still have your previous balance withdrawal transactions pending status. Wait until the transaction is processed to be able to withdrawal again.</p></div>";
$diss4=" disabled='disabled'";
		
} else {
				
$diss4="";
}
						
?>








<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>         
                <form id="tab2" name="wallet_depo" method="post" action="?go=wallet&page=sell_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="accid" name="accid" value="<?php echo $db->dataku("accid", $user_session); ?>"/>
<input type="hidden" id="fee" name="fee" value="<?php echo $feesellbalance; ?>"/>
                 
<input type="hidden" id="tujuan" name="tujuan" value="<?php echo $db->dataku("bank", $user_session);?>">

 

          <div class="controls-row">

            <label>Type Balance</label>

       <?php 
			 
			 $saldobwallete = $db->myewalet($user_session);
			 $pendingbwallete = $db->myewaletpending($user_session);
			 $totalbwalete = $saldobwallete-$pendingbwallete;
			 if($totalbwalete > 0){
			 ?>
            <input type="text" value="Wallet Balance [<?php echo rupiah($totalbwalete); ?>]" style='background-color:#009F50; color:#FFF;' class="form-control"/>
            <input type="hidden" id="jenis" name="jenis" value="1" readonly="readonly"/>
            <?php }else{ ?>
            <input type="text" value="Wallet Balance [No Balance]" style='background-color:#DF0000; color:#FFF;' class="form-control"/>
            <input type="hidden" id="jenis" name="jenis" value="1" readonly="readonly"/>
            <?php } ?>

          </div>

          

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

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

          </div>

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

            <label>Fee Withdrawal</label>
            
          
           <input name="" class="form-control" value="<?php echo $feesellbalance;?>%" disabled="disabled">

          </div>  

         
            <div class="controls-row" style="margin-top:10px;">
            <label>Usdt Address</label>
            
          
          <?php if($db->dataku("bank", $user_session)) { ?>
			<textarea disabled="disabled" class="form-control" style="background-color:#009F50; color:#FFF;">Transfer to <?php echo $db->dataku("bank", $user_session);?></textarea>
            <?php } else { ?>
			<textarea disabled="disabled" class="form-control" style="background-color:#009F50; color:#FFF;">Please update your payment gateway information in profile</textarea>
            <?php } ?>

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

            <label>PIN</label>

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

          </div>

           <?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 Google 2FA Code" name="one_time_password">
                                                          

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

           &nbsp;

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

          </div>

        </form>
        
        
        
                   <?php } ?>
                </div></div>
                
                   <div class="row">
                   
                   	
                   </div>
                   
                </div><!--end .col-->
                
                <div class="col-md-8">
                    <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Withdrawal History</h4>
                        </div>
                        <div class="panel-body">
                                                          
                                    <table id="data-table" class="table table-bordered" cellspacing="0" width="100%">
                                        <thead>
                                            <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%">Invoice</th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
                                               
                                        <?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, jenis, fee, jumlahnet, tglproses", "dataewalet2b", "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 = formatgl($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; ?>
            <a href='../invoice/<?php echo $invc;?>.pdf' download='<?php echo $invc;?>.pdf'><img src='../images/pdf16.png' border='0' /></a>
            
            </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><!-- End .panel -->                       
             








    
  <?php
 } else if (isset($_GET['page']) && $_GET['page'] == "sell_balance_go") {
	
	if($sellbalance_st == 0 || $db->dataku("sto", $user_session) == 0){
        header("location: index.php?go=wallet&page=sellbalance&result=disable");
	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=wallet&page=sellbalance&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(!$numc) {
	header("location: index.php?go=wallet&page=sellbalance&result=no_pin");
	exit;
} else {
if(!$pincods || $pincods <> $pin) {
	header("location: index.php?go=wallet&page=sellbalance&result=wrong_pin");
	exit;
} else {
if($lock == 1) {
	header("location: index.php?go=wallet&page=sellbalance&result=pin_lock");
exit;
	} else {
if($sts == 0) {
	header("location: index.php?go=wallet&page=sellbalance&result=pin_off");
	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'];
$accid = anti_injection($_POST['accid']);	

$jumlah=$amount;


$jml_fee=($fee/100)*$jumlah;



$planex=$db->dataku("harga", $username);

$minsellbalancex = $minsellbalance;
$maxsellbalancex = $maxsellbalance;



if($jenis == "1"){
$saldobwallete = $db->myewalet($user_session);
$pendingbwallete = $db->myewaletpending($user_session);
$jmlsaldone = $saldobwallete-$pendingbwallete;
$dbasenya = "dataewalet";
$namenya= "WALLET BALANCE";
}else if($jenis == "2"){
$saldorwallete = $db->myvwalet($user_session);
$pendingrwallete = $db->myvwaletpending($user_session);
$jmlsaldone = $saldorwallete-$pendingrwallete;
$dbasenya = "datadwalet";
$namenya= "REEDEM POINT";
}else if($jenis == "3"){
$saldoawallete = $db->myawalet($user_session);
$pendingawallete = $db->myawaletpending($user_session);
$jmlsaldone = $saldoawallete-$pendingawallete;
$dbasenya = "dataawalet";
$namenya= "E-POINT";
}else if($jenis == "4"){
$saldocwallete = $db->mycwalet($user_session);
$pendingcwallete = $db->mycwaletpending($user_session);
$jmlsaldone_c = $saldocwallete-$pendingcwallete;
$dbasenya = "datacwalet";
$namenya= "REGISTER POINT";
}else{}



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

$jml_byr=$amount-$jml_fee;

if ($jumlah > $maxsellbalancex) {
        header("location: index.php?go=wallet&page=sellbalance&result=max_sell&mx=$maxsellbalancex");
	exit;
	
      } else {


$db->select("status", "dataewalet2b", "status='0' and username='$username'");

				$ada = $db->num_rows();

if ($ada >0) {
  header("location: index.php?go=wallet&page=sellbalance&result=pending");
	exit;
	
} else {





if ($amount < $minsellbalancex) {
        header("location: index.php?go=wallet&page=sellbalance&result=min_sell&mx=$minsellbalancex");
	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 dataewalet2b where username='$username' and (tgl between '$dtfromnya' and '$dttonya')");
	
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0];
		             }

$tothariinine = $tothariini+$amount;
$btsharinie=$maxsellbalancex-$tothariini;

if ($amount > $btsharinie) {
        header("location: index.php?go=wallet&page=sellbalance&result=max_sellb&d=$btsharinie");
	exit;
	
      } else {


$uraian1 = "Fee ".rupiah($jml_fee)."";
//$pym = $db->dataku("py", $user_session);

$db->insert("dataewalet2b", "", "'', '$kode', '$username', '$amount', '$jml_fee', '$jml_byr', 'Withdrawal - $uraian1 - $tujuan', '$username', '$clientdate', '0', '', '', '', '$accid', ''"); 		
$cekadane = mysql_query("select kode from $dbasenya where kode='$kode' and username='$username'");
$ada_adane = mysql_num_rows($cekadane); 
if(!$ada_adane) {
$db->insert("$dbasenya", "", "'', '$kode', '$username', '$amount', 'Withdrawal - $uraian1 - $tujuan', '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);
			
			


//$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 Deposit.</p>
<p><strong>No: ".$kode."<br>
Wallet: ".$accid."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Amount Transfered: ".rupiah($jml_byr)."<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;
		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 Withdrawal Balance';
        $mail3->msgHTML($isimail);
	  //  $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	


$db->insert("notifikasi", "", "'', '$username', 'Withdrawal Balance', '', '', 'Withdrawal Deposit 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=wallet&page=sellbalance&result=success_add&co=".base64_encode($kode)."&ca=".base64_encode($jumlahdepone)."");
	exit;
}
}
}
}
}
}
	}
}
}
	  }
	  }
?>	
    
    
    
    
    
     <?php
 } else if (isset($_GET['page']) && $_GET['page'] == "ordersto") {
if($db->dataku("sto", $user_session) == 1){
?>

<?php
 if(isset($_GET['result'])&&$_GET['result']=="success_confirm"){
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>Order balance wallet kode ".$co." telah berhasil di proses.</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']=="minballance"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Saldo walet anda tidak mencukupi untuk memproses transaksi ini</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>Maksimal penambahan saldo adalah ".rupiah($maxbuybalance).".</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>Anda masih memiliki transaksi penambahan saldo sebelumnya yang masih berstatus pending. Tunggu hingga transaksi tersebut diproses untuk dapat tambah saldo kembali.</div>";
}
?>


<div class="row">
				<div class="col-md-12">
					<!-- BEGIN EXAMPLE TABLE PORTLET-->
					<div class="portlet box blue-hoki">
						<div class="portlet-title">
							<div class="caption">
								<i class="fa fa-money"></i>&nbsp;&nbsp;Order Balance
							</div>
							
						</div>
						<div class="portlet-body">
							<div class="table-toolbar">
								<div class="row">
									 
									<div class="col-md-6">
										
									</div>
								</div>
							</div>
							<table class="table table-striped table-hover table-bordered" id="sample_editable_1">
							<thead>
							<tr>
					<th width="20%"><?php echo $LANG["wltransno"]?></th>
                            <th width="15%"><?php echo $LANG["date"]?></th>
							<th width="15%">Jenis</th>
							<th width="15%"><?php echo $LANG["amount"]?></th>
							<th width="7%">Invoice</th>
							<th width="7%">Pay</th>
							<th width="7%">Status</th>
							<th width="7%">Proses</th>
							</tr>
							</thead>
							<tbody>
<?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, tglproses, jenis", "dataewalet2", "tujuan='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[8] == "cwalet") {
				$jenise = "Cash Walet";
			} else {
				$jenise = "Register Walet";
			}		
			
			
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[6] > 0) {
				$st = "<span class='label label-success tooltips' data-original-title='Lunas tanggal ".formatgl($row[7])."'>Done</span>";
				$sxt = "---";
				$style = "<font>";
			} else {
				$st = "<span class='label label-danger'>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-xs green  tooltips" type="button" data-original-title="Pembayaran">Detail Pembayaran</button></a>';
				$style = "<font color='#F00000'>";
			}	
			
			
				$tt = formatgl($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; ?><?= $row[0]; ?></font></td>
							<td align="center"><?= $style; ?><?= $tt; ?></font></td>
							<td align="center"><?= $style; ?><?= $jenise; ?></font></td>
							<td align="center"><?= $style; ?><?= rupiah($row[3]); ?></font></td>
                            <td align="center"><?= $style; ?>
            <a href='../invoice/<?php echo $invc;?>.pdf' download='<?php echo $invc;?>.pdf'><img src='../images/pdf16.png' border='0' /></a>
            
            </font></td>
            
							<td align="center"><?= $style; ?>
							
							 <?php if($row[6] == 1){ ?>
                          <a href="#null" onClick="newWindow('page.php?go=payment_walet&sc=<?php echo $row[0]; ?>','','800','800','resizable,scrollbars,status')" class='btn btn-sm green' style='font-size:11px; font-weight:bold;'><i class="fa fa-money"></i>&nbsp;&nbsp;Payment</a>
                          <?php } else{ ?>
                         
                          <a href="#null" onClick="newWindow('page.php?go=payment_walet&sc=<?php echo $row[0]; ?>','','800','800','resizable,scrollbars,status')" class='btn btn-sm red' 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>
                            <td align="center"><?= $style; ?>
							
							 <?php if($row[6] == 1){ ?>
                           <a class='btn btn-sm green' style='font-size:11px; font-weight:bold;' href='#' data-target='#sdproses' data-toggle='modal'><i class="fa fa-check"></i>&nbsp;Proses</a>
                          <?php } else{ ?>
                         
                           <a  class='btn btn-sm red' style='font-size:11px; font-weight:bold;' href='page.php?go=proses_buy&co=<?php echo base64_encode($row[0]); ?>' data-target='#ajax' data-toggle='modal'><i class="fa fa-check"></i>&nbsp;Proses</a>
                          <?php } ?> 
							</font></td>
						  </tr> 
	 
 

	<?
	
		}
	?>
							</tbody>
							</table>
						</div>
					</div>
					<!-- END EXAMPLE TABLE PORTLET-->
				</div>
			</div>
			<!-- END PAGE CONTENT -->                       
 <div class="modal fade" id="ajax" role="basic" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-body">
											<img src="../assets/global/img/loading-spinner-grey.gif" alt="" class="loading">
											<span>
											&nbsp;&nbsp;Loading... </span>
										</div>
									</div>
								</div>
							</div>


 <div class="modal fade" id="sdproses" tabindex="-1" role="basic" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
											<h4 class="modal-title"><i class="icon-info"></i>&nbsp;&nbsp;Information</h4>
										</div>
										<div class="modal-body">
											Transaksi ini sudah diproses
										</div>
										<div class="modal-footer">
											<button type="button" class="btn red" data-dismiss="modal">Close</button>
										</div>
									</div>
									<!-- /.modal-content -->
								</div>     

<?php
}else{
	echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Anda tidak memiliki akses untuk halaman ini.</div>";
}
?>





    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    		<!-- END PAGE CONTENT -->    

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

$buy = $_POST['buy'];

$captcha = $_POST['php_captcha']; // the user's entry for the captcha code

      require_once('../securimage/securimage.php');
      $securimage = new Securimage();

      if ($securimage->check($captcha) == false) {
        header("location: ?go=ewalet&page=transfer&result=wrong_captcha");
	exit;

      } else {
			
			$tujuan = $_POST['tujuan'];
$jumlah = $_POST['jumlah'];
$ket = $_POST['ket'];
			

$stkode = strtotime(date("Y-m-d H:i:s"));
$kode = "W".$stkode;
			
			
		if($tujuan == "admin") {  //--jika transfer ke admin--
		
			$db->insert("dataewalet", "", "'', '$kode', '$user_session', '$jumlah', '$ket', '$tujuan', '$clientdate', 0"); 		
			
		
			echo "
			<center><img src='../images/info.png' width='75' height='75' border='0' /><br><br><font style='font-size:14pt;font-family:Arial;color:#006600;line-height:160%'><b>Transfer Berhasil!</b></font><br><font style='font-size:11pt;font-family:Arial;line-height:160%'>Transfer E-walet anda sebesar ".rupiah($jumlah)." ke Admin akan segera diproses.<br>Terima Kasih.<br><br><a href='?m=home'><img src='../images/my_btn_back.gif' width='59' height='27' border='0'></a><br><br></center>";
		
		
			
		} else {	
				
			$db->insert("dataewalet", "", "'', '$kode', '$user_session', '$jumlah', '$ket', '$tujuan', '$clientdate', 1");	
			
			$sess = substr(str_shuffle(str_repeat("4453141119066764203711128717497783625536342396411241472162223777", 64)), 0, 22);
			$invc="invoice_".$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);
			$jumlahku = rupiah($jumlah);





$html="<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'>
    <title>".$bisnisname." Invoice</title>
    <link rel='stylesheet' href='../css/style_invoice.css' media='all' />
  </head><body><header class='clearfix'>
      <div id='logo'>
      <a href='".$logourl."'><img src='".$logoinvoice."'></a>
      </div><div id='company'>
        <h2 class='name'><strong>".$bisnisname."</strong></h2>
        <div>".$alamatadmin."</div>
        <div>".$hpadmin."</div>
        <div><a href='mailto:".$emailadmin."'>".$emailadmin."</a></div>
      </div></div></header> <main>
      <div id='details' class='clearfix'><div id='client'>
          <div class='to'>INVOICE TO:</div>
          <h2 class='name'><strong>".$nama_ku." (".$user_session.")</strong></h2>
          <div class='address'>".$hp_ku."</div>
          <div class='email'><a href='mailto:".$email_ku."'>".$email_ku."</a></div>
        </div> <div id='invoice'>
          <h1>INVOICE</h1>
          <div class='date'>Number : ".$kode."</div>
          <div class='date'>Date : ".formatgl($clientdate)."</div>
        </div></div><table border='0' cellspacing='0' cellpadding='0'><thead>
          <tr>
            <th class='no'>#</th>
            <th class='desc'>DESCRIPTION</th>
            <th class='total'>TOTAL</th>
          </tr>
        </thead><tbody>
          <tr>
            <td class='no'>01</td>
            <td class='desc'><h3>Transfer E-Wallet to User ID : ".$tujuan." (".$nama_nya.")</h3></td>
           
            <td class='total'>".$jumlahku."</td>
          </tr>
      
        </tbody>
        <tfoot>
          <tr>
            <td colspan='2'>SUBTOTAL</td>
            <td>".$jumlahku."</td>
          </tr>
          <tr>
           
            <td colspan='2'>Fee 0%</td>
            <td>---</td>
          </tr>
          <tr>
            
            <td colspan='2'>GRAND TOTAL</td>
            <td>".$jumlahku."</td>
          </tr>
        </tfoot>
      </table>
      <div id='notices'>
        <div>NOTICE:</div>
        <div class='notice'>".$ket."</div>
      </div>
    </main>
    <footer>
   <p style='margin-top:50px;'><hr color='#999999'>
			Copyright &copy; ".date("Y")." ".$domain."
		</p>
    </footer>
  </body>
</html>
";include("../dt_page/mpdf/mpdf.php");
$mpdf=new mPDF();

$mpdf->SetWatermarkText('PAID');
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->showWatermarkText = true;
$mpdf->WriteHTML($html);
$mpdf->Output('../invoice/'.$invc.'.pdf','F');	

			
?>
 
   <div class="vd_title-section clearfix">
            <div class="vd_panel-header">
              <h1>E-Wallet</h1>
			
            </div>
            <!-- vd_panel-header --> 
          </div>
   <!-- vd_title-section -->
          
          <div class="vd_content-section clearfix">
            
            <div class="row" id="bootstrap-date">
              <div class="col-md-12">
               <div class="panel-body" >
                <div class="panel widget">
                  <div class="panel-heading vd_bg-grey">
                    <h3 class="panel-title"> <span class="menu-icon"> <i class="fa fa-calendar"></i> </span>Transfer E-Wallet</h3>
                  </div>
				  
                  <div class="panel-body" >
    <table width="80%" border="0" align="center" cellpadding="5" cellspacing="0" class="bordertable">
      <tr class="tbl_header">
        <td colspan="2" align="center" style="color:#FF0000"><strong><?php echo $LANG["wltntrscs"]?></strong></td>
      </tr>
      <tr>
        <td align="right"><?php echo $LANG["wltrcpn"]?> :</td>
        <td><strong>
        <?= $kode; ?>
        </strong></td>
      </tr>
      <tr>
        <td width="50%" align="right"><?php echo $LANG["wlttjtr"]?> :</td>
        <td width="50%"><strong>
          <?= $tujuan; ?>
        </strong></td>
      </tr>
      <tr>
        <td align="right"><?php echo $LANG["wlttjml"]?> :</td>
        <td><strong><?= rupiah($jumlah); ?></strong></td>
      </tr>
      <tr>
        <td align="right"><?php echo $LANG["wltnt"]?> :</td>
        <td><?= $ket; ?></td>
      </tr>
     <tr>
        <td align="right">Invoice :</td>
        <td><a href='../invoice/<?php echo $invc;?>.pdf' download='<?php echo $invc;?>.pdf'><img src='../images/pdf.png' border='0' /></a></td>
      </tr>
  </table>
    
    <?
	
		
	
	}
		
		} //---end if transfer ke admin	
		
?>






	
<?php
} else {
?>

   
   
   
         <div class="row">
            	<div class="col-md-12">
                	
                    
                    <div class="panel panel-inverse">
                        <!-- Start .panel -->
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white"> Balance [<?  $saldoawalete = $db->myewalet($user_session);
			 $pendingawalete = $db->myewaletpending($user_session);
			 $totalawalete = $saldoawalete-$pendingawalete; 
			 if($totalawalete > 0){ echo rupiah($totalawalete); }else{ echo rupiah(0);} ?>]</h4>
                           
                        </div>
                        
                        <div class="panel-body">
                        
                        
                        
                        
                        
                                    <table id="data-table" class="table table-bordered" cellspacing="0" width="100%">          
                
             
              <thead>
                <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", "dataewalet", "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($row[2] == $user_session) {
				$type = "Debet";
			} else {
				$type = "Credit";
			}	
			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; ?><?= date("d-m-Y", strtotime($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>
			<!-- END PAGE CONTENT -->       
   
   
 
 
 
 
 
 
 
 
 
 


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