<div style="display: none;">
    <div id="OrderCBfeeContent">
        <div class="popup-header toolbar-header">
            <div class="popup-title"><?php echo $this->lang->line('cbFee') ?></div>
            <div class="popup-close-btn" onclick="zamanEposPopupcloser()"><span class="icon icon-cancel"></span></div>
        </div>
        <div class="popup-content">
            <form id="orderCbFeeForm">
                <div class="neworder-table-guest collection-phone ccfee">
                    <div class="form-group">
                        <input type="text" name="cbFee" id="zamancbFeePrimaryNumpad" class="form-control" placeholder="<?php echo $this->lang->line('cbFee') ?>">
                    </div>
                    <div class="clearfix"></div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">1</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">2</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">3</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">4</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">5</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">6</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">7</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">8</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">9</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">.</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryNumKey">0</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key cbFeePrimaryActionKey">CLR</div>
                    </div>
                    <div class="tab-group config-submit">
                        <button type="submit" onclick="setOrderCbFee('orderCbFeeForm')"><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 zamanOrderCBFeeInfoControllerPopup() {
        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: "#OrderCBfeeContent",
                        width: '290px',
                        height: 'auto',
                        maxWidth: "100%",
                        open: true,
                        closeButton: false,
                        transition: 'none',
                        overlayClose: false,
                        className: 'transparent-overlay',
                        onOpen: function () {
                            playBeepSound();
                        },
                        onLoad: function () {
                            var cbFee = zamanEposCart.getcbFee();
                            if (Number(cbFee) > 0) {
                                $('#zamancbFeePrimaryNumpad').val(cbFee);
                            } else {
                                $('#zamancbFeePrimaryNumpad').val('');
                            }
                        },
                        onComplete: function () {

                        },
                        onCleanup: function () {
                        },
                        onClosed: function () {
                            resetForm('orderCbFeeForm');
                        }
                    });
                }

            } else {
                warning('<?php echo $this->lang->line('warning') ?>', '<?php echo $this->lang->line('load_order_in_cart') ?>', '<?php echo $this->lang->line('ok') ?>');
            }
        });
    }
    function setOrderCbFee(formId) {
        $('#' + formId).validate({
            submitHandler: function () {
                var cbFee = $('#zamancbFeePrimaryNumpad').val();
                console.log(cbFee);
                zamanEposCart.setcbFee(cbFee);
                var currentOrderId = zamanEposCart.getEposCurrentId();
                zamanEposPopupcloser();
                displayEposCart();
                postupdateForExtraCharge(currentOrderId, 'cbFee', zamanEposCart.cartCalculator().cartcbFee);
            },
            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: {
                cbfee: {number: true, required: true}
            },
            errorPlacement: function (error, element) {
                errorPlacement(error, element);
            }
        });
    }
</script>