<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 right-item">
    <div class="tablebackgroundbg">
        <?php
        $total = 0;
        $foodDbcartTotal = 0;
        $foodTotal = 0;
        $nonFoodTotal = 0;
        $nonFoodDbcartTotal = 0;
        $order_id = isset($order_id) ? $order_id : $this->uri->segment(4);
        $preTotal = $currentOrderObj->grand_total;
        ?>
        <table class="table table-responsive item-table-header cart-table">
            <tr>
                <th class="text-uppercase text-center" style="width: 60%;"><?php echo $this->lang->line('gkpos_item') ?></th>
                <th class="text-uppercase text-center" style="width: 15%;"><?php echo $this->lang->line('gkpos_qnt') ?></td>
                <th class="text-uppercase text-center" style="width: 25%;"><?php echo $this->lang->line('gkpos_price') ?></th>
            </tr>
        </table>
        <div class="item-table item-table-1">
            <table class="table table-bordered table-responsive cart-table" id="foodCart">
                <?php if (!$isFoodCartEmpty): ?>
                    <?php $foodCart = array_reverse($foodCart, true) ?>
                    <?php foreach ($foodCart as $cart): ?>
                        <tr onclick="selectRow('<?php isset($cart['line']) ? print $cart['line'] : print '0' ?>', '<?php echo $cart['order_id'] ?>')" class="line line-<?php isset($cart['line']) ? print $cart['line'] : print '0' ?>">
                            <td style="width: 60%;" class="text-left text-capitalize line line-<?php echo $cart['line'] ?>">
                                <?php
                                $currentCartItemsString = isset($cart['selection_title']) && $cart['selection_title'] != null ? $cart['selection_title'] . '-' . $cart['menu_title'] : $cart['menu_title'];
                                $currentCartItemsString .= $cart['set_items'] != null ? '<br/> <i><strong style="font-size:11px">Items : </strong><span style="font-size:11px;">' . $cart['set_items'] . '</span></i>' : '';
                                $currentCartItemsString .= $cart['toppings'] != null ? '<br/> <i><strong style="font-size:10px; text-transform: uppercase;">T/S : </strong><span style="font-size:10px;">' . $cart['toppings'] . '</span></i>' : '';
                                echo ucwords(strtolower($currentCartItemsString));
                                ?>
                            </td>
                            <td style="width: 15%;" class="text-capitalize text-center line line-<?php echo $cart['line'] ?>"><?php echo $cart ['quantity'] ?></td>
                            <td style="width: 25%;" class="text-capitalize text-right line line-<?php echo $cart['line'] ?>"><?php echo to_currency($cart ['quantity'] * $cart ['price']) ?></td>
                        </tr>
                        <?php $foodTotal += $cart ['quantity'] * $cart ['price']; ?>
                    <?php endforeach; ?>  
                <?php else: ?>
                    <?php if ($isFoodCartEmpty && $isDbcFoodCartEmpty): ?>
                        <tr>
                            <td> Your Food Cart is Empty</td>
                        </tr>
                    <?php endif; ?>
                <?php endif; ?>
                <?php if (!$isDbcFoodCartEmpty): ?>
                    <?php $dbcFoodCart = array_reverse($dbcFoodCart, true) ?>
                    <?php foreach ($dbcFoodCart as $dbc): ?>
                        <tr onclick="selectRow('<?php isset($dbc['line']) ? print $dbc['line'] : print '0' ?>', '<?php echo $dbc['order_id'] ?>')" class="line line-<?php isset($dbc['line']) ? print $dbc['line'] : print '0' ?> alert-warning db-row" >
                            <td style="width: 60%;" class="text-capitalize text-left line line-<?php echo $dbc['line'] ?>">
                                <?php
                                $dbcItemString = isset($dbc['selection_title']) && $dbc['selection_title'] != null ? $dbc['selection_title'] . '-' . $dbc['menu_title'] : $dbc['menu_title'];
                                $dbcItemString .= $dbc['set_items'] != null ? '<br/> <i><strong style="font-size:11px">Items : </strong><span style="font-size:11px;">' . $dbc['set_items'] . '</span></i>' : '';
                                $dbcItemString .= $dbc['toppings'] != null ? '<br/> <i><strong style="font-size:10px;text-transform: uppercase;">T/S : </strong><span style="font-size:10px;">' . $dbc['toppings'] . '</span></i>' : '';
                                echo ucwords(strtolower($dbcItemString));
                                ?>
                            </td>
                            <td style="width: 15%;" class="text-capitalize text-center line line-<?php echo $dbc['line'] ?>"><?php echo $dbc ['quantity'] ?></td>
                            <td style="width: 25%; margin-right: 3px;" class="text-capitalize text-right line line-<?php echo $dbc['line'] ?>"><?php echo to_currency($dbc ['quantity'] * $dbc ['price']) ?></td>
                        </tr>
                        <?php $foodTotal += $dbc ['quantity'] * $dbc ['price']; ?>
                    <?php endforeach; ?>     
                <?php endif; ?>
            </table>
        </div>
    </div>
    <div><a href="javascript:void(0)" class="btn btn-block btn-danger btn-sm"><span class="glyphicon glyphicon-arrow-up"><?php echo $this->lang->line('gkpos_food') ?></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-remove-circle"  onclick="emptyCart('<?php echo $order_id; ?>')">Empty</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-arrow-down"><?php echo $this->lang->line('gkpos_non_food') ?></span></a></div>
    <div class="tablebackgroundbg">
        <table class="table table-responsive cart-table">
            <tr>
                <th class="text-uppercase text-center" style="width: 60%;"><?php echo $this->lang->line('gkpos_item') ?></th>
                <th class="text-uppercase text-center" style="width: 15%;"><?php echo $this->lang->line('gkpos_qnt') ?></td>
                <th class="text-uppercase text-center" style="width: 25%;"><?php echo $this->lang->line('gkpos_price') ?></th>
            </tr>
        </table>
        <div class="item-table item-table-2">
            <table class="table table-bordered table-responsive cart-table" id="nonFoodCart">
                <?php if (!$isNonFoodCartEmpty): ?>
                    <?php $nonFoodCart = array_reverse($nonFoodCart, true) ?>
                    <?php foreach ($nonFoodCart as $cart): ?>
                        <tr onclick="selectRow('<?php echo $cart['line'] ?>', '<?php echo $cart['order_id'] ?>')" class="line line-<?php echo $cart['line'] ?>" >
                            <td style="width: 60%;" class="text-capitalize text-left">
                                <?php
                                $currentCartItemsString = isset($cart['selection_title']) && $cart['selection_title'] != null ? $cart['selection_title'] . '-' . $cart['menu_title'] : $cart['menu_title'];
                                $currentCartItemsString .= $cart['set_items'] != null ? '<br/> <i><strong style="font-size:11px">Items : </strong><span style="font-size:11px;">' . $cart['set_items'] . '</span></i>' : '';
                                $currentCartItemsString .= $cart['toppings'] != null ? '<br/> <i><strong style="font-size:10px; text-transform: uppercase;">T/S : </strong><span style="font-size:10px;">' . $cart['toppings'] . '</span></i>' : '';
                                echo ucwords(strtolower($currentCartItemsString));
                                ?>
                            </td>
                            <td style="width: 15%;" class="text-center"><?php echo $cart ['quantity'] ?></td>
                            <td style="width: 25%; padding-right: 3px;" class="text-right"><?php echo to_currency($cart ['quantity'] * $cart ['price']) ?></td>
                        </tr>
                        <?php $nonFoodTotal += $cart ['quantity'] * $cart ['price'] ?>
                    <?php endforeach; ?>
                <?php else: ?>
                    <?php if ($isNonFoodCartEmpty && $isDbcNonFoodCartEmpty): ?>
                        <tr>
                            <td> Your Beverage Cart is Empty</td>
                        </tr>
                    <?php endif; ?>
                <?php endif; ?>
                <?php if (!$isDbcNonFoodCartEmpty): ?>
                    <?php $dbcNonFoodCart = array_reverse($dbcNonFoodCart, true) ?>
                    <?php foreach ($dbcNonFoodCart as $dbc): ?>
                        <tr onclick="selectRow('<?php echo $dbc['line'] ?>', '<?php echo $dbc['order_id'] ?>')" class="line line-<?php echo $dbc['line'] ?> alert-warning db-row " >
                            <td style="width: 60%;" class="text-capitalize text-left">
                                <?php
                                $dbcItemString = isset($dbc['selection_title']) && $dbc['selection_title'] != null ? $dbc['selection_title'] . '-' . $dbc['menu_title'] : $dbc['menu_title'];
                                $dbcItemString .= $dbc['set_items'] != null ? '<br/> <i><strong style="font-size:11px">Items : </strong><span style="font-size:11px;">' . $dbc['set_items'] . '</span></i>' : '';
                                $dbcItemString .= $dbc['toppings'] != null ? '<br/> <i><strong style="font-size:10px;text-transform: uppercase;">T/S : </strong><span style="font-size:10px;">' . $dbc['toppings'] . '</span></i>' : '';
                                echo ucwords(strtolower($dbcItemString));
                                ?>

                            </td>
                            <td style="width: 15%;" class="text-capitalize text-center"><?php echo $dbc ['quantity'] ?></td>
                            <td style="width: 25%; margin: 0px 2px " class="text-capitalize text-right"><?php echo to_currency($dbc ['quantity'] * $dbc ['price']) ?></td>
                        </tr>
                        <?php $nonFoodTotal += $dbc ['quantity'] * $dbc ['price']; ?>
                    <?php endforeach; ?>     
                <?php endif; ?>
            </table>
        </div>
    </div>
    <?php
    $subtotal = $foodTotal + $nonFoodTotal;
    $this->Orders_Model->set_foodtotal($order_id, $foodTotal);
    $this->Orders_Model->set_nonfoodtotal($order_id, $nonFoodTotal);
    $this->Orders_Model->set_subtotal($order_id, $subtotal);
    $total += $subtotal;
    ?>
    <div style="margin-bottom: -5px; height:2px;"><a href="javascript:void(0)" class="btn-block btn-danger btn-sm"></a></div>
    <div class="tablebackgroundbg item-table calculation-table" id="calculationTable">
        <input type="hidden" id="CurrentOrderTotal" value='<?php echo $total ?>'/>
        <table class="table table-responsive">
            <tr>
                <th style="text-align: right!important; padding: 4px 5px!important"><?php echo $this->lang->line('gkpos_subtotal') ?></th>
                <td style="text-align: right!important; padding: 4px 5px!important"><?php echo to_currency($total) ?></td>
            </tr>
            <!--DISCOUNT MANAGE PART -->    
            <?php
            $discount_data = $this->Orders_Model->get_discount($order_id);
            //debugPrint($discount_data);
            $discountArray = !empty($discount_data) ? calculate_discount($order_id, $total, $foodTotal, $nonFoodTotal, $discount_data) : 0;
            //debugPrint($discountArray);
            $discount = $discountArray['discount'];
            $discount_string = $discountArray['dsicount_string'];
            $this->Orders_Model->set_discount_amount($order_id, $discount);
            ?>
            <?php if ($discount > 0): ?>
                <tr class="line-discount">
                    <th style="text-align: right!important; padding: 4px 5px!important"><?php echo $this->lang->line('gkpos_discount') ?></th>
                    <td style="text-align: right!important; padding: 4px 5px!important"><?php echo to_currency(!$this->Orders_Model->get_discount_amount($order_id) ? $discount : $this->Orders_Model->get_discount_amount($order_id) ) ?></td>
                </tr>
            <?php endif; ?>
            <!--DISCOUNT MANAGE PART END--> 
            <?php $delivery_charge = 0; ?>
            <?php if ($currentOrderObj->order_type == 'delivery'): ?>
                <?php $delivery_plan = $this->Orders_Model->get_deliveryplan($order_id); ?>
                <?php if (isset($delivery_plan) && !empty($delivery_plan)): ?>
                    <tr>
                        <?php $delivery_charge = $delivery_plan['is_free'] == 2 ? $delivery_plan['delivery_charge'] : 0; ?>
                        <th style="text-align: right!important; padding: 4px 5px!important"><?php echo $this->lang->line('gkpos_delivery_fee') ?></th>
                        <td style="text-align: right!important; padding: 4px 5px!important"><?php $delivery_charge > 0 ? print to_currency($delivery_charge) : print 'FREE' ?></td>
                    </tr>     
                <?php endif ?>
            <?php endif; ?>     
            <?php $this->Orders_Model->set_deliveryplan_amount($order_id, $delivery_charge) ?>
            <!--SERVICE CHARGE MANAGE PART -->    
            <?php
            $service_charge_data = $this->Orders_Model->get_servicecharge($order_id);
            $service_charge = !empty($service_charge_data) ? calculate_service_charge($order_id, $total, $service_charge_data) : 0;
            $service_charge = !$this->Orders_Model->get_servicecharge_amount($order_id) ? $service_charge : $this->Orders_Model->get_servicecharge_amount($order_id)
            ?>   
            <?php if ($service_charge > 0): ?>
                <tr class="line-service-charge">
                    <th style="text-align: right!important; padding: 4px 5px!important"><?php echo $this->lang->line('gkpos_servicecharge') ?></th>
                    <td style="text-align: right!important; padding: 4px 5px!important"><?php echo to_currency($service_charge) ?></td>
                </tr>
            <?php endif; ?>
            <!--SERVICE CHARGE MANAGE PART END-->    

            <!--VAT MANAGE PART --> 
            <?php
            $vat_data = $this->Orders_Model->get_vat($order_id);
            $vat = 0;
            if (!empty($vat_data) && $vat_data['is_included'] == 2) {
                $vat = calculate_vat($order_id, $total, $vat_data);
            }
            ?>  
            <?php if ($vat > 0): ?>
                <tr>
                    <th style="text-align: right!important; padding: 4px 5px!important"><?php echo $this->lang->line('gkpos_vat') ?></th>
                    <td style="text-align: right!important; padding: 4px 5px!important"><?php $vat_data['is_included'] == 1 ? print'<span class="alert-info">' . $vat_data['number'] . '&percnt;' . $this->lang->line('gkpos_vat_included') . '</span>' : print to_currency($vat) ?></td>
                </tr>
            <?php endif; ?>
            <!--VAT MANAGE PART END--> 

            <!--TOTAL MANAGE PART --> 
            <?php $cc_fee = 0 ?>
            <?php if ($this->Orders_Model->get_cc_fee($order_id)): ?>
                <tr>
                    <?php $cc_fee = $this->Orders_Model->get_cc_fee($order_id) ?>
                    <th style="text-align: right!important; padding: 4px 5px!important">ccFee</th>
                    <td style="text-align: right!important; padding: 4px 5px!important"><?php echo to_currency($cc_fee > 0 ? $cc_fee : 0) ?></td>
                </tr>
            <?php endif; ?>

            <?php $multi_discount = 0 ?>
            <?php if ($bogo_discount > 0): ?>
                <tr>
                    <?php $multi_discount = $bogo_discount ?>
                    <th style="text-align: right!important; padding: 4px 5px!important">Multi Discount</th>
                    <td style="text-align: right!important; padding: 4px 5px!important"><?php echo to_currency($multi_discount) ?></td>
                </tr>
            <?php endif; ?>    

            <?php
            $total += ($service_charge + $vat + $delivery_charge + $cc_fee) - ($discount + $multi_discount);
            $this->Orders_Model->set_total($order_id, $total);
            calculateTotal: {
                $this->Orders_Model->set_total($order_id, $total);
            }
            if ($total != $this->Orders_Model->get_total($order_id)) {
                goto calculateTotal;
            }
            ?>
            <tr>
                <th style="text-align: right!important; padding: 4px 5px!important"><?php echo $this->lang->line('gkpos_total') ?></th>
                <td style="text-align: right!important; padding: 4px 5px!important"><?php echo to_currency($total) ?></td>
            </tr>
            <!--TOTAL MANAGE PART --> 
            <?php if (!empty($delivery_plan) && ($foodTotal + $nonFoodTotal) < $delivery_plan ['min_order']): ?>
                <tr>
                    <td colspan="2" class="text-capitalize alert-info" style="text-align: center;"><?php print'Minimum Delivery Order Amount:' . to_currency($delivery_plan['min_order']) ?></td>
                </tr>
            <?php endif; ?>
        </table>
    </div>
    <input type="hidden" id="selectedRow" value="<?php isset($line) ? print $line : '' ?>">
    <input type="hidden" id="orderId" value="<?php isset($order_id) ? print $order_id : '' ?>">
    <div class="colpay-close" style="padding: 3px 0 3px 0; margin-top: -15px;">
        <a href="javascript:void(0)" onclick="kitchenTextDialog('<?php echo $order_id ?>')" class="off-click"><div class="btn btn-block btn-sm btn-warning gradient round" style="width: 100%"><?php echo $this->lang->line('gkpos_send_kitchen_note_with_order') ?></div></a>
    </div>
    <?php //debugPrint(array($has_new, $has_update, $isCartEmty, $isDbcEmpty)) ?>
    <div style="padding-top: 3px;">
        <?php if (!empty($delivery_plan) && ($foodTotal + $nonFoodTotal) < $delivery_plan['min_order']): ?>
            <div class="sendbg col-lg-3 col-md-3 col-sm-3 col-xs-3" onclick="alert('<?php echo $this->lang->line("gkpos_meet_delivery_condition") ?>')"><?php echo $this->lang->line('gkpos_send') ?></div>
        <?php else: ?>
            <?php if ($has_new == 'no' && $has_update == 'yes'): ?>
                <div class="sendbg col-lg-3 col-md-3 col-sm-3 col-xs-3" onclick="cartPostUpdate('<?php echo $order_id ?>')"><?php echo $this->lang->line('gkpos_update') ?></div>
            <?php endif; ?>   
            <?php if ($has_new == 'yes' && ($has_update == 'yes' || $has_update == 'no')): ?>
                <?php if (!empty($delivery_plan) && ($foodTotal + $nonFoodTotal) < $delivery_plan['min_order']): ?>
                    <div class="sendbg col-lg-3 col-md-3 col-sm-3 col-xs-3" onclick="submitCart('<?php echo $order_id ?>', 'minYes', '<?php echo $isCartEmty ?>', '<?php echo $isDbcEmpty ?>', '<?php echo $has_new ?>', '<?php echo $has_update ?>')"><?php echo $this->lang->line('gkpos_send') ?></div>
                <?php else: ?>
                    <div class="sendbg col-lg-3 col-md-3 col-sm-3 col-xs-3" onclick="submitCart('<?php echo $order_id ?>', 'minNo', '<?php echo $isCartEmty ?>', '<?php echo $isDbcEmpty ?>', '<?php echo $has_new ?>', '<?php echo $has_update ?>')"><?php echo $this->lang->line('gkpos_send') ?></div>
                <?php endif; ?>
            <?php endif; ?>
            <?php if ($has_new == 'no' && $has_update == 'no' && (!$isCartEmty || !$isDbcEmpty)): ?>   
                <?php if (!empty($delivery_plan) && ($foodTotal + $nonFoodTotal) < $delivery_plan['min_order']): ?>
                    <div class="sendbg col-lg-3 col-md-3 col-sm-3 col-xs-3" onclick="submitCart('<?php echo $order_id ?>', 'minYes', '<?php echo $isCartEmty ?>', '<?php echo $isDbcEmpty ?>', '<?php echo $has_new ?>', '<?php echo $has_update ?>')"><?php echo $this->lang->line('gkpos_send') ?></div>
                <?php else: ?>
                    <?php if ($has_new == 'yes'): ?>
                        <div class="sendbg col-lg-3 col-md-3 col-sm-3 col-xs-3" onclick="submitCart('<?php echo $order_id ?>', 'minNo', '<?php echo $isCartEmty ?>', '<?php echo $isDbcEmpty ?>', '<?php echo $has_new ?>', '<?php echo $has_update ?>')"><?php echo $this->lang->line('gkpos_send') ?></div>
                    <?php else: ?>
                        <div class="sendbg col-lg-3 col-md-3 col-sm-3 col-xs-3 off-click" onclick="resendToKitchen('<?php isset($order_id) ? print $order_id : print $this->uri->segment(4) ?>')"><?php echo $this->lang->line('gkpos_resend') ?></div>
                    <?php endif; ?>
                <?php endif; ?>
            <?php endif; ?>
            <?php if ($has_new == 'no' && $has_update == 'no' && $isCartEmty && $isDbcEmpty): ?>
                <div class="sendbg col-lg-3 col-md-3 col-sm-3 col-xs-3 off-click" onclick="alert('Nothing to happen')"><?php echo $this->lang->line('gkpos_send') ?></div>
            <?php endif; ?>  
        <?php endif ?>
        <div style="cursor: pointer" class="minusbg col-lg-3 col-md-3 col-sm-3 col-xs-3 update-button-width off-click" onclick="updatecart('minus', '1', '<?php echo $isCartEmty ?>', '<?php echo $isDbcEmpty ?>')"><span class="minustextbg"> <?php echo $this->lang->line('gkpos_minus') ?> </span></div>
        <div style="cursor: pointer" class="plusbg col-lg-3 col-md-3 col-sm-3 col-xs-3  update-button-width off-click" onclick="updatecart('plus', '1', '<?php echo $isCartEmty ?>', '<?php echo $isDbcEmpty ?>')"><span class="plustextbg"> <?php echo $this->lang->line('gkpos_plus') ?> </span></div>
        <div style="cursor: pointer" class="minusbg col-lg-3 col-md-3 col-sm-3 col-xs-3  update-button-width off-click" onclick="updatecart('del', '1', '<?php echo $isCartEmty ?>', '<?php echo $isDbcEmpty ?>')"><span class="plustextbg"> <?php echo $this->lang->line('gkpos_numpad_key_del') ?> </span></div>
        <!--<div style="cursor: pointer" class="ktcbg col-lg-3 col-md-3 col-sm-3 col-xs-3"><?php echo $this->lang->line('gkpos_ktc') ?></div>-->
    </div>
    <div class="clearfix"></div>
    <div class="colpay-close" style="margin-top: 3px;">
        <a href="javascript:void(0)" onclick="ccFeeOpener('<?php echo $order_id ?>')" class="off-click"><div class="btn btn-block btn-sm btn-primary gradient round"><?php echo $this->lang->line('gkpos_add_cce_fee') ?></div></a>
    </div>
    <div class="clearfix"></div>
    <?php if ($currentOrderObj->paid_status == 1): ?>
        <div class="colpay-close" style="padding: 3px 0 3px 0; margin-top: 3px;">
            <a href="javascript:void(0)"><div class="pay-closs-enter img-responsive text-capitalize text-center"><?php echo $this->lang->line('gkpos_already_paid_and_closed') ?></div></a>
        </div>
    <?php else: ?>
        <?php if (!empty($delivery_plan) && ($foodTotal + $nonFoodTotal) < $delivery_plan['min_order']): ?>
            <div class="colpay-close" style="margin-top: 3px;">
                <a href="javascript:void(0)" onclick="alert('<?php echo $this->lang->line("gkpos_meet_delivery_condition") ?>')"><div class="pay-closs-enter img-responsive text-capitalize text-center btn round" style="height: 50px; padding: 27px 0px;"><?php echo $this->lang->line('gkpos_pay_and_close') ?></div></a>
            </div>
        <?php else: ?>
            <div class="colpay-close" style="margin-top: 3px;">
                <a href="javascript:void(0)" onclick="payAndClose('<?php isset($order_id) ? print $order_id : print $this->uri->segment(4) ?>', '<?php echo $isCartEmty ?>', '<?php echo $isDbcEmpty ?>', '<?php echo $has_new ?>', '<?php echo $has_update ?>')"><div class="pay-closs-enter img-responsive text-capitalize text-center btn round" style="height: 50px; padding: 27px 0px;"><?php echo $this->lang->line('gkpos_pay_and_close') ?></div></a>
            </div>
        <?php endif; ?>
    <?php endif; ?>
