            <div class="block-header">
                <h2>
                  
                     <ol class="breadcrumb breadcrumb-bg-teal">
                                <li><a href="index.php?home"><i class="material-icons">home</i> Home</a></li>
                               <li><a href="index.php?transfer_bank"><i class="material-icons">transfer_within_a_station</i> Transfer Bank</a></li>
                                <li class="active"> Transfer Bank Add</li>
                            </ol>
                </h2>
            </div>
			<?php 
			
			if(isset($_POST['submit'])){
			$keterangan=noninjection($koneksi,$_POST['keterangan']);
			$idmember=noninjection($koneksi,$_POST['idmember']);
			$nama=noninjection($koneksi,$_POST['nama']);
			$nama2=noninjection($koneksi,$_POST['nama2']);
			$idmember2=noninjection($koneksi,$_POST['idmember2']);
			$nominal=noninjection($koneksi,$_POST['nominal']);
			$pin=noninjection($koneksi,$_POST['pin']);
			$task="34567fghjkl;FGHJK09865fghjs12345@#$@#$!@#";
				
			
			
			//tambah data
			if(($idmember<>'') and ($nominal<>'')  )
			{
									
					$pin=md5($pin);
					$pin_encript=md5($pin.$task);
		
			
					$qry_pin=mysqli_query($koneksi,"SELECT * FROM `tb_user` WHERE (email='".$_SESSION['email']."') AND (password='".$_SESSION['password']."') AND (pin='".$pin_encript."')");
					$N_pin=mysqli_num_rows($qry_pin);
					if($N_pin<>0)
					{
					$row_user=mysqli_fetch_array($qry_pin);
					$tgl1=date('Y-m-d').' 00:00:00';
					$tgl2=date('Y-m-d').' 23:59:59';
					$qry_cari=mysqli_query($koneksi,"SELECT * FROM `tb_rekening` WHERE (idanggota='".$idmember2."') and (nominal='".$nominal."') and (keterangan='".$keterangan."') and (tgl BETWEEN '$tgl1' AND '$tgl2')");
					$N=mysqli_num_rows($qry_cari);
					if($N==0)
					{
									$qry_rek=mysqli_query($koneksi,"SELECT * FROM `tb_rekening`  WHERE idanggota='".$idmember."' order by id desc limit 1");
									$row_rek=mysqli_fetch_array($qry_rek);
									if(mysqli_num_rows($qry_rek)<>0){
									if($row_rek['saldo']>=$nominal){
									$saldo=$row_rek['saldo']-$nominal;
																		
									$qry_rek2=mysqli_query($koneksi,"SELECT * FROM `tb_rekening`  WHERE idanggota='".$idmember2."' order by id desc limit 1");
									$row_rek2=mysqli_fetch_array($qry_rek2);
									if(mysqli_num_rows($qry_rek2)<>0){
									$saldo2=$row_rek2['saldo']+$nominal;
									} else {$saldo2=$nominal;}
									
									$res2=mysqli_query($koneksi,"INSERT INTO `tb_transfer_bank` (`dari_idanggota`, `dari_nama`, `tujuan_idanggota`, `tujuan_nama`, `nominal`, `keterangan`, `status`,`iduser`, `tgl`) VALUES ('".$idmember."', '".$nama."', '".$idmember2."', '".$nama2."', '".$nominal."', '".$keterangan."', 'OPEN','".$row_user['id']."', current_timestamp());");
					if($res2){
									$res=mysqli_query($koneksi,"INSERT INTO `tb_rekening` (`idanggota`, `keterangan`, `in_out`, `nominal`, `saldo`, `reff`, `reff2`,`iduser`, `tgl`) VALUES ('".$idmember2."', '".$keterangan."', 'in', '".$nominal."', '".$saldo2."', '-', '-','".$row_user['id']."', current_timestamp()),('".$idmember."', '".$keterangan."', 'out', '".$nominal."', '".$saldo."', '-', '-','".$row_user['id']."', current_timestamp());");
					
					if($res){echo ' <div class="alert bg-green alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <strong>Well done!</strong> Simpan Data Sukses.
                            </div>';
							}else {
							echo '<div class="alert bg-pink alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                               <strong>Warning!</strong> Simpan Data Gagal.
                            </div>';
							}
							}//res2
							}}// batas saldo pengirim
					}
			} else {echo '<div class="alert bg-pink alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                               <strong>Warning!</strong> PIN Salah.
                            </div>';}
			} else {echo '<div class="alert bg-pink alert-dismissible" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                               <strong>Warning!</strong> Input Data dengan lengkap.
                            </div>';}
			}
			
			
			
			?>
 <div class="row clearfix">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="card">
                        <div class="header">
                            <h2>TRANSFER BANK ADD</h2>
                           
                        </div>
                        <div class="body">
						
						
                            <form id="form_advanced_validation" method="POST" action="index.php?transfer_bank&mn=transfer_bank_add">
							<div class="row">
							 <div class="col-sm-6">
                                <div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="idmember" id="idmember" onkeyup="func_anggota(this.value);"   required>
                                        <label class="form-label">ID Member/Nasabah</label>
                                    </div>
                                    <div class="help-info">Input ID Member/Nasabah</b></div>
                                </div>
								
								
								 <div class="row clearfix">
								  <div class="col-sm-4">
                                    <div class="form-group">
                                        <div class="form-line">
                                            <input type="text" class="form-control" name="saldo" id="saldo" min="3" max="120"  readonly="true" placeholder="saldo Member [DARI]" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <div class="form-line">
                                           <input type="text" class="form-control" name="nama" id="nama" min="3" max="120"  readonly="true" placeholder="Nama Member [DARI]" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <div class="form-line">
                                             <input type="text" class="form-control" name="alamat" id="alamat" min="3" max="120" readonly="true" placeholder="Alamat Member [DARI]" required>
                                        </div>
                                    </div>
                                </div>
                               
                            </div>
							</div>
							 <div class="col-sm-6">	
							  <div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="idmember2" id="idmember2" onkeyup="func_anggota2(this.value);"   required>
                                        <label class="form-label">ID BANk [TUJUAN]</label>
                                    </div>
                                    <div class="help-info">Input ID Bank Tujuan Transfer</b></div>
                                </div>
								
								
								 <div class="row clearfix">
								  <div class="col-sm-4">
                                    <div class="form-group">
                                        <div class="form-line">
                                            <input type="text" class="form-control" name="saldo2" id="saldo2" min="3" max="120"  readonly="true" placeholder="Saldo Bank [TUJUAN]" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <div class="form-line">
                                           <input type="text" class="form-control" name="nama2" id="nama2" min="3" max="120"  readonly="true" placeholder="Nama Bank [TUJUAN]" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <div class="form-line">
                                             <input type="text" class="form-control" name="alamat2" id="alamat2" min="3" max="120" readonly="true" placeholder="Alamat Bank [TUJUAN]" required>
                                        </div>
                                    </div>
                                </div>
                               
                            </div>
							</div>
							</div>
								
								
								 <div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="text" class="form-control" name="nominal" id="nominal" style="font-size:32px;" onkeypress="return isNumberKey(event);" required>
                                        <label class="form-label">Nominal IDR</label>
                                    </div>
                                    <div class="help-info">Input Nominal dalam IDR</b></div>
                                </div>
								
                                <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="form-group">
                                        <div class="form-line">
                                            <textarea rows="4" class="form-control no-resize" name="keterangan" placeholder="Keterangan Setoran..."></textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
								
	                             
								
							
								
                           		 <div style="font-size:18px; color:#336600;" ><b>Input PIN Petugas</b></div>
                       			<div style="height:20px;"></div>
								
									<div class="form-group form-float">
                                    <div class="form-line">
                                        <input type="password" class="form-control" name="pin" title="Masukkan PIN" required>
                                        <label class="form-label">PIN Transaksi (Petugas)</label>
                                    </div>
                                    <div class="help-info">Input PIN untuk keamanan Transaksi</div>
                                </div>
								
								
								
                                <button class="btn btn-primary waves-effect" name="submit" type="submit" data-toggle="tooltip" data-placement="right" title="Simpan Data">SIMPAN</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!-- #END# Advanced Validation -->
			<script>
			function func_anggota(idmember){
			document.getElementById("nama").value='';document.getElementById("alamat").value='';document.getElementById("saldo").value='';
			setCookie("url","https://nurululum-app.com/api/",365);

		var urlget=getCookie("url");
		
			$.ajax({
			type: 'GET',
		 	url: urlget+'anggota.php?api=AIzaSyARSSmIJjL5LuxZnrjkDnrD&id='+idmember,
			 cache: false,
		 	success: function (data) {
		 	var arr  = JSON.parse(data);
			var len = arr.length;		
			var i;
    		for(i = 0; i < len; i++) {
				document.getElementById("nama").value = arr[i].nama;	
				document.getElementById("alamat").value = arr[i].alamat;	
				
				$.ajax({
			type: 'GET',
		 	url: urlget+'saldo.php?api=AIzaSyARSSmIJjL5LuxZnrjkDnrD&id='+arr[i].idanggota,
			 cache: false,
		 	success: function (data) {
		 	var arr  = JSON.parse(data);
			var len = arr.length;		
			var i;
    		for(i = 0; i < len; i++) {
				document.getElementById("saldo").value = arr[i].saldo;	
				
			 }
    							
		 	},
		 	error: function () {
		 		alert('Error : Request Gagal, periksa koneksi Internet');
		 	}
		 });
				
			 }
    							
		 	},
		 	error: function () {
		 		alert('Error : Request Gagal, periksa koneksi Internet');
		 	}
		 });
		 }
		 
		 function func_anggota2(idmember){
			document.getElementById("nama2").value='';document.getElementById("alamat2").value='';document.getElementById("saldo2").value='';
			setCookie("url","https://nurululum-app.com/api/",365);

		var urlget=getCookie("url");
		
			$.ajax({
			type: 'GET',
		 	url: urlget+'anggota_bank.php?api=AIzaSyARSSmIJjL5LuxZnrjkDnrD&id='+idmember,
			 cache: false,
		 	success: function (data) {
		 	var arr  = JSON.parse(data);
			var len = arr.length;		
			var i;
    		for(i = 0; i < len; i++) {
				document.getElementById("nama2").value = arr[i].nama;	
				document.getElementById("alamat2").value = arr[i].alamat;	
				
				
				$.ajax({
			type: 'GET',
		 	url: urlget+'saldo.php?api=AIzaSyARSSmIJjL5LuxZnrjkDnrD&id='+arr[i].idanggota,
			 cache: false,
		 	success: function (data) {
		 	var arr  = JSON.parse(data);
			var len = arr.length;		
			var i;
    		for(i = 0; i < len; i++) {
				document.getElementById("saldo2").value = arr[i].saldo;	
				
			 }
    							
		 	},
		 	error: function () {
		 		alert('Error : Request Gagal, periksa koneksi Internet');
		 	}
		 });
			 }
    							
		 	},
		 	error: function () {
		 		alert('Error : Request Gagal, periksa koneksi Internet');
		 	}
		 });
		 }
			</script>