<?php
include('../includes/con2pma3.php');

if (isset($_SESSION['UserName'])) {
 
$sowName =  $_POST['SOWname'];            
$sowFrom  =  $_POST['SOWfrom'];       
$sowType   =  $_POST['brieftype'];        
$sowClient  = $_POST['clientName'];
$sowProject =  $_POST['projectName'];
$PreparedBy = ($_SESSION['user_id']==0) ? $_SESSION['id'] : $_SESSION['user_id'];  
$date = date('Y-m-d');
$id = $_SESSION['id'];


    if (isset($_REQUEST['del'])) {
        $SID = $_REQUEST['del'];
        if (mysql_query("UPDATE scope_sow SET `sowStatus`=2 WHERE `sowID` = '$SID'")) {
            header("location: SOW1.php?msg=DELETED");
        } else {
            header("location: SOW1.php?msg=NOT DELETED");
        }
    } else if (isset($_REQUEST['Active'])) {
        $SID = $_REQUEST['Active'];
        if (mysql_query("UPDATE scope_sow SET `sowStatus`=1 WHERE `sowID` = '$SID'")) {
            header("location: SOW1.php?msg=ACTIVED");
        } else {
            header("location: SOW1.php?msg=NOT ACTIVED");
        }
    } else if (isset($_REQUEST['InActive'])) {
       $SID = $_REQUEST['InActive'];
        if (mysql_query("UPDATE scope_sow SET `sowStatus`=0 WHERE `sowID` = '$SID'")) {
            header("location: SOW1.php?msg=HIDDEN");
        } else {
            header("location: SOW1.php?msg=NOT HIDDEN");
        }
    } else if (isset($_REQUEST['Edit'])) {
        $SID = $_REQUEST['Edit'];
        if (mysql_query("UPDATE scope_sow SET `sowType`='$sowType',`sowFrom`='$sowFrom',`sowName`='$sowName',`sowClient`='$sowClient',`sowProject`='$sowProject' WHERE `sowID` = '$SID'")) {
//        if(mysql_query("UPDATE manual_assignments SET `companyProjects` = '$projectName', `companyClients` = '$clientName' WHERE `ProjectEstimate` = '$BudgetID'"))
            header("location: SOW1.php?msg=UPDATED");
        } else {
            header("location: SOW1.php?msg=NOT UPDATED");
        }
    } else {
        

        if (mysql_query("INSERT INTO scope_sow SET `sowType`='$sowType',`sowFrom`='$sowFrom',`sowCompany`='$id',`sowDateCreated`='$date',`sowName`='$sowName',`sowClient`='$sowClient',`sowProject`='$sowProject', `sowPreparedBy` = '$PreparedBy', `sowStatus` = '1'")) {
            
     
            header("location: SOW1.php?msg=SAVED");
        } else {
            header("location: SOW1.php?msg=NOT SAVED");
        }
    }
} else {
    header("location: ../index.php?msg=YOU ARE NOT LOGINED");
}
?> 