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

$kode=$_POST['kode'];

$sql = mysql_query("SELECT max(noakun) as no_akhir FROM akun_bb WHERE nogol='$kode' ORDER BY noakun");
$r	 = mysql_fetch_array($sql);
$no  = $r['no_akhir'];

if($no==''){
	$data['nomor']= $kode.'1';
	echo json_encode($data);
}else{
	$nosub	 = substr($no, 0, 3);
	$no_akhir= (int) substr($no, 3, 2);
	$no_akhir++;
	$noakun = $nosub.sprintf("%02s",$no_akhir);
	$data['nomor']= $noakun;
	echo json_encode($data);
}
?>