<?php
if (empty($_GET['id'])) {
    header("Location: " . Wo_LoadAdminLinkSettings(''));
    exit();
}
$genders = $db->objectbuilder()->where('id', Secure($_GET['id']))->get('genders', null,array('*'));
?>
<div class="container-fluid">
    <div class="block-header">
        <h2>Users > Edit Country</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="header">
                    <h2>Edit Gender</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success key-settings-alert"></div>
                    <form class="key-settings" method="POST">
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="gender" name="gender" class="form-control" value="<?php echo $genders[0]->name;?>">
                                <label class="form-label">Gender title</label>
                            </div>
                        </div>
                        <input type="hidden" name="id" value="<?php echo $genders[0]->id;?>">
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Edit Gender</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
    <script>

        $(function() {

            var form_key_settings = $('form.key-settings');
                form_key_settings.ajaxForm({
                    url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=edit_gender&p=manage-genders',
                    beforeSend: function() {
                        form_key_settings.find('button').text('Please wait..');
                    },
                    success: function(data) {
                        if (data.status == 200) {
                            $("html, body").animate({ scrollTop: 0 }, "slow");
                            $('.key-settings-alert').html('<i class="fa fa-check"></i> Gender successfully edited');
                            setTimeout(function () {
                                window.location.href = data.url;
                            }, 1000);
                        } else {
                            alert(data.message);
                        }
                        form_key_settings.find('button').text('Add Gender');
                    }
                });
        });
    </script>