<?php
if (smc_session()['user_logged_id'] != 1) { ?>
    <div class="alert alert-danger" role="alert">
        <button class="close" data-dismiss="alert"></button>
        <strong><?php print CommonLanguage::getMessage('danger'); ?>: </strong><?php echo "You Are Not Allowed To Visit This Page"; ?>
    </div>
<?php
    return;
}
// echo $current_expiry_date;
?>

<style type="text/css">
    /*
    .input-group-addon.complete {
    background-color:#4c0870;
    color: #ffffff;
    }
    */
    #OverTimeTable thead tr th {
        color: #555;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    #OverTimeTable tbody tr td input {
        width: 100%;
        margin: 0;
        border: 1px solid rgba(0, 0, 0, 0.02);
        background-color: #e5e5e5;
    }

    #OverTimeTable tbody tr td {
        border: 0;
        padding: 3px 1px;
        position: relative;
    }

    #OverTimeTable tbody tr:first-child td {
        padding-top: 10px;
    }

    #InvoiceDiscountInput {
        display: inline-block;
        width: 40px;
        padding: 3px;
        line-height: 20px;
        background: rgb(250, 250, 250);
        min-height: 12px;
        text-align: center;
        height: 25px;
        font-size: 12px;
        top: -2px;
        position: relative;
        margin: 0 3px;
    }

    #OverTimeTable .Hint {
        position: absolute;
        font-size: 10px;
        font-weight: bold;
        height: 20px;
        line-height: 20px;
        bottom: 2px;
        right: 4px;
        color: rgb(153, 153, 153);
    }

    #OverTimeTable .TotalTD {
        width: auto;
        display: inline-block;
        text-align: center;
        font-size: 20px;
        font-weight: bold;
    }

    #OverTimeTable .Disc {
        width: 50px;
    }

    #OverTimeTable input.wrong {
        border: 1px solid rgba(255, 0, 0, 0.2);
        background: rgba(255, 0, 0, 0.05);
    }

    .DropDownForForms>.dropdown-menu {
        width: 100%;
        height: 200px;
        max-height: 200px;
        overflow-y: scroll;
    }

    .DropDownForForms>.dropdown-menu {
        height: auto;
        cursor: pointer;
        overflow-y: auto;
    }

    .DropDownForForms>button {
        position: relative;
        z-index: 999;
    }

    .DropDownForForms>button>input {
        position: absolute;
        left: 5;
        top: 0;
        width: 90%;
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
        padding: 0;
        border: 0;
        background: transparent;
    }

    .Disabled {
        cursor: default;
        opacity: 0.5;
    }

    #AdvanceValue {
        width: 102px;
        display: inline-block;
    }

    .datepicker thead tr .dow {
        color: #4c0870 !important;
    }

    .datepicker table tr td.day:hover {
        background: #4c0870 !important;
        color: #fff;
    }

    .datepicker table tr td.active {
        background-color: #4c0870 !important;
    }

    .datepicker thead tr .datepicker-switch {
        color: #4c0870 !important;
        font-size: 13px;
    }

    .datepicker table tr td span.active {
        background-color: #4c0870 !important;
    }

    .datepicker table tr td span:hover {
        background-color: #4c0870 !important;
        color: #fff;
    }

    datepicker thead tr .next:before,
    .datepicker thead tr .prev:before {
        color: #4c0870 !important;
        font-family: 'FontAwesome';
        font-size: 10px;
    }

    .datepicker thead tr .next:before,
    .datepicker thead tr .prev:before {
        color: #4c0870 !important;
        font-family: 'FontAwesome';
        font-size: 10px;
    }

    .input-group-addon {
        background-color: #4c0870 !important;
        color: #fff;
    }

    form .row [class*='col-']:first-child {
        padding-left: 7px;
        padding-right: 7px;
    }
</style>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <?php echo Forms::ModalLoader('AddShiftIsBusy') ?>
            <div class="modal-header clearfix text-left">
                <h5><span class="semi-bold"><?php echo CommonLanguage::getMessage("add_update_system_note"); ?> </span></h5>

            </div>
            <div class="modal-body">
                <div id="AddShiftValidationAlert"></div>
                <form id="AddShiftPostForm" method="POST" onsubmit="return false">
                    <div class="row">
                        <div class="col-md-12" style="margin-left:5px;">

                            <div class="col-md-3 form-group">
                                <label><?php echo CommonLanguage::getMessage('select_version'); ?></label>
                                <div class="input-group ">
                                    <input  type="hidden" class="full-width " id="select_version" name="select_version" >
                                </div>
                            </div>

                        </div>
                        <div class="col-md-12" style="margin-left:5px;">

                            <div class="col-md-3 form-group">
                                <label><?php echo CommonLanguage::getMessage('system_version'); ?></label>
                                <div class="input-group ">
                                    <input type="text" id="system_version" name="system_version" class="form-control ">
                                </div>
                            </div>
                            <div class="col-md-6 form-group">
                                <label><?php echo CommonLanguage::getMessage('system_note'); ?></label>
                                <div class="input-group ">
                                    <textarea id="system_note" name="system_note" class="form-control ">

                                    </textarea>
                                </div>
                            </div>
                        </div>

                        <br><br>
                        <div class="col-md-12 " style="margin-left:10px;margin-top:10px">
                            <div class="col-md-4 ">
                                <button class="btn btn-success " id="SubmitNote"> <?php print CommonLanguage::getMessage('Save'); ?> </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    var Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
        Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>,
        Required_Fields = <?php echo json_encode(CommonLanguage::getMessage('Required_Fields')); ?>;
    $(function() {



        build_select2($("#select_version"), "xhr/CommonSearch?col_id=note_id&col_name=system_version&table=tbl_system_note")

        $("#select_version").on("change", function () {
            var select_version=$("#select_version").val();
            if(select_version == ''){
                return ;
            }
            $.ajax({
                url: "SettingsAjax/get_system_version",
                method: "POST",
                data: {select_version:select_version},
                dataType: "JSON",
                complete: function (jqXHR, status) {
                    $("#system_version").val(jqXHR.responseJSON.system_version)
                    $("#system_note").val(jqXHR.responseJSON.system_note)
                }
            });
        });

        $("#SubmitNote").on("click", function() {
            var validate = true;


            $("#AddShiftIsBusy").removeClass('hidden');
            var Data = {
                system_version: $("#system_version").val(),
                system_note: $("#system_note").val(),
                select_version:$("#select_version").val()
            };
            console.log(Data);

            $.ajax({
                url: "SettingsAjax/add_update_system_note",
                method: "POST",
                data: Data,
                complete: function(v1, v2) {
                    if (v2 == 'success') {
                        if (v1.responseText == 'ok') {
                            $("#AddShiftValidationAlert").attr("class", "alert alert-success").empty().html(Submitted_Successfully);

                        } else {
                            $("#AddShiftValidationAlert").attr("class", "alert alert-danger").empty().html(v1.responseText);
                        }
                    } else {
                        $("#AddShiftValidationAlert").attr("class", "alert alert-danger").empty().html(v1.responseText);
                    }
                    $("#AddShiftIsBusy").addClass('hidden');
                }
            });
            
        });
    })
</script>