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

$jttempo = $_POST['jttempo'];
$tanggal = $_POST['tanggal'];

$jt = (int) $jttempo;
$thn= substr($tanggal,0,4);
$bln= substr($tanggal,5,2);
$tgl= substr($tanggal,8,2);
$thn= (int) $thn;
$bln= (int) $bln;
$tgl= (int) $tgl;
$kab= $thn;

while($kab>4){
	$kab=$kab-4;
}
		
if($kab==0) 
	$feb=29; 
else 
	$feb=28;
		
while($jt>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;
		}
	}
	$jt=$jt-1;
}

$tanggaljt = $thn.'-'.sprintf("%02s",$bln).'-'.sprintf("%02s",$tgl);
$data['tanggaljt']= $tanggaljt;
echo json_encode($data);
?>