<?php
/*cara perbaiki xampp error Error: MySQL shutdown unexpectedly sukses 100%
1. mysqld --console --skip-grant-tables --skip-external-locking
2. mentasi table rusak 
ALTER TABLE yourtable_name DISCARD TABLESPACE ;

ALTER TABLE yourtable_name IMPORT TABLESPACE ;


https://www.youtube.com/watch?v=K7gyclhWo1Y*/
/*error_reporting(0);*/
include('../koneksi.php');
if (isset($_GET['rekening']) AND isset($_GET['tgl'])){
/*$rek          = array('gadai'=>'1.120.10','jualbeli'=>'1.120.20');*/
$rekening = $_POST['rekening'];
}
$no_bukti     = $_POST['no_faktur'];
$username     = $_SESSION['username'];
$kode         = $_SESSION['kode'];
/*$rekening     = $rek($_POST['akad']);*/
$rekening     = $_POST['rekening'];
$tgl          = date('Y-m-d',strtotime($_POST['tgl']));
$tglsystem    = $_POST['tglsystem'];
$pokok        = str_replace(",", "", $_POST['pokok']);
$margin       = str_replace(",", "", $_POST['margin']);
$jumlah       = $pokok+$margin;
$keterangan   = $_POST['keterangan'];
$bakidebet   = str_replace(",", "", $_POST['bakidebet'])-$pokok;

$query = mysqli_query($koneksi,"UPDATE angsuran SET rekening='$rekening',no_bukti='$no_bukti',tgl='$tgl',pokok='$pokok',margin='$margin',keterangan='$keterangan',username='$username' WHERE no_bukti='$no_bukti' ")or die(mysqli_error($koneksi));
$query = mysqli_query($koneksi,"UPDATE pinjaman SET bakidebet='$bakidebet' where rekening='$rekening' ")or die(mysqli_error($koneksi));

$query = mysqli_query($koneksi,"DELETE FROM bukubesar WHERE no_bukti='$no_bukti' ")or die(mysqli_error($koneksi));

$query = mysqli_query($koneksi,"INSERT INTO bukubesar SET id_jurnal='0', no_bukti='$no_bukti',tanggal='$tgl',kode_akun='1.100.10',debet='$jumlah',kredit='0',keterangan='$keterangan',kode='$kode',username='$username',tglsystem='$tglsystem' ")or die(mysqli_error($koneksi));
$query = mysqli_query($koneksi,"INSERT INTO bukubesar SET id_jurnal='0',no_bukti='$no_bukti',tanggal='$tgl',kode_akun='1.120.10',debet='0',kredit='$pokok',keterangan='$keterangan',kode='$kode',username='$username',tglsystem='$tglsystem' ")or die(mysqli_error($koneksi));
$query = mysqli_query($koneksi,"INSERT INTO bukubesar SET id_jurnal='0',no_bukti='$no_bukti',tanggal='$tgl',kode_akun='4.410.10',debet='0',kredit='$margin',keterangan='$keterangan',kode='$kode',username='$username',tglsystem='$tglsystem' ")or die(mysqli_error($koneksi));
echo "Data Sukses Disimpan--!!!";



?>
