<?php 
    session_start();
    include '../koneksi.php';
    include '../cari_notrans.php';
    
      $tgl_awal     = date_create('2025-01-01');
      $tgl_sekarang = date_create();
      $tgl_d        = $tgl_awal ;
      $tgl_s        = $tgl_sekarang ;
  
    $tgl_skr    = date('Y-m-d');
    $harinya    = (date('d', strtotime($tgl_skr)))-1 ;
    $tg_skr     = strtotime("$tgl_skr");
    $tgl_dr     = date('Y-m-d', strtotime("-$harinya day", $tg_skr));     


	$nominalb = str_replace("Rp.", "", $thbeli);
	$nominalb = str_replace(".", "", $nominalb);
	$nominalb = str_replace(",", "", $nominalb);  
	
	$nominal = str_replace("Rp.", "", $tnotrans);
	$nominal = str_replace(".", "", $nominal);
	$nominal = str_replace(",", "", $nominal);  
	
	$tot_hrg=$tjumlah*$nominalb ;
	
    $aksi = $_POST['aksi'];
    switch ($aksi) {
    case 'insert_kelompok':
    // kode untuk insert_kelompok
    
        $tkd     = $_POST['tkd'];
        $tnama   = $_POST['tnama'];
        $takunt_as    = $_POST['takunt_as'];
        $takunt_ak    = $_POST['takunt_ak'];
        $takunt_ph    = $_POST['takunt_ph'];
        $takunt_lb    = $_POST['takunt_lb'];
        $takunt_rg    = $_POST['takunt_rg'];
        /////////// 
        $query = mysqli_query($mysqli, "INSERT INTO kdjenis_at (kd,nama,akunt_as,akunt_ak,akunt_ph,akunt_lb,akunt_rg) 
                                        VALUES('$tkd','$tnama','$takunt_as','$takunt_ak','$takunt_ph','$takunt_lb','$takunt_rg')")
                                        or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                        
        header("location:at_kode_jenis.php");
    
    break;        
    case 'edit_kelompok':
    // kode untuk edit_kelompok
        $tid     = $_POST['tid'];
        $tkd     = $_POST['tkd'];
        $tnama   = $_POST['tnama'];
        $takunt_as    = $_POST['takunt_as'];
        $takunt_ak    = $_POST['takunt_ak'];
        $takunt_ph    = $_POST['takunt_ph'];
        $takunt_lb    = $_POST['takunt_lb'];
        $takunt_rg    = $_POST['takunt_rg'];
        /////////// 
        $query = mysqli_query($mysqli, "UPDATE kdjenis_at SET kd='$tkd',nama='$tnama',akunt_as='$takunt_as',akunt_ak='$takunt_ak',akunt_ph='$takunt_ph',akunt_lb='$takunt_lb',akunt_rg='$takunt_rg' where id='$tid' ");
                                    
        header("location:at_kode_jenis.php");

    break;        
    case 'isi_ph_bln':
    // kode untuk edit_kelompok
        $tid     = $_POST['tid'];
        $tkd     = $_POST['tkd'];
        $tbln    = $_POST['tbln'];
        $tthn    = $_POST['tthn'];
        $tn_ph_bln    = $_POST['tn_ph_bln'];
            //////////////////////////////////////////////////////////////////////////// 
        $oleh = $_SESSION['id_kar'];
        $kdc = $_SESSION['kdc'];
        $tabel_tujuan = "cmob_trans_".$oleh."_".$kdc;
        $tabel_asal = "cmob_trans";
            ////////////////////////////////////////////////////////////////////////////
	$nominalb = str_replace("Rp.", "", $tn_ph_bln);
	$nominalb = str_replace(".", "", $nominalb);
	$nominalb = str_replace(",", "", $nominalb);              
        /////////// 
        $query = mysqli_query($mysqli, "UPDATE $tabel_tujuan SET be_ph='$nominalb' where id='$tid' ");
                                    
        header("location:at_penyusutan_2.php?xbulan=$tbln&xtahun=$tthn&xkas=$tkd");
        
        
    break;
    case 'simpan_jornal_penyusutan':
    // kode untuk simpan_jornal_penyusutan
    
        $toleh    = $_POST['toleh'];
        $tkd    = $_POST['tkd'];
        $tbln    = $_POST['tbln'];
        $tthn    = $_POST['tthn'];

        $tnilai    = $_POST['tnilai'];
        $tgle     = $_POST['ttanggal'];
        
	$nominal = str_replace("Rp.", "", $tnilai);
	$nominal = str_replace(".", "", $nominal);
	$nominal = str_replace(",", "", $nominal); 
	
    $sql1 = mysqli_query($koneksi, "SELECT nama AS tx_nama,akunt_ak AS tx_akunt_ak,akunt_ph AS tx_akunt_ph FROM kdjenis_at WHERE kd='$tkd' ");
            list($tx_nama,$tx_akunt_ak,$tx_akunt_ph) = mysqli_fetch_array($sql1);
                
	$takunt_d=$tx_akunt_ph ;
	$takunt_k=$tx_akunt_ak ;
	
	$tket='Penyusutan '.$tx_nama.', '.$tbln.'-'.$tthn.'' ;
	$tr='PH' ;
	$td=$tkd ;
            //////////////////////////////////////////////////////////////////////////// 
        $oleh   = $_SESSION['id_kar'];
        $kdc    = $_SESSION['kdc'];
        $tabel_tujuan   = "cmob_trans_".$oleh."_".$kdc;
        $tabel_asal     = "cmob_trans";
            //////////////////////////////////////////////////////////////////////////// 	
	        $ttj = mysqli_query($koneksi,"SELECT * FROM $tabel_tujuan WHERE kd='$tkd' order by kode ASC ");
            while($p = mysqli_fetch_array($ttj)){
                $tkode   =$p['kode'];
                $tpeny   =$p['be_ph'];
   
           
              
            /////////// 
            $query = mysqli_query($mysqli, "INSERT INTO cmob_trans (notrans,tanggal,kd,kode,be_ph,kt) 
                                    VALUES('$kode3','$tgle','$tkd','$tkode','$tpeny','$tr' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
            }                          
                                    
    ///////////             MENYIMPAN KE TABEL KAS
    $query = mysqli_query($mysqli, "INSERT INTO kas (tanggal,notrans,kdc,keterangan,tr,td,jumlah,noperk,oleh,jam) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_k','$toleh',(now()) )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                    
    ///////////             MENYIMPAN KE TABEL JOR DEBET
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,debet,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_d' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
    ///////////             MENYIMPAN KE TABEL JOR KREDIT
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,kredit,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_k' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli)); 
    //////////                    

        header("location:at_penyusutan.php");
        



    break;
    case 'insert_jornal_biaya_service_at':
    // kode untuk insert_jornal_biaya_service_at
    
        $toleh    = $_POST['toleh'];
        $tkd      = $_POST['tkd'];
        $tkode    = $_POST['tkode'];
        $tbiaya   = $_POST['tbiaya'];
        $tgle     = $_POST['ttanggal'];
        $takunt   = $_POST['takunt'];
        $tket     = $_POST['tket'];

        $tnilai    = $_POST['tnilai'];
        $tgle     = $_POST['ttanggal'];
        
	$nominal = str_replace("Rp.", "", $tbiaya);
	$nominal = str_replace(".", "", $nominal);
	$nominal = str_replace(",", "", $nominal); 
	
    $sql1 = mysqli_query($koneksi, "SELECT nama AS tx_nama,akunt_bi AS tx_akunt_bi FROM kdjenis_at WHERE kd='$tkd' ");
            list($tx_nama,$tx_akunt_bi) = mysqli_fetch_array($sql1);
                
	$takunt_d=$tx_akunt_bi ;
	$takunt_k=$takunt ;
	
	$tket='Biaya '.$tx_nama.', '.$tket.'' ;
	$tr='BI' ;
	$td=$tkd ;
            //////////////////////////////////////////////////////////////////////////// 
        $oleh   = $_SESSION['id_kar'];
        $kdc    = $_SESSION['kdc'];
            /////////// 
            $query = mysqli_query($mysqli, "INSERT INTO cmob_trans (notrans,tanggal,kd,kode,biaya,kt) 
                                    VALUES('$kode3','$tgle','$tkd','$tkode','$nominal','$tr' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                   
    ///////////             MENYIMPAN KE TABEL KAS
    $query = mysqli_query($mysqli, "INSERT INTO kas (tanggal,notrans,kdc,keterangan,tr,td,jumlah,noperk,oleh,jam) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_k','$toleh',(now()) )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                    
    ///////////             MENYIMPAN KE TABEL JOR DEBET
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,debet,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_d' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
    ///////////             MENYIMPAN KE TABEL JOR KREDIT
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,kredit,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_k' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli)); 
    //////////                    
        header("location:at_daftar_barang.php");




    break;
    case 'insert_jornal_pendapatan_jasa_at':
    // kode untuk insert_jornal_pendapatan_jasa_at
    
        $toleh    = $_POST['toleh'];
        $tkd      = $_POST['tkd'];
        $tkode    = $_POST['tkode'];
        $tjasa    = $_POST['tjasa'];
        $tgle     = $_POST['ttanggal'];
        $takunt   = $_POST['takunt'];
        $tket     = $_POST['tket'];
        
	$nominal = str_replace("Rp.", "", $tjasa);
	$nominal = str_replace(".", "", $nominal);
	$nominal = str_replace(",", "", $nominal); 
	
    $sql1 = mysqli_query($koneksi, "SELECT nama AS tx_nama,akunt_sw AS tx_akunt_sw FROM kdjenis_at WHERE kd='$tkd' ");
            list($tx_nama,$tx_akunt_sw) = mysqli_fetch_array($sql1);
                
	$takunt_k=$tx_akunt_sw ;
	$takunt_d=$takunt ;
	
	$tket='Pendapatan Jasa '.$tx_nama.', '.$tket.'' ;
	$tr='SW' ;
	$td=$tkd ;
            //////////////////////////////////////////////////////////////////////////// 
        $oleh   = $_SESSION['id_kar'];
        $kdc    = $_SESSION['kdc'];
            /////////// 
            $query = mysqli_query($mysqli, "INSERT INTO cmob_trans (notrans,tanggal,kd,kode,pendapatan,kt) 
                                    VALUES('$kode3','$tgle','$tkd','$tkode','$nominal','$tr' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                   
    ///////////             MENYIMPAN KE TABEL KAS
    $query = mysqli_query($mysqli, "INSERT INTO kas (tanggal,notrans,kdc,keterangan,tr,td,jumlah,noperk,oleh,jam) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_k','$toleh',(now()) )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                    
    ///////////             MENYIMPAN KE TABEL JOR DEBET
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,debet,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_d' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
    ///////////             MENYIMPAN KE TABEL JOR KREDIT
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,kredit,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal','$takunt_k' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli)); 
    //////////                    

        header("location:at_daftar_barang.php");




    
    break;
    case 'insert_jornal_beli':
    // kode untuk insert_jornal_beli
    
        $toleh    = $_POST['toleh'];
        $tkd    = $_POST['tkd'];
        $tkode  = $_POST['tkode'];
        $tnama    = $_POST['tnama'];
        $tunit    = $_POST['tunit'];
        $thbeli    = $_POST['thbeli'];
        $tumur    = $_POST['tumur'];
        $tsewa    = '';
        $tgle     = $_POST['ttanggal'];
        $takunt   = $_POST['takunt'];
        
	$nominal = str_replace("Rp.", "", $thbeli);
	$nominal = str_replace(".", "", $nominal);
	$nominal = str_replace(",", "", $nominal); 
	
	$h_beli=$tunit*$nominal;
	$ph_bln=$h_beli/($tumur*12);
	
        $sql1 = mysqli_query($koneksi, "SELECT akunt_as AS takunt_as FROM kdjenis_at WHERE kd='$tkd' ");
                list($takunt_as) = mysqli_fetch_array($sql1);
                
	$takunt_k=$takunt ;
	$takunt_d=$takunt_as ;
	
	$tket='Pembelian Aset Tetap '.$tunit.' '.$tnama.' @ '.$thbeli.',-' ;
	$tr='BL' ;
	$td=$tkd ;
        /////////// 
    $query = mysqli_query($mysqli, "INSERT INTO cmob_trans (notrans,tanggal,kd,kode,noperk,beli,kt,u_beli) 
                                    VALUES('$kode3','$tgle','$tkd','$tkode','$takunt_d','$h_beli','$tr','$tunit' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
    $query = mysqli_query($mysqli, "INSERT INTO cmob_brg (notrans,tanggal,kd,kode,u_beli,a_beli,n_beli,ph,ph_bln,kelompok,nama) 
                                    VALUES('$kode3','$tgle','$tkd','$tkode','$tunit','$nominal','$h_beli','$tumur','$ph_bln','$tsewa','$tnama' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));                                    
    ///////////             MENYIMPAN KE TABEL KAS
    $query = mysqli_query($mysqli, "INSERT INTO kas (tanggal,notrans,kdc,keterangan,tr,td,jumlah,noperk,oleh,jam) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$h_beli','$takunt_k','$toleh',(now()) )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                    
    ///////////             MENYIMPAN KE TABEL JOR DEBET
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,debet,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$h_beli','$takunt_d' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
    ///////////             MENYIMPAN KE TABEL JOR KREDIT
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,kredit,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$h_beli','$takunt_k' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli)); 
    //////////                    
      $tgl_awal     = date_create('2025-01-01');
      $tgl_sekarang = date_create();
      $tgl_d        = $tgl_awal ;
      $tgl_s        = $tgl_sekarang ;
  
    $tgl_skr    = date('Y-m-d');
    $harinya    = (date('d', strtotime($tgl_skr)))-1 ;
    $tg_skr     = strtotime("$tgl_skr");
    $tgl_dr     = date('Y-m-d', strtotime("-$harinya day", $tg_skr));        
    
        header("location:at_pembelian.php");
        
        
        
    break;
    case 'insert_jornal_jual_at':
    // kode untuk insert_jornal_jual_at
    
        $toleh    = $_POST['toleh'];
        $tkd      = $_POST['tkd'];
        $tkode    = $_POST['tkode'];
        $tunit    = $_POST['tunit'];
        $thjual   = $_POST['thjual'];
        $tgle     = $_POST['ttanggal'];
        $takunt   = $_POST['takunt'];
        
 	$nominal_j = str_replace("Rp.", "", $thjual);
	$nominal_j = str_replace(".", "", $nominal_j);
	$nominal_j = str_replace(",", "", $nominal_j); 
       
        $cmob_brg = mysqli_query($koneksi,"select * from cmob_brg where kode='$tkode'");
        $c = mysqli_fetch_assoc($cmob_brg);
        $nbuku_sat=($c['n_beli']-$c['be_ph'])/$c['u_beli'] ;
        $njual_sat=$nominal_j/$tunit;
        $nbeli_sat=($c['n_beli']/$c['u_beli']) ;
            
        $nbuku_dijual       =$tunit*$nbuku_sat ;
        $penyusutan_dijual  =($c['be_ph']/$c['u_beli'])*$tunit;
        $nbeli_dijual       =$tunit*$nbeli_sat ;
        
            
	
	if ($nbuku_dijual<=$nominal_j) {
	    $laba=$nominal_j-$nbuku_dijual ;
	} else {
	    $rugi=$nbuku_dijual-$nominal_j ;
	}    
	
            $kdjenis_at = mysqli_query($koneksi,"select * from kdjenis_at where kd='$c[kd]'");
            $k = mysqli_fetch_assoc($kdjenis_at);
                
	$takunt_d=$takunt ;
	$min_jual=($nbeli_dijual*-1) ;
	$min_unit=($tunit*-1);
	$min_be_ph=($penyusutan_dijual*-1);

	$tket='Penjualan Aset Tetap '.$tunit.' '.$c['nama'].' Rp. '.$thjual.',-' ;
	$tr='JL' ;
	$td=$c['kd'] ;
        /////////// 
    $query = mysqli_query($mysqli, "INSERT INTO cmob_trans (notrans,tanggal,kd,kode,noperk,beli,kt,u_beli,be_ph,jual,biaya,pendapatan) 
                                    VALUES('$kode3','$tgle','$c[kd]','$tkode','$takunt_d','$min_jual','$tr','$min_unit','$min_be_ph','$nominal_j','$rugi','$laba' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
    ///////////             MENYIMPAN KE TABEL KAS
    $query = mysqli_query($mysqli, "INSERT INTO kas (tanggal,notrans,kdc,keterangan,tr,td,jumlah,noperk,oleh,jam) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal_j','$takunt_d','$toleh',(now()) )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
                                    
    ///////////             MENYIMPAN KE TABEL JOR DEBET (KAS/BANK)
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,debet,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nominal_j','$takunt_d' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));
    ///////////             MENYIMPAN KE TABEL JOR KREDIT (AKUMULASI PENYUSUTAN)
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,debet,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$penyusutan_dijual','$k[akunt_ak]' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));     
    /////                   MENYIMPAN KE TABEL JOR DEBET (JIKA RUGI)        
    if ($rugi>= 1) {
        $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,kredit,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$rugi','$k[akunt_rg]' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));          
    }                                    
    ///////////             MENYIMPAN KE TABEL JOR KREDIT (ASSET TETAP)
    $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,kredit,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$nbeli_dijual','$k[akunt_as]' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli)); 
                                
    ///////////             MENYIMPAN KE TABEL JOR KREDIT (JIKA LABA)
    if ($laba>= 1) {
        $query = mysqli_query($mysqli, "INSERT INTO jor (tanggal,notrans,kdc,keterangan,tr,td,kredit,noperk) 
                                    VALUES('$tgle','$kode3','$tkdc','$tket','$tr','$td','$laba','$k[akunt_lb]' )")
                                    or die('Ada kesalahan pada query insert : '.mysqli_error($mysqli));                                 
    } 
                                    

        header("location:at_daftar_barang.php");
        
        
        

    break;
    default:
    // kode jika aksi tidak ditemukan
    break;
    
$aksi = $_GET['aksi'];
$id = $_GET['id'];
$notrans = $_GET['notrans'];
}

if (isset($_POST['aksi']) && $_POST['aksi'] == 'delete_baris_kelompok') {
  $id = $_POST['id'];
  // kode untuk delete
        mysqli_query($koneksi, "delete from kdjenis_at where id='$id'");
        
       header("location:at_kode_jenis.php");
  // redirect atau tampilkan pesan sukses
}

$aksi2 = $_GET['aksi2'];
$notrans = $_GET['notrans'];
if (isset($_POST['aksi2']) && $_POST['aksi2'] == 'delete_jornal') {
  $notrans = $_POST['notrans'];
  // kode untuk delete
        mysqli_query($koneksi, "delete from jor where notrans='$notrans'");
        mysqli_query($koneksi, "delete from kas where notrans='$notrans'");
        mysqli_query($koneksi, "delete from brg_mts where notrans='$notrans'");
        mysqli_query($koneksi, "delete from brg_mts_r where notrans='$notrans'");
        
       header("location:toko_trans_beli_tgl_sd_tgl.php?tanggal_d=$tgl_dr&tanggal_s=$tgl_skr");
  // redirect atau tampilkan pesan sukses
}

$aksi3 = $_GET['aksi3'];
$notrans3 = $_GET['notrans3'];
if (isset($_POST['aksi3']) && $_POST['aksi3'] == 'delete_angsuran') {
  $notrans3 = $_POST['notrans3'];
  $no_kdr = $_POST['no_kdr'];
  // kode untuk delete
        mysqli_query($koneksi, "delete from jor where notrans='$notrans3'");
        mysqli_query($koneksi, "delete from kas where notrans='$notrans3'");
        mysqli_query($koneksi, "delete from brg_angs where notrans='$notrans3'");

       header("location:toko_trans_beli_per_nota.php?id=$no_kdr");
  // redirect atau tampilkan pesan sukses
}


