
<?php 
    include 'header.php'; 
    include '../fungsi_indotgl.php'; 
    
    $id  = $_GET['id'];
    $kab = $_GET['kab'];
    $kdc = $_GET['kdc'];
   
    $tgl_ini=date('d-m-Y') ;
    $tgl_ini2=date('Y-m-d') ;  

              // fungsi untuk membuat kode transaksi
                $sql1 = mysqli_query($koneksi, "SELECT right(angg_no,8) as kode3 FROM anggota WHERE kdc='$kdc' ORDER BY angg_no DESC LIMIT 1");
                list($kode3) = mysqli_fetch_array($sql1);
              $count3 = mysqli_num_rows($sql1);

              if ($count3 <> 0) {
                  // mengambil data kode transaksi
                  $data_id3 = mysqli_fetch_assoc($sql1);
                  $kode3    = $kode3+1;
                  $no_angg  = '0'.$kode3 ;
              } else {
                  $kode3 = $kdc.'1000001';
              } 
    $oleh=$_SESSION['id_kar'];
       $sql5 = mysqli_query($koneksi, "SELECT nama AS nama_kary FROM karyawan WHERE id='$oleh' ");
               list($nama_kary) = mysqli_fetch_array($sql5);       
?>    

<div class="container">
  <div class="my-4 border-bottom">
    <h3 class="fw-semibold fs-3">Tambah Customer Baru untuk <?php echo  $kab; ?></h3>
  </div>
  <section class="content">
    <div class="row justify-content-center">
      <section class="col-lg-7">       
        <?php 
        if(isset($_GET['alert'])){
          if($_GET['alert'] == "duplikat"){
            echo "<div class='alert alert-danger'><b>GAGAL!</b> No KK Sudah digunakan anggota <b>".$_GET['siapa']."</b>......!</div>";
          }
        }
        if(isset($_GET['alert2'])){
          if($_GET['alert2'] == "duplikat2"){
            echo "<div class='alert alert-danger'><b>GAGAL!</b> No ANGGOTA Sudah digunakan anggota <b>".$_GET['siapa']."</b>......!</div>";
          }
        }        
        ?>      
        <div class="card card-info">
          <div class="card-header d-flex justify-content-between">
            <span class="card-title fw-semibold"><font color='#ff0000'  style="text-align:left; font-size: 11pt; font-weight:normal;"><i>Halo <?php echo $nama_kary; ?>,  - Lengkapi data ini dan isi saja dengan strip (-) jika data belum diketahui....</i></font><br></span>
            <a href="angg_rkp_adm.php" class="btn btn-primary btn-sm"><i class="bi bi-reply-all"></i> &nbsp Kembali</a> 
          </div>
          <div class="card-body">
            <form action="angg_tambah_act.php" method="post">
              <div class="form-group mb-2">
                <div class="form-group">
                 <label>Kode Customer</label>        
                    <input type="hidden" name="tkdc" required="required" class="form-control" value=<?php echo $kdc; ?> readonly required >
                    <input type="hidden" name="tkdk" required="required" class="form-control" value=<?php echo $id; ?> readonly required >
                    <input type="hidden" name="tkab" required="required" class="form-control" value=<?php echo $kab; ?> readonly required >
                    <input type="hidden" name="toleh" required="required" class="form-control" value=<?php echo $oleh; ?> readonly required >
                    <input type="text" name="noang" class="form-control" value=<?php echo $no_angg; ?> readonly required >
                </div>                     
                <div class="form-group">
                  <label> <font color="#000fff">Nama Anggota</font></label>
                  <input type="text" name="nama" required="required" class="form-control" placeholder="Isikan Nama ..">
                </div>
                <div class="form-group">
                  <label><font color="#000fff">Alamat (Kelurahan RT / RW)</label>
                  <input type="text" name="alamat" required="required" class="form-control" placeholder="Isikan Alamat ..">
                </div> 

            	<div class="form-group">
                    <label class="form-label">Kecamatan <font color='#ff0000'><i>(Pilih Kecamatan)</i></font color></label>
                    <select class="form-control" name="xkdkec" required="required">
                      <option value="">- Pilih Kecamatan -</option>
                      <?php 
                      $kec = mysqli_query($koneksi,"select * from kdkecamatan WHERE kdkab='$id'");
                      while($rx = mysqli_fetch_array($kec)){
                        ?>
                        <option value="<?php echo $rx['kd'] ?>"><?php echo $rx['kd'] ?> - <?php echo $rx['kecamatan'] ?></option>
                        <?php 
                      }
                      ?>
                    </select>
            	</div>                         
                <div class="form-group">
                  <label><font color="#000fff">Tempat Tanggal Lahir</label>
                  <input type="text" name="tpt" required="required" class="form-control" placeholder="Isikan Tempat Tanggal Lahir ..">
                </div>              
                <div class="form-group">
                  <label><font color="#000fff">Umur (Thn)</label>
                  <input type="text" name="umur" required="required" class="form-control" placeholder="Isikan Umur ..">
                </div>                
                <div class="form-group">
                  <label><font color="#000fff">No. KTP <font color='#ff0000'><i>(Harus diisi 16 Digit)</i></font color></font></label>
                  <input type="text" minlength="16" maxlength = "16" name="ktp" required="required" class="form-control" placeholder="Isikan Nomor KTP ..">
                </div>                
                <div class="form-group">
                  <label><font color="#000fff">No KK <font color='#ff0000'><i>(Harus diisi 16 Digit)</i></font color></font></label>
                  <input type="text" minlength="16" maxlength = "16" name="kk" required="required" class="form-control" placeholder="Isikan Nomor KK ..">
                </div>                
                <div class="form-group">
                  <label><font color="#000fff">Nama Suami/Istri/Orang Tua</font></label>
                  <input type="text" name="suami" required="required" class="form-control" placeholder="Isikan Nama Suami/Istri ..">
                </div>         
                <div class="form-group">
                  <label><font color="#000fff">Hubungan Nama terhadap Customer</font></label>
                  <input type="text" name="sebagai" required="required" class="form-control" placeholder="Isikan Hubungan Nama terhadap Customer ..">
                </div>
                <div class="form-group">
                  <label><font color="#000fff">Nomor HP Customer</font></label>
                  <input type="text" name="hp" required="required" class="form-control" placeholder="Isikan nomor HP Customer ..">
                </div>
                <div class="form-group">
                  <label><font color="#000fff">Nomor HP Kerabat Customer Untuk Konfirmasi</font></label>
                  <input type="text" name="hp_kon" required="required" class="form-control" placeholder="Isikan nomor HP lain (konfirmasi) Customer ..">
                </div>                
                <div class="form-group">
                   <label class="form-label"><font color="#000fff">Tanggal Masuk</font></label>
                   <input type="date" class="form-control" name="tgl" required="required" placeholder="Masukkan Tanggal ..">
                </div>    
              </div>  
              <div class="form-group mb-2">
                <input type="submit" class="btn btn-primary" value="Simpan">
              </div>
            </form>
          </div>
        </div>
      </section>
    </div>
  </section>
</div>

<?php include 'footer.php'; ?>