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

$stdName =  $_POST['stdname'];
$stdPrefix  =  $_POST['stdprefix'];
$stdCode   =  $_POST['stdcode'];
$stdNotes  = $_POST['stdnotes'];
$date = date('Y-m-d');
$id = $_SESSION['id'];

if (isset($_REQUEST['del'])) {
    $SID = $_REQUEST['del'];
    if (mysql_query("UPDATE scope_std SET `stdStatus`=2 WHERE `stdID` = '$SID'")) {
        header("location: 03-01Scope-01Standards01.php?msg=DELETED");
    } else {
        header("location: 03-01Scope-01Standards01.php?msg=NOT DELETED");
    }
} else if (isset($_REQUEST['Edit'])) {
    $SID = $_REQUEST['Edit'];
    if (mysql_query("UPDATE scope_std SET `stdName`='$stdName',`stdPrefix`='$stdPrefix',`stdCode`='$stdCode',`stdNotes`='$stdNotes' WHERE `stdId` = '$SID'")) {
//        if(mysql_query("UPDATE manual_assignments SET `companyProjects` = '$projectName', `companyClients` = '$clientName' WHERE `ProjectEstimate` = '$BudgetID'"))
        header("location: 03-01Scope-01Standards01.php?msg=UPDATED");
    } else {
        header("location: 03-01Scope-01Standards01.php?msg=NOT UPDATED");
    }
}


else if(isset($_REQUEST['Active'])){
    $bid = $_REQUEST['Active'];
    if(mysql_query("UPDATE scope_std SET stdStatus ='1' WHERE stdId = '$bid'"))
    {
        header("location: 03-01Scope-01Standards01.php?msg=ACTIVE");}

    else
    {
        header("location: 03-01Scope-01Standards01.php?msg=NOT ACTIVE");
    }


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

    $bid = $_REQUEST['InActive'];
    if(mysql_query("UPDATE scope_std SET stdStatus ='0' WHERE stdId = '$bid'"))
    {
        header("location: 03-01Scope-01Standards01.php?msg=HIDDEN");}

    else
    {
        header("location: 03-01Scope-01Standards01.php?msg=NOT HIDDEN");
    }

}

else {


    if (mysql_query("INSERT INTO scope_std SET `stdName`='$stdName',`stdPrefix`='$stdPrefix',`stdCode`='$stdCode',`stdDateCreated`='$date',`stdNotes`='$stdNotes',`stdCompany`='$id'")) {


        header("location: 03-01Scope-01Standards01.php?msg=SAVED");
    } else {
        header("location: 03-01Scope-01Standards01.php?msg=NOT SAVED");
    }
}

?>