<?php
include('../headertop.php');
include('../db.php');
//include('../datepicker.php');

$disp = '';
$pagetitle = 'Delete Project';

date_default_timezone_set('Asia/Kolkata');

if(!isset($_REQUEST['id']))
{
echo '<meta http-equiv="refresh" content="0;URL=viewprojects.php?sm=Select a project first to delete it">';
exit;
}

$id = $_REQUEST['id'];
$type = $_REQUEST['type'];

$q = "delete from project where id='$id'";

mysqli_autocommit($dbcon, false);
mysqli_query($dbcon,$q) or die(mysqli_error($dbcon));

if($type=='ct')
{
$q2 = "delete from expenses where project='$id'";
$q3 = "delete from estimates where project_id='$id'";

mysqli_query($dbcon,$q2) or die(mysqli_error($dbcon));
mysqli_query($dbcon,$q3) or die(mysqli_error($dbcon));

mysqli_commit($dbcon);
$sm = "Project and its estimation & expenses data deleted ";
echo '<meta http-equiv="refresh" content="0;URL=viewprojects.php?sm='.$sm.'">';
}
elseif($type=='mt')
{

mysqli_commit($dbcon);
$sm = "Project and its estimation & expenses data deleted ";
echo '<meta http-equiv="refresh" content="0;URL=viewprojects.php?sm='.$sm.'">';
}





