<?php 
session_start();
$iduser=$_SESSION['user_idd'];
$date = new DateTime("now", new DateTimeZone('Africa/Nairobi') );
$timenow=$date->format('Y-m-d H:i:s');
$timenow2=$date->format('Y-m-d');
$month=$date->format('M');
//$finaldate='Today: '.$date->format('l d M Y - H:i:s');
 include('../include/config.php');
 
 if(isset($_POST["tit"]))
 { 
 $tit=addslashes($_POST["tit"]);
 $dat=addslashes($_POST["dat"]);
 $clas=addslashes($_POST["clas"]);
 $tdes=addslashes($_POST["tdes"]);
 $fee=addslashes($_POST["fee"]);

 $yrr=substr($dat, 0, 4);
 $mm=substr($dat, 5, 2);

if($mm=='01'){$mm='January';}
if($mm=='02'){$mm='February';}
if($mm=='03'){$mm='March';}
if($mm=='04'){$mm='April';}
if($mm=='05'){$mm='May';}
if($mm=='06'){$mm='June';}
if($mm=='07'){$mm='July';}
if($mm=='08'){$mm='August';}
if($mm=='09'){$mm='September';}
if($mm=='10'){$mm='October';}
if($mm=='11'){$mm='November';}
if($mm=='12'){$mm='December';}

$sql=mysqli_query($con,"INSERT INTO graduations(Title,Clazz,Dat,Description,EntryDate,Fee) values ('$tit','$clas','$dat','$tdes','$timenow2','$fee')");
if($sql)
{
$msgg='added new Graduation data';
$sql3=mysqli_query($con,"INSERT INTO activity(user,Action,Tim,Dat,shortmsg,Month)values('$iduser','$msgg','$timenow','$timenow2','update','$month')");
if($sql3)
{ } 
echo "success";
}else
{
echo "Error in saving data";
}
 }else if(isset($_POST["did"]))
 {
$id =addslashes($_POST['did']);
$sql=mysqli_query($con,"DELETE from TourPayment where idd='$id'");
if($sql)
{
    $msg='deleted a tour payment entry';
 $sql2=mysqli_query($con,"INSERT INTO activity(user,Action,Tim,Dat,shortmsg,Month) VALUES('$iduser','$msg','$timenow','$timenow2','delete','$month') ");
 if($sql2)
 {
    echo 'success'; 
 }
}else
{
    echo 'Sorry. Error occured while saving data';
}  
 }
?>