</div>
<input type="hidden" id="hasUpdate" value='<?php echo $has_update ?>'>
<input type="hidden" id="hasNew" value='<?php echo $has_new ?>'>
<input type="hidden" id="isDbcEmpty" value="<?php $isDbcEmpty ? print 'yes' : 'no' ?>"/>
<div style="display: none;">
    <div id="guestBill_<?php echo $this->Orders_Model->get_current_orderid() ?>" style="width: 80mm; margin: 0 auto;">
        <table style="width: 80mm; margin: 0 auto;padding: 0" >
            <tr>
                <td colspan="2" style="width: 80mm; text-align: center;"><img src="<?php echo UPLOAD_PATH ?>gkpos/logo/<?php echo $this->config->item('gk_logo'); ?>"></td>
            </tr>
            <tr>
                <td colspan="2" style="width: 80mm;text-align: center;font-weight: bold;text-transform: uppercase; font-size: 1.5em"><?php echo $this->config->item('gk_name') ?></td>
            </tr>
            <tr>
                <td colspan="2" style="width: 80mm; text-align: left; font-size: 1em"><?php echo $this->config->item('gk_address') ?></td>
            </tr>
            <tr>
                <td colspan="2" style="width: 80mm;font-size: 1em;text-align: center;">Phone: <?php echo $this->config->item('gk_phone') ?></td>
            </tr>
            <tr>
                <td colspan="2" style="width: 80mm;font-size: 1em; text-align: center;">VAT NO: <?php echo $this->config->item('gk_vat_reg') ?></td>
            </tr>
            <tr>
                <td style="width: 30mm; font-size: 1em;text-align: left;">#<?php $this->Orders_Model->get_current_orderid() ? print strtoupper($this->Orders_Model->get_current_orderid()) : strtoupper($this->uri->segment(4)) ?></td>
                <td style="width: 50mm; font-size: 1em;text-align: right; padding-right: 5mm">By:-<?php echo get_user_name($this->session->userdata('gkpos_userid')) ?></td>
            </tr>
            <tr>
                <td colspan="2" style="width: 80mm; border-bottom: 2px dotted #000;padding: 0;margin: 0"></td>
            </tr>    
        </table>
        <table style="width: 80mm; margin: 0 auto;padding: 0" >
            <tr>
                <td style="width:65mm;font-weight: bold;"><?php echo $this->lang->line('gkpos_item') ?></td>
                <td style="width:15mm;font-weight: bold;"><?php echo $this->lang->line('gkpos_price') ?></td>
            </tr>
            <?php if (!$isDbcFoodCartEmpty): ?>
                <?php foreach ($dbcFoodCart as $key => $obj): ?>
                    <tr>
                        <td style="text-transform: capitalize;text-align: left;width: 60mm ">
                            <?php echo $obj ['quantity'] ?>&nbsp;&nbsp;
                            <?php
                            $dbcItemString = isset($obj['selection_title']) && $obj['selection_title'] != null ? $obj['selection_title'] . '-' . $obj['menu_title'] : $obj['menu_title'];
                            $dbcItemString .= $obj['set_items'] != null ? '<br/> <i><strong style="font-size:11px">Items : </strong><span style="font-size:11px;">' . $obj['set_items'] . '</span></i>' : '';
                            $dbcItemString .= $obj['toppings'] != null ? '<br/> <i><strong style="font-size:10px;text-transform: uppercase;">T/S : </strong> : <span style="font-size:10px;">' . $obj['toppings'] . '</span></i>' : '';
                            echo ucwords(strtolower($dbcItemString));
                            ?>
                        <td style="text-align: right;width: 20mm;padding-right: 3mm"><?php echo to_currency($obj ['quantity'] * $obj ['price']) ?></td>
                    </tr>
                <?php endforeach; ?>
            <?php endif; ?>
            <?php if (!$isDbcNonFoodCartEmpty): ?>
                <?php foreach ($dbcNonFoodCart as $key => $obj): ?>        
                    <tr>
                        <td style="text-transform: capitalize; text-align: left;width: 60mm" ><?php echo $obj ['quantity'] ?>&nbsp;&nbsp;
                            <?php
                            $dbcItemString2 = isset($obj['selection_title']) && $obj['selection_title'] != null ? $obj['selection_title'] . '-' . $obj['menu_title'] : $obj['menu_title'];
                            $dbcItemString2 .= $obj['set_items'] != null ? '<br/> <i><strong style="font-size:11px">Items : </strong><span style="font-size:11px;">' . $obj['set_items'] . '</span></i>' : '';
                            $dbcItemString2 .= $obj['toppings'] != null ? '<br/> <i><strong style="font-size:10px;text-transform: uppercase;">T/S : </strong><span style="font-size:10px;">' . $obj['toppings'] . '</span></i>' : '';
                            echo ucwords(strtolower($dbcItemString2));
                            ?>
                        </td>
                        <td style="text-align: right;width: 20mm;padding-right: 3mm"><?php echo to_currency($obj ['quantity'] * $obj ['price']) ?></td>
                    </tr>
                <?php endforeach; ?>
            <?php endif; ?>  
            <tr>
                <td colspan="2" style="width: 80mm; border-bottom: 2px dotted #000;padding: 0;margin: 0"></td>
            </tr>           
        </table>
        <table style="width: 80mm; margin: 0 auto;padding: 0" >
            <tr>
                <td style="width: 60mm;text-align: right;padding-right: 3mm;"><?php echo $this->lang->line('gkpos_subtotal') ?>:</td>
                <td style='width: 20mm;text-align: right;padding-right: 3mm; '><?php echo to_currency($subtotal) ?></td>
            </tr>
            <?php if ($vat > 0): ?>
                <tr>
                    <td style="width: 60mm;text-align: right;padding-right: 3mm;"><?php echo $this->lang->line('gkpos_vat') ?>:</td>
                    <td style='width: 20mm;text-align: right;padding-right: 3mm;'><?php $vat_data['is_included'] == 1 ? print'<span class="alert-info">' . $vat_data['number'] . '&percnt;' . $this->lang->line('gkpos_vat_included') . '</span>' : print to_currency($vat) ?></td>
                </tr>
            <?php endif; ?>
            <?php if ($service_charge > 0): ?>
                <tr>
                    <td style="width: 60mm;text-align: right;padding-right: 3mm;">Service Charge:</td>
                    <td style='width: 20mm;text-align: right;padding-right: 3mm; '><?php echo to_currency($service_charge) ?></td>
                </tr>
            <?php endif; ?>
            <?php if (isset($delivery_plan) && !empty($delivery_plan)): ?>
                <tr>
                    <td style="width: 60mm; text-align: right;padding-right: 3mm;"><?php echo $this->lang->line('gkpos_delivery_fee') ?>:</td>
                    <td style='width: 20mm;text-align: right;padding-right: 3mm; '><?php $delivery_charge > 0 ? print to_currency($delivery_charge) : print 'FREE' ?></td>
                </tr>
            <?php endif; ?>

            <?php if ($discount > 0): ?>   
                <tr>
                    <td style="width: 60mm;text-align: right;padding-right: 3mm;"><?php echo $this->lang->line('gkpos_discount') ?>:</td>
                    <td style='width: 20mm;text-align: right;padding-right: 3mm;'><?php echo to_currency(!$this->Orders_Model->get_discount_amount($order_id) ? $discount : $this->Orders_Model->get_discount_amount($order_id) ) ?></td>
                </tr>
            <?php endif; ?>
            <tr>
                <td colspan="2" style="width: 80mm; border-bottom: 2px dotted #000;padding: 0;margin: 0"></td>
            </tr>    
            <tr>
                <td style="width: 60mm; text-align: right;padding-right: 3mm;"><?php echo $this->lang->line('gkpos_total') ?>:</td>
                <td style='width: 20mm;text-align: right;padding-right: 3mm;'><?php echo to_currency($total) ?></td>
            </tr>
            <tr>
                <td colspan="2" style="width: 80mm; border-bottom: 2px dotted #000;padding: 0;margin: 0; display: none;" class="payment-line" ></td>
            </tr>      
            <?php $paidPayments = $this->Orders_Model->get_payments($currentOrderObj->id) ?>
            <tr>
                <td style="width: 60mm; text-align: right; padding-right: 3mm;" class="Cash"><?php isset($paidPayments['Cash']['method']) ? print $paidPayments['Cash']['method'] . ':' : '' ?></td>
                <td style='width: 20mm;text-align: right;padding-right: 3mm;' class="CashAmount"><?php isset($paidPayments['Cash']['amount']) ? print to_currency($paidPayments['Cash']['amount']) : '' ?></td>
            </tr>
            <tr>
                <td style="width: 60mm; text-align: right;padding-right: 3mm;" class="EFT"><?php isset($paidPayments['EFT']['method']) ? print $paidPayments['EFT']['method'] . ':' : '' ?></td>
                <td style='width: 20mm;text-align: right;padding-right: 3mm;;' class="EFTAmount"><?php isset($paidPayments['EFT']['amount']) ? print to_currency($paidPayments['EFT']['amount']) : '' ?></td>
            </tr>
            <tr>
                <td style="width: 60mm; text-align: right;padding-right: 3mm;" class="Cheque"><?php isset($paidPayments['Cheque']['method']) ? print $paidPayments['Cheque']['method'] . ':' : '' ?></td>
                <td style='width: 20mm;text-align: right;padding-right: 3mm;' class="ChequeAmount"><?php isset($paidPayments['Cheque']['amount']) ? print to_currency($paidPayments['Cheque']['amount']) : '' ?></td>
            </tr>
            <tr>
                <td style="width: 60mm; text-align: right;padding-right: 3mm;" class="Voucher"><?php isset($paidPayments['Voucher']['method']) ? print $paidPayments['Voucher']['method'] . ':' : '' ?></td>
                <td style='width: 20mm;text-align: right;padding-right: 3mm;' class="VoucherAmount"><?php isset($paidPayments['Voucher']['amount']) ? print to_currency($paidPayments['Voucher']['amount']) : '' ?></td>
            </tr>
            <tr>
                <td colspan="2" style="width: 80mm; border-bottom: 2px dotted #000;padding: 0;margin: 0; display: none;" class="payment-line" ></td>
            </tr>  
            <?php
            $changeDueString = null;
            $changeAmount = null;
            if ($currentOrderObj->change_due != null && $currentOrderObj->change_due < 0) {

                if ($currentOrderObj->pay_tip == 'yes') {
                    $changeDueString = 'Tips:';
                } else {
                    $changeDueString = 'Paid Back:';
                }
                $changeAmount = abs($currentOrderObj->change_due);
            }
            ?>
            <tr>
                <td style="width: 60mm; text-align: right;padding-right: 3mm;" id="billChangeOption"><?php ($currentOrderObj->change_due != null && $currentOrderObj->change_due < 0) ? print $changeDueString : '' ?></td>
                <td style='width: 20mm;text-align: right;padding-right: 3mm; ' id="billChangeAmount"><?php ($currentOrderObj->change_due != null && $currentOrderObj->change_due < 0) ? print to_currency($changeAmount) : '' ?></td>
            </tr>
            <tr>
                <td colspan="2">
                    <table style="width: 80mm; margin: 0 auto;padding: 0" >
                        <tr>
                            <td style="width: 20mm; font-size: 1em;text-align: left;"><?php echo date($this->config->item('dateformat')) ?></td>
                            <?php $billOrderType = $currentOrderObj->order_type ?>
                            <td colspan="2" style="font-size: 1.2em; width: 40mm; text-transform: uppercase;font-weight: bold; text-align: center;"><?php $billOrderType == 'table' ? print $billOrderType . '-' . $currentOrderObj->table_number . '/' . $currentOrderObj->guest_quantity : print $billOrderType ?></td>
                            <td style="width: 20mm; font-size: 1em;text-align: right; padding-right: 5mm;"><?php echo date($this->config->item('timeformat')) ?></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <?php if ($billOrderType !== 'table'): ?>
                <tr>
                    <td colspan="2">
                        <table style="width: 80mm; margin: 0 auto;padding: 0" >
                            <?php if ($currentOrderObj->name != null): ?>
                                <tr>
                                    <td colspan="2" style="width: 80mm; font-size: 1em;text-align: center; text-transform: capitalize;"><?php echo $this->lang->line('gkpos_name') ?>:<?php echo $currentOrderObj->name ?></td>
                                </tr>
                            <?php endif; ?>

                            <?php if ($billOrderType == 'delivery' && $currentOrderObj->postcode != null): ?>
                                <?php if ($currentOrderObj->phone != null): ?>
                                    <tr>
                                        <td colspan="2" style="width: 80mm; font-size: 1em;text-align: center;"><?php echo $this->lang->line('gkpos_phone') ?>:<?php echo $currentOrderObj->phone ?></td>
                                    </tr>
                                <?php endif; ?>
                                <?php
                                $billAddressString = '';
                                $billAddressString .= $currentOrderObj->floor_or_apt != null ? $this->lang->line('gkpos_floor_or_apt_no') . '&nbsp;:&nbsp;' . $currentOrderObj->floor_or_apt . ', ' : '';
                                $billAddressString .= $currentOrderObj->building != null ? $this->lang->line('gkpos_building') . '&nbsp;:&nbsp;' . $currentOrderObj->building . '<br/>' : '';
                                $billAddressString .= $currentOrderObj->house != null ? $currentOrderObj->house . '&nbsp;' : '';
                                $billAddressString .= $currentOrderObj->street != null ? $currentOrderObj->street . ', ' : '';
                                $billAddressString .= $currentOrderObj->city != null ? $currentOrderObj->city . ', ' : '';
                                $billAddressString .= $currentOrderObj->postcode;
                                ?>
                                <tr>
                                    <td colspan="2" style="width: 80mm; font-size: 1em;text-align: center; padding-right: 5mm;"><?php echo $billAddressString ?></td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="width: 80mm; font-size: 1em;text-align: center;"><?php echo $this->lang->line('gkpos_delivery_time') ?>:<?php echo date('F j, Y H:i:a', strtotime($currentOrderObj->delivery_time)) ?></td>
                                </tr>
                            <?php endif; ?>
                        </table>
                    </td>
                </tr>
            <?php endif; ?>
        </table>
    </div>
