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

if (isset($_SESSION['UserName'])) {           
$dwgcomplePercent  =  $_POST['complevel2'];       
$dwgType   =  $_POST['designtype'];        
$dwgNotes  = $_POST['dwglistingnotes'];
$dwgProject =  $_POST['projname']; 
$date = date('Y-m-d');
$id = $_SESSION['id'];


    if (isset($_REQUEST['del'])) {
        $dwgID = $_REQUEST['del'];
        if (mysql_query("UPDATE scope_dwg SET `dwgStatus`=2 WHERE `dwgID` = '$dwgID'")) {
            header("location: DWG1.php?msg=DELETED");
        } else {
            header("location: DWG1.php?msg=NOT DELETED");
        }
    } else if (isset($_REQUEST['Active'])) {
        $dwgID = $_REQUEST['Active'];
        if (mysql_query("UPDATE scope_dwg SET `dwgStatus`=1 WHERE `dwgID` = '$dwgID'")) {
            header("location: DWG1.php?msg=ACTIVED");
        } else {
            header("location: DWG1.php?msg=NOT ACTIVED");
        }
    } else if (isset($_REQUEST['InActive'])) {
       $dwgID = $_REQUEST['InActive'];
        if (mysql_query("UPDATE scope_dwg SET `dwgStatus`=0 WHERE `dwgID` = '$dwgID'")) {
            header("location: DWG1.php?msg=HIDDEN");
        } else {
            header("location: DWG1.php?msg=NOT HIDDEN");
        }
    } else if (isset($_REQUEST['Edit'])) {
        $SID = $_REQUEST['Edit'];
        if (mysql_query("UPDATE scope_dwg SET `dwgProject`='$dwgProject',`dwgcomplePercent`='$dwgcomplePercent',`dwgType`='$dwgType',`dwgNotes`='$dwgNotes' WHERE `dwgID` = '$SID'")) {
            header("location: DWG1.php?msg=UPDATED");
        } else {
            header("location: DWG1.php?msg=NOT UPDATED");
        }
    } else {
        

        if (mysql_query("INSERT INTO scope_dwg SET `dwgProject`='$dwgProject',`dwgcomplePercent`='$dwgcomplePercent',`dwgType`='$dwgType',`dwgNotes`='$dwgNotes',`dwgCompany`='$id',`dwgDateCreated`='$date', `dwgStatus` = '1'")) {
            
     
            header("location: DWG1.php?msg=SAVED");
        } else {
            header("location: DWG1.php?msg=NOT SAVED");
        }
    }
} else {
    header("location: ../index.php?msg=YOU ARE NOT LOGINED");
}
?> 