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

$tanggal= $_POST['tanggal'];
$bk		= $_POST['bataskr'];

$thn	= substr($tanggal,0,4);
$bln	= substr($tanggal,5,2);
$tgl	= substr($tanggal,8,2);
$bln1= $bln;
$hari	= $tgl;
$thn	= (int) $thn;
$bln	= (int) $bln;
$tgl	= (int) $tgl;
$thn1= $thn-2000;

$kab = $thn;

while($kab>4){
	$kab=$kab-4;
}
		
if($kab==0) 
	$feb=29; 
else 	
	$feb=28;
		
while($bk>0){
	$tgl=$tgl+1;
			
	if($bln==1){
		if($tgl==32){
			 $bln=$bln+1;
			 $tgl = 1;
		}
	}else if($bln==2){
		if($feb==29){
			if($tgl==30){
				 $bln=$bln+1;
				 $tgl=1;
			}
		}else{
			if($tgl==29){
				 $bln=$bln+1;
				 $tgl=1;
			}
		}
	}else if($bln==3){
		if($tgl==32){
			 $bln=$bln+1;
			 $tgl = 1;
		}
	}else if($bln==4){
		if($tgl==31){
			 $bln=$bln+1;
			 $tgl = 1;
		}
	}else if($bln==5){
		if($tgl==32){
			$bln=$bln+1;
			$tgl = 1;
		}
	}else if($bln==6){
		if($tgl==31){
			$bln=$bln+1;
			$tgl = 1;
		}
	}else if($bln==7){
		if($tgl==32){
			$bln=$bln+1;
			$tgl = 1;
		}
	}else if($bln==8){
		if($tgl==32){
			$bln=$bln+1;
			$tgl = 1;
		}
	}else if($bln==9){
		if($tgl==31){
			$bln=$bln+1;
			$tgl = 1;
		}
	}else if($bln==10){
		if($tgl==32){
			$bln=$bln+1;
			$tgl = 1;
		}
	}else if($bln==11){
		if($tgl==31){
			$bln=$bln+1;
			$tgl = 1;
		}
	}else if($bln==12){
		if($tgl==32){
			$bln=1;
			$thn=$thn+1;
			$tgl = 1;
		}
	}
	$bk=$bk-1;
}
$data['tanggalbk']= $thn.'-'.sprintf("%02s",$bln).'-'.sprintf("%02s",$tgl);
echo json_encode($data);
?>