<?php
include('../includes/con2pma3.php');
if (isset($_SESSION['UserName'])) {
    $project_id = $_POST['projname'];
    $client_id = $_POST['clientname'];
    $briefC_name = $_POST['briefCname'];    
    $briefC_create_from = $_POST['briefCfrom'];
    $briefC_copy_from = $_POST['briefClist'];
	$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 briefC SET briefC_status ='2' WHERE briefC_id = '$bid'"))
        {
        header("location: BriefClient1.php?msg=DELETED");}
        
        else
{
	header("location: BriefClient1.php?msg=NOT DELETED");
}
    }
    
    if(isset($_REQUEST['Active'])){
	$bid = $_REQUEST['Active'];
	if(mysql_query("UPDATE briefC SET briefC_status ='1' WHERE briefC_id = '$bid'"))
        {
        header("location: BriefClient1.php?msg=ACTIVE");}
        
        else
{
	header("location: BriefClient1.php?msg=NOT ACTIVE");
}


}
    else if(isset($_REQUEST['InActive'])){
    
	$bid = $_REQUEST['InActive'];
	if(mysql_query("UPDATE briefC SET briefC_status ='0' WHERE briefC_id = '$bid'"))
        {
        header("location: BriefClient1.php?msg=HIDDEN");}
        
        else
{
	header("location: BriefClient1.php?msg=NOT HIDDEN");
}

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

        $briefCID = $_REQUEST['Edit'];

        if (mysql_query("UPDATE briefC SET `project_id`='$project_id',`client_id`='$client_id',`briefC_name`='$briefC_name',`briefC_create_from`='$briefC_create_from',`briefC_copy_from`='$briefC_copy_from' WHERE `briefC_id` = '$briefCID'")) {

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

        if (mysql_query("insert into briefC SET `project_id`='$project_id',`client_id`='$client_id',`briefC_name`='$briefC_name',`briefC_create_from`='$briefC_create_from',`briefC_copy_from`='$briefC_copy_from',`creationDate`='$date',`CompanyID`='$id', `PreparedBy` = '$PreparedBy', `briefC_status` = '1'")) {
            header("location: BriefClient1.php?msg=SAVED");
        } else {

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