</div>
<script>

    $(document).ready(function () {
        var isOrderPaid = '<?php echo $currentOrderObj->paid_status; ?>';
        if (isOrderPaid == 1) {
            $(".off-click").removeAttr("onclick");
            var changeDue = '<?php echo $currentOrderObj->change_due; ?>';
            if (Number(changeDue) < 0) {
                $('.payment-line').show();
            }
            var printFromBrowser = '<?php echo $this->config->item('gk_guest_bill_from_browser') ?>'
            if (printFromBrowser == 'yes') {
                printGuestBillServer('<?php echo $currentOrderObj->id ?>', 4);
            } else {
                printGuestBill('<?php echo $currentOrderObj->id ?>', 4);
            }
        }
    });
    function manageCartAreaHeight() {
        $('.item-table-1').css({'min-height': '26vh', 'max-height': '26vh', "overflow-y": "auto", "overflow-x": "hidden"});
        $('.item-table-2').css({'min-height': '10vh', 'max-height': '10vh', "overflow-y": "auto", "overflow-x": "hidden"});
        $('.calculation-table').css({'min-height': '14vh', 'max-height': '14vh', 'margin-bottom': '14.5px', "overflow-y": "auto", "overflow-x": "hidden"});
        $('.item-table-1').jScrollPane();
        $('.item-table-2').jScrollPane();
        $('#calculationTable').jScrollPane().data('jsp').scrollToBottom();
        manageWindowHeight();
    }
    function cartPostUpdate(order_id) {
        
        $.ajax({
            url: "<?php echo site_url('gkpos/orders/cart_post_update') ?>",
            data: {
                order_id: order_id
            },
            type: "POST",
            dataType: "json",
            success: function (output) {
                if (output.success) {
                    ALERT_TITLE = "Success!";
                }
                alert(output.message);
                loadCart(output.order_id, 0);
            }
        });
    }
    function resendToKitchen(order_id) {
        
        $.ajax({
            url: "<?php echo site_url('gkpos/orders/resend_to_kitchen') ?>",
            data: {
                order_id: order_id
            },
            type: "POST",
            dataType: "json",
            success: function (output) {
                if (output.success) {
                    ALERT_TITLE = "Print Success!";
                    alert(output.message);
                    loadCart(output.order_id, 5);
                } else {
                    ALERT_TITLE = "Print Failed!";
                    alert(output.message);
                    loadCart(output.order_id, 5);
                }
            }
        });


    }

    function emptyCart(order_id) {
        $.ajax({
            url: "<?php echo site_url('gkpos/orders/empty_cart'); ?>",
            type: "POST",
            dataType: "json",
            data: {
                id: order_id
            },
            success: function (output) {
                RefreshPage('<?php echo site_url("gkpos/orders/indexajax/" . $this->Orders_Model->get_current_orderid()) ?>');
            }
        });
    }
    function kitchenTextDialog(ktcOrderId) {
        $.ajax({
            url: '<?php echo site_url('gkpos/orders/kitchen_text_opener') ?>',
            data: {
                ktcOrderId: ktcOrderId
            },
            type: 'POST',
            success: function (output) {
                $('#menuListArea').html(output);
                $('#categoryTitle').html('');
<?php if ($this->config->item('is_touch') == 'enable') { ?>
                    jsKeyboard.currentElement = $('#kitchenDeliveryNote');
<?php } ?>
            }
        });

    }
    function ccFeeOpener(ktcOrderId) {
        $.ajax({
            url: '<?php echo site_url('gkpos/orders/ccFee_opener') ?>',
            data: {
                ktcOrderId: ktcOrderId
            },
            type: 'POST',
            success: function (output) {
                $('#menuListArea').html(output);
                $('#categoryTitle').html('');
                $('#ccFeeOrderId').val(ktcOrderId);
                setCcFeeNumkeys('ccFee');
            }
        });
    }
</script>