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

$kode		= $_POST[kode];
$sql 		= mysql_query("SELECT max(kode_ak) as no_akhir FROM aktiva WHERE kode_bb='$kode' ORDER BY kode_ak");
$row		= mysql_num_rows($sql);
if ($row>0){
	$data	= mysql_fetch_assoc($sql);
	$no 		= $data['no_akhir'];
	$no_akhir = (int) substr($no, 5, 4);
	$no_akhir++;
	$data['nomor']	= $kode.sprintf("%04s",$no_akhir);
	echo json_encode($data);
}else{
	$data['nomor']	= $kode.'0001';
	echo json_encode($data);
}
?>