<?php
$sql="select `kode_paket` from `$tbpaket` order by `kode_paket` desc";
$q=mysqli_query($conn, $sql);
$jum=mysqli_num_rows($q);
$kd="PKT";
if($jum > 0){
$d=mysqli_fetch_array($q);
$idmax=$d["kode_paket"];
$urut=substr($idmax,3,2)+1;//01
if($urut<10){$idmax="$kd"."0".$urut;}
else{$idmax="$kd".$urut;}
}
else{$idmax="$kd"."01";}
$kode_paket=$idmax;
?>
<?php
$sql="select `kode_customer` from `$tbcustomer` order by `kode_customer` desc";
$q=mysqli_query($conn, $sql);
$jum=mysqli_num_rows($q);
$th=date("y");
$bl=date("m")+0;if($bl<10){$bl="0".$bl;}
$kd="CUS".$th.$bl;//KEG1610001
if($jum > 0){
$d=mysqli_fetch_array($q);
$idmax=$d["kode_customer"];
$bul=substr($idmax,5,2);
$tah=substr($idmax,3,2);
if($bul==$bl && $tah==$th){
$urut=substr($idmax,7,3)+1;
if($urut<10){$idmax="$kd"."00".$urut;}
else if($urut<100){$idmax="$kd"."0".$urut;}
else{$idmax="$kd".$urut;}
}//==
else{
$idmax="$kd"."001";
}
}//jum>0
else{$idmax="$kd"."001";}
$kode_customer=$idmax;
?>
Tidak ada komentar:
Posting Komentar