
<!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'];
    $user_id_toko=30-$id;
    $kd  = $_GET['kd'];
    
        $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'] ; 
                $hp_no  =$a['hp'];
                $nama   =$a['nama'];
                $alamat =''.$a['alamat'].' RT '.$a['rt'].' RW '.$a['rw'].'' ;

        $kanca = mysqli_query($koneksi,"select * from kdkanca ");
            $k = mysqli_fetch_assoc($kanca);            

        $judul=''.$k['kanca'].'' ;
    
      $tnohp        = $hp_no;
      $potong_nohp  = substr($tnohp,1,12);
      $kd           = '62';
      $nohp_tujuan  = '62'.$potong_nohp ;
      $keter='Terimakasih yang sebesar-besarnya kepada Bpk/Ibu '.$nama.', '.$alamat.', yg telah mempercayakan pengelolaan Zaat/Infak/Sodakoh kepada takmir '.$k['kanca'].','.$k['alamat'].'';
      $trim_ket = trim($keter);
      $jabatan = ' Pengelola Toko / TPK '.$nama_tpk.' di '.$alam_tpk.'';
    ?>
	<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>Ucapan Terimakasih Kepada : <?php echo $nama ; ?> </h4>
			<div class="panel panel-success">
				<div class="panel-heading">
					Kirim WA kepada <?php echo $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 $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>	
					<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_jabatan 		= $("#jabatan").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' +
				    '*Jabatan* : ' + input_jabatan + '%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>