<?php require_once('koneksi.php'); ?>
<?php include('libfungsi.php'); ?>
<?php
mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT * FROM nokw";
$Recordset1 = mysql_query($query_Recordset1, $conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if(isset($_POST['netfaktur']))
{
$anetfaktur= $_POST['netfaktur'];
$kodepelanggan=$_POST['no_reg_konter'];
$namapelanggan=$_POST['nama_pelanggan'];
$no_counternofaktur= $_POST['no_faktur'];
if(empty($anetfaktur))
{
echo("Tak memilih faktur");
}
else
{
$N = count($anetfaktur);
$total= 0;
for($i=0; $i < $N; $i++)
{
// echo("Anda memilih $i no Faktur: ");
$nofak=substr($anetfaktur[$i],0,21);
// echo($nofak." ");
$nilfak=(int) substr($anetfaktur[$i],22,38);
// echo "Nilai Faktur Rp.".$nilfak. "<br/> ";
$total=$total+$nilfak;
}
}
// echo "Total Nilai Faktur : ";
// echo $total." <br/>";
}
else
exit;
?>
<?php
$tmptgl=date('d-m-Y'); $tgj=date('d')+13 ; $blj=date('m'); $thj=date('Y');
$query = "SELECT max(no) AS akhir FROM nokw" ;
$hasil = mysql_query($query);
if (!$hasil) { // add this check.
die('Invalid query: ' . mysql_error());
}
$data = mysql_fetch_array($hasil);
$lastNo = $data['akhir'];
// baca nomor urut transaksi dari id transaksi terakhir
$lastNoUrut = $lastNo;
// nomor urut ditambah 1
$nextNoUrut = $lastNoUrut + 1;
// membuat format nomor transaksi berikutnya
$nextNo = sprintf('%06s', $nextNoUrut)."/AKP/KW/".$thj."/".$blj;
?>
<html>
<head>
<title>proses kwitansi</title>
<script type="text/javascript" src="../library/calendar.js"></script><br>
<script type="text/javascript" src="../library/calendar-en.js"></script>
<!-- language for the calendar -->
<script type="text/javascript" src="../stok/calendar-setup.js"></script>
<style type="text/css">
<!--
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../library/calendar-win2k-1.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style3 {font-family: Arial, Helvetica, sans-serif; font-size: 24px; }
-->
</style>
</head>
<body>
<form action="rekam.php" method="get">
<table width="544" border="1" align="center">
<tr>
<td colspan="2"><div align="center">
<h3>FORM PEMBAYARAN </h3>
</div></td>
</tr>
<tr>
<td width="157" nowrap>No Kwitansi</td>
<td width="350"><input name="no_kwitansi" type="text" id="no_kwitansi" value="<?php echo $nextNo; ?> "> <input name="nextNo" type="hidden" id="nextNo" value="<?php echo $nextNoUrut; ?>"></td>
</tr>
<tr>
<td>Tanggal Pembayaran </td>
<td> <?php $tmptgl=date('d-m-Y'); $tgj=date('d') ; $blj=date('m'); $thj=date('Y'); ?> <input name="date_in" type="text" id="f_date_b"
value="<?php echo $tmptgl ; ?>" size="12">
<button type="reset" id="f_trigger_b">...</button></td>
</tr>
<tr>
<td>Pembayaran dari </td>
<td><?php echo $namapelanggan ;?> <input name="no_reg_konter" type="hidden" id="no_reg_konter" value="<?php echo $kodepelanggan; ?>"></td>
</tr>
<tr>
<td>Total Pembayaran : </td>
<td><?php echo 'Rp. '.Rp($total) ; ?>
<?php for($i=0; $i < $N; $i++) { ?>
<input name="afaktur[]" type="hidden" id="afaktur" value="<?php echo substr($anetfaktur[$i],0,21) ; ?>">
<?php }?>
</td>
</tr>
<tr>
<td colspan="2">Terbilang : <?php echo jin_num2txt($total); ?> </td>
</tr>
<tr>
<td>Total Bayar </td>
<td><input name="total_bayar" type="text" id="total_bayar" value="<?php echo $total ; ?>"></td>
</tr>
<tr>
<td>Cara Pembayaran</td>
<td><select name="carabayar" id="carabayar">
<option value="Tunai">Tunai </option>
<option value="Check">Check</option>
<option value="Giro">Giro</option>
</select></td>
</tr>
<tr>
<td>No Chek / Giro </td>
<td><input name="nocheckgiro" type="text" id="nocheckgiro"></td>
</tr>
<tr>
<td> </td>
<td><input name="Simpan" type="submit" id="Simpan" value="Simpan">
<input name="Button" type="button" onClick=history.go(-1) value="Batal"></td>
</tr>
</table>
</form>
<script type="text/javascript">
Calendar.setup({
inputField : "f_date_b", // id of the input field
ifFormat : "%d-%m-%Y", // format of the input field
showsTime : true, // will display a time selector
button : "f_trigger_b", // trigger for the calendar (button ID
singleClick : false, // double-click mode
step : 1 // show all years in drop-down boxes (instead of every other year as default)
});
</script>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
// disini proses rekam disimpan dalam file terpisah rekam.php
<?php
$hostname_conn = "";
$database_conn = "namadatabase";
$username_conn = "password";
$password_conn = "";
$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<?php
mysql_select_db($database_conn, $conn);
if(isset($_GET['no_kwitansi']))
{
$no_kwitansi=$_GET['no_kwitansi'];$tgl_bayar=$_GET['date_in'];$no_reg_konter=$_GET['no_reg_konter'];
$nilai_bayar=$_GET['total_bayar']; $carabayar=$_GET['carabayar'];$nocheckgiro=$_GET['nocheckgiro'];
$nextNo=$_GET['nextNo']; $afaktur=$_GET['afaktur'];
$sqlt= "INSERT INTO kwitansimaster( no_urut,no_kwitansi,no_reg_konter,tgl_bayar, nilai_bayar,carabayar,nochekgiro) VALUES ('"."','".$no_kwitansi."','".$no_reg_konter."','".$tgl_bayar."','".$nilai_bayar."','".$carabayar."','".$nocheckgiro."')";
$result1=mysql_query($sqlt, $conn) or die(mysql_error());
}
$sqlkw= "INSERT INTO nokw(no, keterangan) VALUES ('"."','".$nextNo."')";
"BEGINS";
"LOCK TABLES notk WRITE" ;
$Resultkw = mysql_query($sqlkw, $conn) or die(mysql_error());
"COMMITS";
"UNLOCK TABLES";
$N = count($afaktur);
$total= 0;
for($i=0; $i < $N; $i++)
{
// echo("Anda memilih $i no Faktur: ") apdet no faktur dan tandai sebagai faktur lunas;
$nofak=$afaktur[$i];
$sql = "SELECT * FROM jualmaster WHERE no_faktur='".$nofak."'";
$kueri=mysql_query($sql);
$found = mysql_num_rows($kueri); $lunas="Lunas";
if ($found > 0)
{
$sqlupdet = "UPDATE jualmaster SET lunas ='".$lunas."'";
mysql_select_db($database_conn, $conn);
$hasil = mysql_query($sqlupdet, $conn) or die(mysql_error());
}
else
{echo "No faktur tidak ditemukan ".$nofak."-".$N ;}
}
mysql_close($conn);
header("Location:kw.php")
?>
Komentar
Posting Komentar
Nuhun sudah komentar