header("Location: ../index.php?view=list-cat-product&stt=success");
                } else {
                    header("Location: ../index.php?view=list-cat-product&stt=fail");
                }
            }
            break;
        case "xoa":
            $id = $_POST['id'];
            $cat_obj = new category_product();
            if ($cat_obj->delCat($id)) {
                header("Location: ../index.php?view=list-cat-product&stt=success");
            } else {
                header("Location: ../index.php?view=list-cat-product&stt=fail");
            }
            break;
        default:
            if (isset($_POST['cat_name']) && isset($_POST['position']) && isset($_POST['parent_id'])) {
                $cat_obj = new category_product();
                $cat = $_POST['cat_name'];
                $position = $_POST['position'];
                $parent_id = $_POST['parent_id'];
                $home = isset($_POST['home']) ? $_POST['home'] : '';
                if ($cat_obj->insertCat($cat, $parent_id, $position, $home)) {
                    header("Location: ../index.php?view=form-cat-product&stt=success");
                } else {
                    header("Location: ../index.php?view=form-cat-product&stt=fail");
                }
            }
            break;
    }
}