<!DOCTYPE html>
<html>
   <head>

      <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
      <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
   </head>

<body>

    
    <?php
    include 'header.php'; 
    
    $id     = $_GET['id'];
    $hp_no  = $_GET['hp'];

        $anggota = mysqli_query($koneksi,"select * from anggota where angg_id='$id'");
            $a = mysqli_fetch_assoc($anggota);
                $rt   =$a['rt'] ;
                $rw   =$a['rw'] ;
                $noang=$a['angg_no'] ;
                
        $unik = mysqli_query($koneksi,"select * from kode_unik where id='$id'");
            $u = mysqli_fetch_assoc($unik);        
                
        $kanca = mysqli_query($koneksi,"select * from kdkanca ");
            $k = mysqli_fetch_assoc($kanca);            

               $sql1 = mysqli_query($koneksi, "SELECT rt AS art FROM kd_rt WHERE id='$rt' ");
                       list($art) = mysqli_fetch_array($sql1);
               $sql0 = mysqli_query($koneksi, "SELECT rw AS arw FROM kd_rw WHERE id='$rw' ");
                       list($arw) = mysqli_fetch_array($sql0);  
                       
        $alamat=''.$a['alamat'].', RT '.$rt.' RW '.$rw.', '.$k['kelurahan'].', '.$k['kecamatan'].'' ;  
        $judul=''.$k['kanca'].'' ;
    
      $tnohp        = $hp_no;
      $potong_nohp  = substr($tnohp,1,12);
      $kd           = '62';
      $nohp_tujuan  = '62'.$potong_nohp ;
      $keter=' Pasword Anda telah direset. User : '.$noang.' dan password : '.$u['kode'].'. Silahkan klik link berikut ini : '.$k['hosting_anggota'].' , kemudian LOGIN dengan User dan password tersebut, anda akan melihat data diri dan transaksi Anda.  Terimakasih';
      $trim_ket = trim($keter)
    ?>
	<div class="container">
	    
    </br>
    </br>
      <button type="button" class="btn btn-primary btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
        <a href="javascript:history.go(-1)" class="btn btn-primary btn-sm"><i class="bi bi-reply-all"></i> &nbsp Kembali</a> 
      </button>    
    </br>
    </br>
    </br>	   
<div style="background-color: <?php echo$_SESSION['warna_bag']; ?>; padding: 15px; border-radius: 15px; box-shadow: 0 0 15px <?php echo$_SESSION['warna_bag']; ?>;">
		<div class="col-lg-6 col-lg-offset-3">
			<h4>Reset Pasword Anggota </h4>
			<div class="panel panel-success">
				<div class="panel-heading">
					Kirim WA kepada <?php echo $a['nama'] ; ?> No. HP <?php echo $a['hp']; ?>
     <div class="card-header d-flex justify-content-between">

    </div>   			
				</div>
				</div>
				<div class="panel-body">
					<div class="form-group">
						<label>Dikirim ke Nomor WhatsApp : </label>
						<input type="text" name="phone" class="form-control" placeholder="Nomor Kontak / WhatsApp" id="phone" value=<?php echo $nohp_tujuan; ?> 
					</div>
					<div class="form-group">
						<label><font color="#000fff">Nama : </font></label>
                        <input type="text" class="form-control" name="name" id="name" value="<?php echo $a['nama'] ?>" required="required" >
					</div>
					<div class="form-group">
						<label><font color="#000fff">Alamat : </font></label>
                        <input type="text" class="form-control" name="alamat" id="alamat" value="<?php echo strtoupper($alamat) ?>" required="required" >
                        <input type="hidden" class="form-control" name="datadiri" id="datadiri" value="<?php echo strtoupper($alamat) ?>" required="required" >
                        <input type="hidden" class="form-control" name="konfirmasi" id="konfirmasi" value="<?php echo strtoupper($alamat) ?>" required="required" >
                        <input type="hidden" class="form-control" name="judul" id="judul" value="<?php echo strtoupper($judul) ?>" required="required" >
					</div>
                    <div class="form-group">
                        <label><font color="#000fff">Berita : </font></label>
                        <textarea class="form-control" name="ket" id="ket" rows="5" required="required"><?php echo $keter; ?></textarea>
                    </div>
					<div class="form-group">
						<br>
						<button class="btn btn-success send">Kirim Pesan via WhatsApp</button>
					</div>					


					<div id="text-info"></div>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		$(document).on('click','.send', function(){
			/* Inputan Formulir */
			var input_name 			= $("#name").val(),
			    input_alamat 		= $("#alamat").val(),
			    input_phone 		= $("#phone").val(),
			    input_ket 	        = $("#ket").val();
			    input_judul	        = $("#judul").val();

			/* Pengaturan Whatsapp */
			var walink 		= 'https://web.whatsapp.com/send',
			    phone 		= $("#phone").val(),
			    text 		= $("#judul").val(),
			    text_yes	= 'Pesan Anda berhasil terkirim.',
			    text_no 	= 'Isilah formulir terlebih dahulu.';

			/* Smartphone Support */
			if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
				var walink = 'whatsapp://send';
			}

			if(input_name != "" && input_phone != "" && input_ket != ""){
				/* Whatsapp URL */
				var checkout_whatsapp = walink + '?phone=' + phone + '&text=' + text + '%0A%0A' +
				    '*Kepada* : ' + input_name + '%0A' +
				    '*Alamat* : ' + input_alamat + '%0A' +
				    'INFO RAHASIA - ' + input_ket + '%0A';

				/* Whatsapp Window Open */
				//window.open(checkout_whatsapp,'_blank');/
				window.open(checkout_whatsapp,'');
				document.getElementById("text-info").innerHTML = '<div class="alert alert-success">'+text_yes+'</div>';
			} else {
				document.getElementById("text-info").innerHTML = '<div class="alert alert-danger">'+text_no+'</div>';
			}
		});
	</script>

</body>
</html>