<?
include_once("./_common.php");

if ($is_admin != "super")
    alert("최고관리자만 접근 가능합니다.");

switch ($_GET[szMode])
{
# 등록
case "INSERT":

    $nNowDate = time();
    $szStart  = mktime(0,0,1, substr($_POST[szStart],4,2), substr($_POST[szStart],6,2), substr($_POST[szStart],0,4));
    $szEnd    = mktime(23,59,59,substr($_POST[szEnd],4,2),substr($_POST[szEnd],6,2),substr($_POST[szEnd],0,4));

    if ($szStart > $szEnd)
    {
        alert("종료일이 시작일보다 빠릅니다."); 
    }

    $sql_common = " 
                nStartDate  = '$szStart',
                nEndDate    = '$szEnd',
                nWidth      = '$_POST[nWidth]',
                nHeight     = '$_POST[nHeight]',
                nLeft       = '$_POST[nLeft]',
                nRight      = '$_POST[nRight]',
                nOptions    = '$_POST[nOptions]',
                szSubject   = '$_POST[szSubject]',
                szMemo      = '$_POST[szMemo]',
                szView      = '$_POST[szView]',
                nDate       = '$nNowDate'
                ";

    $sql = " INSERT INTO $g4[popup_table] SET $sql_common ";

    sql_query($sql);
    goto_url("./category_list.php?url=popup_list");

    break;


case "MODIFY" :

    $szStart  = mktime(0,0,1, substr($_POST[szStart],4,2), substr($_POST[szStart],6,2), substr($_POST[szStart],0,4));
    $szEnd    = mktime(23,59,59,substr($_POST[szEnd],4,2),substr($_POST[szEnd],6,2),substr($_POST[szEnd],0,4));

    if ($szStart > $szEnd)
    {
        alert("종료일이 시작일보다 빠릅니다."); 
    }

    $sql_common = " 
                nStartDate  = '$szStart',
                nEndDate    = '$szEnd',
                nWidth      = '$_POST[nWidth]',
                nHeight     = '$_POST[nHeight]',
                nLeft       = '$_POST[nLeft]',
                nRight      = '$_POST[nRight]',
                nOptions    = '$_POST[nOptions]',
                szSubject   = '$_POST[szSubject]',
                szMemo      = '$szMemo',
                szView      = '$_POST[szView]'
                ";

    $sql = " UPDATE $g4[popup_table] SET $sql_common WHERE nIdx='$_GET[no]' ";

    sql_query($sql);
    goto_url("./category_list.php?url=popup_list&page=$_GET[page]");

    break;

case "DELETE" :

    if ($imgurl) {
        @unlink("$g4[path]/data/popup/$_GET[imgurl]");
    }

    sql_query(" DELETE FROM $g4[popup_table] WHERE nIdx='$_GET[no]' ");
    goto_url("./category_list.php?url=popup_list&page=$_GET[page]");

    break;
}

?>