
<div class="modal fade" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="role-mode" id="payForAccruedExpense" aria-hidden="true">
    <div class="modal-dialog half-width">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myModalLabel"><?php print CommonLanguage::getMessage('pay_accured_expense'); ?></h4>
                <br>
            </div>
            <div class="modal-body">
                <div class="row form-group">
                    <div class="col-md-12 m-b-10" >
                        <div class="col-md-6 ">
                            <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                            <input id="Pay_Acrrued_End_Date" name="Pay_Acrrued_End_Date" class="form-control" value="<?php echo ($today); ?>" />
                        </div>
                          <div class="col-md-6 ">
<label><?php print CommonLanguage::getMessage('Currency'); ?></label>
                            <?php echo Forms::CurrencyDropDown(1, 'complete') ?>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-6 ">
                            <label><?php print CommonLanguage::getMessage('paid_amount'); ?></label>
                                <input type="text" placeholder="<?php print CommonLanguage::getMessage('paid_amount'); ?>" class="form-control Amount isnumber" id="Accrued_Paid_Amount">
                           
                        </div>
                        <div class="col-md-6">
                           <label><?php print CommonLanguage::getMessage('payment_account'); ?></label>
                                <select class="full-width AccountCode" data-init-plugin="select2" id="Real_Payment_Type">
                                    <?php foreach ($payment_types as $payment): ?>
                                        <option value="<?php echo $payment['Account_ID']; ?>"><?php echo $payment['Account_Code'].' - '.$payment['Account_Name']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                           
                        </div>

                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" id="ClosepayAccruedBtn" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button type="submit" class="btn btn-complete " id="payAccruedBtn"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
        </div>
    </div>
</div>
</div>
<script>
    var Required_Fields = <?php echo json_encode(CommonLanguage::getMessage('Required_Fields')); ?>,
            Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>,
            Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>;
    $(function () {

        $("#payAccruedBtn").on("click", function () {
            $("#payAccruedValidationAlert").remove();
            var AlertBox = $('<div id="payAccruedValidationAlert" class="WizardValidationAlert alert"></div>'), IsValidated = true;
            AlertBox.insertAfter($("#payForAccruedExpense").find(".modal-dialog .modal-header").find("h4"))
            $("#PayAcrruedIsBusy").remove();
            $("#payForAccruedExpense").append('<div id="PayAcrruedIsBusy" style="position:absolute;left:0;right:0;top:0px;height:100%;background:rgba(255,255,255,0.9);z-index:9999;opacity:0"><img class="image-responsive-height demo-mw-50" src="img/demo/progress.svg" alt="Progress" style="position: absolute;left: 50%;top: 50%;margin: -25px 0 0 -25px;" /></div>');
            $("#PayAcrruedIsBusy").animate({opacity: 1});
            var DataForm = new FormData();
            var Data = {
                ID: id,
                Real_Amount: $("#Accrued_Paid_Amount").val(),
                Real_Payment_Type: $("#Real_Payment_Type").val(),
                Currency_ID: $("#CurrencyDropDown button input").val(),
                End_Date: $("#Pay_Acrrued_End_Date").val()
            };

            $.each(Data, function (key, value) {
                DataForm.append(key, value);
            })
            $.ajax({
                url: "ACCAjax/payForAccruedExpenseAjax",
                method: "POST",
                data: Data,
                complete: function (v1, v2) {

                    if (v2 == "success" && v1.responseText == 'OK') {
                        $("#PayAcrruedIsBusy").remove();
                        $("#payAccruedValidationAlert").addClass("alert-success").empty().html(Submitted_Successfully);
                        setTimeout(function () {
                            $("#payForAccruedExpense").modal('hide')
                            $("#payAccruedValidationAlert").hide()
                        }, 1500)
                        ChangeTable()

                    } else {
                        $("#payAccruedValidationAlert").addClass("alert-danger").empty().html(Failed_Submit);
                    }
                    $("#PayAcrruedIsBusy").remove();
                }
            })
        });
    });



</script>