<nav class="navbar fixed-top">
    <div id="specificCard" class="card col-12" style="border-radius: 20px; background: none; border: none; margin-top: 10px;">
        <div class="row">
            <div class="col-6 icon-container">
                <a href="index.php" class="fa fa-arrow-left text-light"></a>
            </div>
            <div class="col-6 text-right">
                <h6 class="text-light mt-2 mb-2">Transfer Saldo Antar Agen</h6>
            </div>
        </div>
    </div>
</nav>
<div class="card" style="border-radius: 0px; background: none; border: none; margin-top: 100px;">
	<div class="card-body">
		<center>
			<p style="color: #fff;">Saldo Anda</p>
			<h1 style="font-size: 36px; color: #fff;"><small>Rp. </small><b><?php echo number_format($pcmem['saldo']); ?></b></h1>
		</center>
	</div>
</div>
<div class="card" id="2" style="border-top-right-radius: 40px; border-top-left-radius: 40px; min-height: 750px; border: none; z-index: 1;">
	<div class="card-body">
	    <center>
	    <h2>Mohon maaf untuk sementara Transfer Saldo tidak bisa di gunakan</h2>
	    </center>
		<!--<div class="alert alert-danger" style="border-radius: 30px;">-->
		<!--	<h6 class="text-danger text-center"><b><u>PERHATIAN</u></b></h6>-->
		<!--	<p class="text-danger"><i>Lakukan pengisian data dengan teliti untuk menghindari kesalahan transfer</i></p>-->
		<!--</div>-->
		<!--<form method="post">-->
		<!--	<div class="form-group">-->
	 <!--           <label>Masukan Nomor Handphone Reseller Lain</label>-->
	 <!--           <input class="form-control" placeholder="08..." type="number" id="nohp" name="nohp" required="required">-->
	 <!--       </div>-->
	 <!--       <div class="form-group">-->
	 <!--           <label>Masukan Nominal</label>-->
	 <!--           <input class="form-control" placeholder="Rp. 0" type="number" id="nominal" name="nominal" required="required">-->
	 <!--       </div><br>-->
	 <!--       <input type="submit" name="tranfer" style="border-radius: 20px;" class="btn btn-warning btn-lg btn-sm btn-block text" value="Transfer Saldo" />-->
		<!--</form>-->
	</div>
</div>
<?php
if (isset($_POST['tranfer']))
{

	$cekseller = $con->query("SELECT * FROM member WHERE NoHp = '$_POST[nohp]' AND id_admin = '$pcmem[id_admin]'");
	$reseller = $cekseller->fetch_assoc();
	if ($reseller['NoHp'] == $pcmem['NoHp'])
	{
		sweetAlert("Transfer Gagal, anda tidak bisa tranfer ke nomor sendiri", "error");
		//echo "<script>location='index.php?hal=TransferSaldo';</script>";
	}
	elseif ($saldo < $_POST['nominal'])
	{
		sweetAlert("Transfer Gagal, Saldo anda tidak cukup", "error");
		//echo "<script>location='index.php?hal=TransferSaldo';</script>";
	}
	elseif ($reseller != '')
	{	
		//yang mengirim saldo
		$ket = "Transfer saldo ke ".$reseller['NamaMember']." ".$reseller['NoHp'];
		$kredit = $con->query("INSERT INTO tranvoucher (id_admin,IdMember,KreditMember,KetTran) values ('$pcmem[id_admin]','$_SESSION[IdMember]','$_POST[nominal]','$ket')");

		//yang menerima saldo
		$idpenerima = $reseller['IdMember'];
		$ket2 = "Transfer saldo dari ".$pcmem['NamaMember']." ".$pcmem['NoHp'];
		$kredit = $con->query("INSERT INTO tranvoucher (id_admin,IdMember,DebetMember,KetTran) values ('$pcmem[id_admin]','$idpenerima','$_POST[nominal]','$ket2')");
		
		//masuk ke db transfer saldo
		$kredit = $con->query("INSERT INTO transfersaldo (id_admin,IdPengirim,IdPenerima,Nominal) values ('$pcmem[id_admin]','$_SESSION[IdMember]','$idpenerima','$_POST[nominal]')");
		$last_id = mysqli_insert_id($con);

		if ($kredit) 
		{
			echo "<script>location='index.php?hal=StaTransSal&idts=$last_id'</script>";
		}
	}
	else
	{
		sweetAlert("Transfer Gagal, Nomor tidak terdaftar sebagai Agent", "error");
		//echo "<script>location='index.php?hal=TransferSaldo';</script>";
	}

}
?>

<script type="text/javascript">
  document.getElementById('nohp').value = "<?php echo $_POST['nohp'];?>";
  document.getElementById('nominal').value = "<?php echo $_POST['nominal'];?>";
</script>