<?php
$CURRENT_SECTION = 'tenant';
include '../inc/header.php'; ?>

    <div class="container" style="max-width:500px; margin-top:40px;">
        <div class="card shadow p-4">
            <h4 class="mb-3 text-center">역할 등록</h4>
            <form id="roleAddForm" method="post" action="/tenant/tenant/role_add_process.php" autocomplete="off">
                <div class="mb-3">
                    <label class="form-label">역할명 <span class="text-danger">*</span></label>
                    <input type="text" class="form-control" name="role_name" maxlength="30" required>
                </div>
                <div class="mb-3">
                    <label class="form-label">설명</label>
                    <input type="text" class="form-control" name="role_desc" maxlength="100">
                </div>
                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-primary w-50">등록</button>
                    <a href="/tenant/tenant/role_list.php" class="btn btn-secondary w-50">취소</a>
                </div>
            </form>
        </div>
    </div>

    <script>
        $(function(){
            $('#roleAddForm').on('submit', function(e){
                var name = $('[name="role_name"]').val().trim();
                if (name.length < 2) {
                    alert('역할명을 2글자 이상 입력하세요.');
                    $('[name="role_name"]').focus();
                    e.preventDefault(); return false;
                }
            });
        });
    </script>

<?php include '../inc/footer.php'; ?>
