<?php

/*
 * 등록 저장
 */
include_once './_common.php';
include_once './index.php';

if (!defined('_GNUBOARD_')) {
    exit;
}

if (!$_POST) {
    exit;
}
if (!$parent_idx) {
    echo "부모값이 없음";
    exit;
}
if (!$w) {
    //신규등록    
    $sql = "insert into ask_plugin_indexgroup_child set aic_parent_idx = '{$parent_idx}', aic_status = '{$aic_status}', aic_bo_table = '{$aic_bo_table}', aic_type = '{$aic_type}', aic_tab = '{$aic_tab}', aic_rows = '{$aic_rows}', aic_sort = '{$aic_sort}' ";
    sql_query($sql);
    $idx = sql_insert_id();
} elseif ($w == 'u' && $aic_idx) {
    //수정
    $sql = "update ask_plugin_indexgroup_child set aic_parent_idx = '{$parent_idx}', aic_status = '{$aic_status}', aic_bo_table = '{$aic_bo_table}', aic_type = '{$aic_type}', aic_rows = '{$aic_rows}', aic_sort = '{$aic_sort}' where aic_idx = '{$aic_idx}' limit 1 ";
    sql_query($sql);
    $idx = $aic_idx;
}
if ($popup == 1) {
    echo "<script>window.opener.location.reload();alert('수정되었습니다. 새로고침합니다.');window.close();</script>";
} else {
    goto_url('./indexgroup_child_tab_add.php?w=u&idx=' . $idx);
}