<?php
include('../includes/con2pma3.php');
if (isset($_SESSION['UserName'])) {
    $project_id = $_POST['projname'];
    $client_id = $_POST['clientname'];
    $briefD_name = $_POST['briefDname'];    
    $briefD_create_from = $_POST['briefDfrom'];
    $briefD_copy_from = $_POST['briefDlist'];
	$PreparedBy = ($_SESSION['user_id']==0) ? $_SESSION['id'] : $_SESSION['user_id'];    
    $date = date('Y-m-d');
    $id = $_SESSION['id'];

    if (isset($_REQUEST['del'])) {

   	$bid = $_REQUEST['del'];
	if(mysql_query("UPDATE briefD SET briefD_status ='2' WHERE briefD_id = '$bid'"))
        {
        header("location: BriefDesign1.php?msg=DELETED");}
        
        else
{
	header("location: BriefDesign1.php?msg=NOT DELETED");
}
    }
    
    if(isset($_REQUEST['Active'])){
	$bid = $_REQUEST['Active'];
	if(mysql_query("UPDATE briefD SET briefD_status ='1' WHERE briefD_id = '$bid'"))
        {
        header("location: BriefDesign1.php?msg=ACTIVE");}
        
        else
{
	header("location: BriefDesign1.php?msg=NOT ACTIVE");
}


}
    else if(isset($_REQUEST['InActive'])){
    
	$bid = $_REQUEST['InActive'];
	if(mysql_query("UPDATE briefD SET briefD_status ='0' WHERE briefD_id = '$bid'"))
        {
        header("location: BriefDesign1.php?msg=HIDDEN");}
        
        else
{
	header("location: BriefDesign1.php?msg=NOT HIDDEN");
}

}
    else if (isset($_REQUEST['Edit'])) {

        $briefDID = $_REQUEST['Edit'];

        if (mysql_query("UPDATE briefD SET `project_id`='$project_id',`client_id`='$client_id',`briefD_name`='$briefD_name',`briefD_create_from`='$briefD_create_from',`briefD_copy_from`='$briefD_copy_from' WHERE `briefD_id` = '$briefDID'")) {

             header("location: BriefDesign1.php?msg=UPDATED");
        } else {
             header("location: BriefDesign1.php?msg=NOT UPDATED");
        }
    } else {
        

        if (mysql_query("insert into briefD SET `project_id`='$project_id',`client_id`='$client_id',`briefD_name`='$briefD_name',`briefD_create_from`='$briefD_create_from',`briefD_copy_from`='$briefD_copy_from',`creationDate`='$date',`CompanyID`='$id', `PreparedBy` = '$PreparedBy', `briefD_status` = '1'")) {
            header("location: BriefDesign1.php?msg=SAVED");
        } else {

            header("location: BriefDesign1.php?msg=NOT SAVED");
        }
    }
} else {
    header("location: ../login.php?msg=YOU ARE NOT LOGINED");
}
?> 