<div style="display: none;">
    <div id="OrderCCfeeContent">
        <div class="popup-header toolbar-header">
            <div class="popup-title"><?php echo $this->lang->line('ref') ?>:<span id="orderccFeeReferenceHolder"></span></div>
            <div class="popup-close-btn" onclick="zamanEposPopupcloser()"><span class="icon icon-cancel"></span></div>
        </div>
        <div class="popup-content">
            <form id="orderCcFeeForm">
                <div class="neworder-table-guest collection-phone ccfee">
                    <div class="form-group">
                        <input type="text" name="ccfee" id="zamanccFeePrimaryNumpad" class="form-control" placeholder="ccFee">
                    </div>
                    <div class="clearfix"></div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">1</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">2</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">3</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">4</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">5</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">6</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">7</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">8</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">9</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">0</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryNumKey">.</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key ccFeePrimaryActionKey">CLR</div>
                    </div>
                    <div class="tab-group config-submit">
                        <button type="submit" onclick="setOrderccFee('orderCcFeeForm')"><span class="icon icon-folder"></span>&nbsp;<?php echo $this->lang->line('add') ?></button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    function zamanOrderCCFeeInfoControllerPopup() {
        zamanEposDb.epos_order.get({orderId: Number(zamanEposCart.getEposCurrentId())}).then(function (anOrder) {
            if (typeof (anOrder) !== 'undefined') {
                if (Number(anOrder.isPaid) === 3) {
                    orderPaymentPreProcessor(anOrder);
                } else {
                    $.colorbox({
                        inline: true,
                        scrolling: false,
                        href: "#OrderCCfeeContent",
                        width: '290px',
                        height: 'auto',
                        maxWidth: "100%",
                        open: true,
                        closeButton: false,
                        transition: 'none',
                        overlayClose: false,
                        className: 'transparent-overlay',
                        onOpen: function () {
                            playBeepSound();
                        },
                        onLoad: function () {
                            var ccFee = zamanEposCart.getccFee();
                            if (Number(ccFee > 0)) {
                                $('#zamanccFeePrimaryNumpad').val(ccFee);
                            } else {
                                $('#zamanccFeePrimaryNumpad').val('');
                            }
                        },
                        onComplete: function () {
                            $('#orderccFeeReferenceHolder').text(anOrder.orderId + '/' + anOrder.sid);
                        },
                        onCleanup: function () {
                        },
                        onClosed: function () {
                            resetForm('orderCcFeeForm');
                        }
                    });
                }
            } else {
                warning('<?php echo $this->lang->line('warning') ?>', '<?php echo $this->lang->line('load_order_in_cart') ?>', '<?php echo $this->lang->line('ok') ?>');
            }
        });
    }
    function setOrderccFee(formId) {
        $('#' + formId).validate({
            submitHandler: function () {
                var ccFee = $('#zamanccFeePrimaryNumpad').val();
                zamanEposCart.setccFee(ccFee);
                var currentOrderId = zamanEposCart.getEposCurrentId();
                if (zamanEposCart.getccFee(currentOrderId)) {
                    displayEposCart();
                    zamanEposPopupcloser();
                    postupdateForExtraCharge(currentOrderId, 'ccFee', zamanEposCart.cartCalculator().cartccFee);
                }
            },
            errorClass: "has-error",
            highlight: function (e) {
                $(e).closest('.form-group').addClass('has-error');
                $.colorbox.resize();
            },
            unhighlight: function (e) {
                $(e).closest('.form-group').removeClass('has-error');
                $.colorbox.resize();
            },
            rules: {
                ccfee: {number: true, required: true}
            },
            errorPlacement: function (error, element) {
                errorPlacement(error, element);
            }
        });
    }

</script>