<script>
    $(function() {
        $("input[name=reset_cuti]").on("change", function() {
            $("#periode_cuti").val(<?= $pengaturan_cuti->periode_cuti ?: '' ?>);
            if ($(this).val() === "bulan") {
                return $("#form_periode_cuti").slideDown(250);
            }
            $("#form_periode_cuti").slideUp(250);
        });
    });
</script>
<div class="card-body">
    <div class="row">
        <div class="col-md-12">
            <input type="hidden" id="cuti_p" value="<?= ($pengaturan_cuti->id_cuti_p) ?: '' ?>" disabled>
            <label for="reset_cuti"><?= $this->lang->line('pengaturan_cuti_pertanyaan_1') ?> <span class="text-danger">*</span></label>
            <div class="row">
                <div class="col-md-6">
                    <input type="radio" name="reset_cuti" value="join_date" id="reset_cuti_join_date" <?= ($pengaturan_cuti->reset_jenis == 'join_date') ? 'checked=true' : '' ?> <?= ($pengaturan_cuti->reset_jenis) ? 'disabled' : '' ?>>
                    <label for="reset_cuti_join_date">Join Date</label>
                </div>
                <div class="col-md-6">
                    <input type="radio" name="reset_cuti" value="bulan" id="reset_cuti_bulan" <?= ($pengaturan_cuti->reset_jenis == 'bulan') ? 'checked=true' : '' ?> <?= ($pengaturan_cuti->reset_jenis) ? 'disabled' : '' ?>>
                    <label for="reset_cuti_bulan"><?= $this->lang->line('pengaturan_cuti_bulan') ?></label>
                </div>
            </div>
        </div>
    </div>
    <div class="row mt-2" id="form_periode_cuti" <?= ($pengaturan_cuti->reset_jenis == 'bulan') ? '' : 'style="display: none;"' ?>>
        <div class="col-md-12">
            <label for="periode_cuti"><?= $this->lang->line('pengaturan_cuti_pertanyaan_2')?> <span class="text-danger">*</span></label>
            <select name="periode_cuti" id="periode_cuti" class="form-control" <?= ($pengaturan_cuti->periode_cuti) ? 'disabled' : '' ?>>
                <option value="1" <?= ($pengaturan_cuti->periode_cuti == '1') ? 'selected' : '' ?>><?= $this->lang->line('januari') ?></option>
                <option value="2" <?= ($pengaturan_cuti->periode_cuti == '2') ? 'selected' : '' ?>><?= $this->lang->line('februari') ?></option>
                <option value="3" <?= ($pengaturan_cuti->periode_cuti == '3') ? 'selected' : '' ?>><?= $this->lang->line('maret') ?></option>
                <option value="4" <?= ($pengaturan_cuti->periode_cuti == '4') ? 'selected' : '' ?>><?= $this->lang->line('april') ?></option>
                <option value="5" <?= ($pengaturan_cuti->periode_cuti == '5') ? 'selected' : '' ?>><?= $this->lang->line('mei') ?></option>
                <option value="6" <?= ($pengaturan_cuti->periode_cuti == '6') ? 'selected' : '' ?>><?= $this->lang->line('juni') ?></option>
                <option value="7" <?= ($pengaturan_cuti->periode_cuti == '7') ? 'selected' : '' ?>><?= $this->lang->line('juli') ?></option>
                <option value="8" <?= ($pengaturan_cuti->periode_cuti == '8') ? 'selected' : '' ?>><?= $this->lang->line('agustus') ?></option>
                <option value="9" <?= ($pengaturan_cuti->periode_cuti == '9') ? 'selected' : '' ?>><?= $this->lang->line('september') ?></option>
                <option value="10" <?= ($pengaturan_cuti->periode_cuti == '10') ? 'selected' : '' ?>><?= $this->lang->line('oktober') ?></option>
                <option value="11" <?= ($pengaturan_cuti->periode_cuti == '11') ? 'selected' : '' ?>><?= $this->lang->line('november') ?></option>
                <option value="12" <?= ($pengaturan_cuti->periode_cuti == '12') ? 'selected' : '' ?>><?= $this->lang->line('desember') ?></option>
            </select>
        </div>
    </div>
    <div class="row mt-2">
        <div class="col-md-12">
            <label for="reset_saldo"><?= $this->lang->line('pengaturan_cuti_reset') ?> <span class="text-danger">*</span></label>
            <input type="number" class="form-control" id="reset_saldo" min="0" value="<?= ($pengaturan_cuti->reset_saldo) ?: '' ?>" <?= ($pengaturan_cuti->reset_saldo) ? 'disabled' : '' ?>>
        </div>
    </div>
    <div class="row mt-2">
        <div class="col-md-12">
            <label><?= $this->lang->line('pengaturan_cuti_pertanyaan_3') ?> <span class="text-danger">*</span></label>
            <div class="row">
                <div class="col-md-6">
                    <input type="checkbox" name="jenis_karyawan" value="2" id="jenis_karyawan_tetap" <?= ($pengaturan_cuti->jenis_karyawan == '2') ? 'checked=true' : '' ?> <?= ($pengaturan_cuti->jenis_karyawan) ? 'disabled' : '' ?>>
                    <label for="jenis_karyawan_tetap"><?= $this->lang->line('tetap')?></label>
                </div>
                <div class="col-md-6">
                    <input type="checkbox" name="jenis_karyawan" value="1" id="jenis_karyawan_kontrak" <?= ($pengaturan_cuti->jenis_karyawan == '1') ? 'checked=true' : '' ?> <?= ($pengaturan_cuti->jenis_karyawan) ? 'disabled' : '' ?>>
                    <label for="jenis_karyawan_kontrak"><?= $this->lang->line('kontrak')?></label>
                </div>
            </div>
        </div>
    </div>
    <div class="row mt-2">
        <div class="col-md-12">
            <label for="join_date_bulan"><?= $this->lang->line('pengaturan_cuti_pertanyaan_4') ?> <span class="text-danger">*</span></label>
            <input type="number" class="form-control" id="join_date_bulan" value="<?= ($pengaturan_cuti->join_date_bulan) ?: '' ?>" <?= ($pengaturan_cuti->join_date_bulan) ? 'disabled' : '' ?>>
        </div>
    </div>
    <div class="row mt-2">
        <div class="col-md-12">
            <label for="carry_forward_maks_saldo"><?= $this->lang->line('pengaturan_cuti_pertanyaan_5') ?> <span class="text-danger">*</span></label>
            <input type="text" name="carry_forward_maks_saldo" id="carry_forward_maks_saldo" class="form-control" value="<?= ($pengaturan_cuti->carry_forward_maks_saldo) ?: '0' ?>" <?= ($pengaturan_cuti->carry_forward_maks_saldo != '') ? 'disabled' : '' ?>>
        </div>
    </div>
    <div class="row mt-2">
        <div class="col-md-12">
            <label for="carry_forward_maks_bulan"><?= $this->lang->line('pengaturan_cuti_pertanyaan_6') ?> <span class="text-danger">*</span></label>
            <input type="number" name="carry_forward_maks_bulan" id="carry_forward_maks_bulan" class="form-control" min="0" max="12" oninput="enforceMinMax(this)" value="<?= ($pengaturan_cuti->carry_forward_maks_bulan) ?: '0' ?>" <?= ($pengaturan_cuti->carry_forward_maks_bulan != '') ? 'disabled' : '' ?>>
        </div>
    </div>
</div>
<div class="card-footer card-footer-rounded">
    <button class="btn_batal_cuti btn btn-secondary" style="display:none"><i class="fa fa-close"> </i> <?= $this->lang->line('button_form_batal') ?></button>
    <button class="btn_save_cuti btn btn-primary ladda-button" <?= (isset($pengaturan_cuti)) ? 'style="display:none"' : '' ?> data-style="expand-left" for-data="<?= (isset($pengaturan_cuti)) ? 'update' : 'store' ?>"><i class="fa fa-save "> </i> <?= $this->lang->line('button_form_simpan') ?></button>
    <button class="btn_edit_cuti btn btn-warning" <?= (!isset($pengaturan_cuti)) ? 'style="display:none"' : '' ?>><i class="fa fa-edit (alias) "> </i> EDIT</button>
    <label id="message"></label>
</div>
