<?php
include "../../inc/inc.koneksi.php";

$kode = $_POST['kode'];
$text	= "SELECT max(id_bbk) as no_akhir FROM jurbk WHERE kode_bk='$kode' ORDER BY kode_bk";
$sql 	= mysql_query($text);
$row	= mysql_num_rows($sql);

if ($row>0){
	$data=mysql_fetch_array($sql);
	$no = $data['no_akhir'];	
	$no_akhir = (int) substr($no,12,3);
	$no_akhir++;
	$idbbk = $kode.sprintf("%03s",$no_akhir);
	$data['nomor'] = $idbbk;
	echo json_encode($data);
}else{
	$data['nomor'] = $kode.'001';
	echo json_encode($data);
}
?>