<div style="display: none;">
    <div id="OrderDeliveryCharge">
        <div class="popup-header toolbar-header">
            <div class="popup-title">Apply Delivery Charge #ref:120</div>
            <div class="popup-close-btn" onclick="zamanEposPopupcloser()"><span class="icon icon-cancel"></span></div>
        </div>
        <div class="popup-content">
            <form id="orderDeliveryChargeForm">
                <div class="neworder-table-guest collection-phone ccfee">
                    <div class="form-group">
                        <input type="text" name="delivery_charge" id="zamanDeliveryChargePrimaryNumpad" class="form-control" placeholder="Delivery Charge">
                    </div>
                    <div class="clearfix"></div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">1</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">2</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">3</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">4</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">5</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">6</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">7</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">8</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">9</div>
                    </div>
                    <div class="tab-group keypad">
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">.</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryNumKey">0</div>
                        <div class="tab-item zaman-epos-nav quantity-digit keypad-key deliveryChargePrimaryActionKey">CLR</div>
                    </div>
                    <div class="tab-group config-submit">
                        <button type="submit" onclick="setOrderDeliveryCharge('orderDeliveryChargeForm')"><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 zamanOrderDeliveryChargeInfoControllerPopup() {
        zamanEposDb.epos_order.get({orderId: Number(zamanEposCart.getEposCurrentId())}).then(function (anOrder) {
            if (typeof (anOrder) !== 'undefined') {
                if (Number(anOrder.isPaid) === 3) {
                    orderPaymentPreProcessor(anOrder);
                } else {
                    if (anOrder.type === 'delivery') {
                        $.colorbox({
                            inline: true,
                            scrolling: false,
                            href: "#OrderDeliveryCharge",
                            width: '290px',
                            maxWidth: "100%",
                            height: 'auto',
                            open: true,
                            closeButton: false,
                            transition: 'none',
                            overlayClose: false,
                            className: 'transparent-overlay',
                            onOpen: function () {
                                playBeepSound();
                                resetForm('orderDeliveryChargeForm');
                                $('#colorbox').colorbox.resize();
                            },
                            onLoad: function () {
                                var deliveryCharge = zamanEposCart.getDeliveryCharge();
                                if (Number(deliveryCharge) > 0) {
                                    $('#zamanDeliveryChargePrimaryNumpad').val(deliveryCharge);
                                } else {
                                    $('#zamanDeliveryChargePrimaryNumpad').val('');
                                }
                            },
                            onComplete: function () {
                            },
                            onCleanup: function () {
                            },
                            onClosed: function () {
                                resetForm('orderDeliveryChargeForm');
                            }
                        });
                    } else {
                        warning('<?php echo $this->lang->line('warning') ?>', '<?php echo $this->lang->line('no_delivery_order') ?>', '<?php echo $this->lang->line('close') ?>');
                    }
                }
            } else {
                warning('<?php echo $this->lang->line('warning') ?>', '<?php echo $this->lang->line('load_order_in_cart') ?>', '<?php echo $this->lang->line('ok') ?>');
            }
        });
    }
    function setOrderDeliveryCharge(formId) {
        $('#' + formId).validate({
            submitHandler: function () {
                var deliveryCharge = $('#zamanDeliveryChargePrimaryNumpad').val();
                zamanEposCart.setDeliveryCharge(deliveryCharge);
                if (zamanEposCart.getDeliveryCharge()) {
                    displayEposCart();
                    zamanEposPopupcloser();
                    postupdateForExtraCharge(zamanEposCart.getEposCurrentId(), 'deliveryCharge', zamanEposCart.cartCalculator().deliveryCharge);
                }
            },
            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: {
                delivery_charge: {number: true, required: true}
            },
            errorPlacement: function (error, element) {
                errorPlacement(error, element);
            }
        });
    }

</script>