
<?php $status = array('Pending', 'Confirmed', 'Canceled', 'Waiting For Online Payment') ?>
<?php $status_color = array('color:#FF9900;', 'color:#219921;', 'color:#D52229;', 'color:#FF9900;') ?>

<div class="buttons" style="margin: 10px 0px;">
    <div onclick="getPage('<?php echo site_url('gkpos/online_order') ?>', 'online order')" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 btn btn-primary gradient text-center" style="font-size:90%">All</div>
    <div onclick="getPage('<?php echo site_url('gkpos/online_order/pending/0') ?>', 'online order')" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 btn btn-warning gradient text-center" style="font-size: 90%">Pending</div>
    <div onclick="getPage('<?php echo site_url('gkpos/online_order/confirmed/1') ?>', 'online order')" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 btn btn-success gradient text-center" style="font-size: 90%">Confirmed</div>
    <div onclick="getPage('<?php echo site_url('gkpos/online_order/canceled/2') ?>', 'online order')" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 btn btn-danger gradient text-center" style="font-size: 90%">Cancelled</div>
    <div onclick="getPage('<?php echo site_url('gkpos/online_order/paid/1') ?>', 'online order')" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 btn btn-info gradient text-center" style="font-size: 90%">Paid</div>
    <div onclick="getPage('<?php echo site_url('gkpos/online_order/unpaid/2') ?>', 'online order')" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 btn btn-danger gradient text-center" style="font-size: 90%" >Unpaid</div>
</div>
<div style='margin: 0px 0px;'>&nbsp;</div>
<?php if (!empty($order[0])): ?>
    <div class="modal-content-order-detail no-padding">
        <div class="modal-body no-padding">
            <?php if (!empty($order[0])): ?>
                <table class="table table-responsive table-bordered table-bg-color-white no-padding">
                    <tr>
                        <td class="text-left">Order# :<strong><?php echo strtoupper($order[0]->id) ?></strong></td>
                        <td class="text-left">Status:<span style='<?php echo $status_color[$order[0]->online_status] ?>'><strong><?php echo $status[$order[0]->online_status] ?></strong></span></td>
                    </tr>
                    <tr>
                        <td class="text-left">Order Type:<?php echo ucfirst($order[0]->order_type) . ' ' . ucfirst($order[0]->online_type) ?></td>
                        <td class="text-left">Customer Phone:<?php echo $order[0]->phonealt ? $order[0]->phonealt : $order[0]->phone ?></td>
                    </tr>
                    <tr>
                        <td class="text-left">Order Total: &nbsp;<strong><?php echo to_currency($order[0]->grand_total) ?></strong></td>
                        <td class="text-left">Customer Name:<?php echo $order[0]->namealt ? $order[0]->namealt : $order[0]->name ?></td>
                    </tr>
                    <tr>
                        <td class="text-left">Payment Status:<?php $order[0]->paid_status == 1 ? print "Paid" : print "Not Paid" ?></td>
                        <td class="text-left">Delivery Time:<?php echo $order[0]->delivery_time ?></td>
                    </tr>
                    <?php if ($order[0]->online_type == 'delivery'): ?>
                        <tr>
                            <td colspan="2" class="text-left"> Delivery Address #
                                <?php
                                $billAddressString = '';
                                $billAddressString .= trim($order[0]->floor_or_apt) ? $this->lang->line('gkpos_floor_or_apt_no') . '&nbsp;:&nbsp;' . ucwords($order[0]->floor_or_apt) . ', ' : '';
                                $billAddressString .= trim($order[0]->building) ? $this->lang->line('gkpos_building') . '&nbsp;:&nbsp;' . ucwords($order[0]->building) . ', ' : '';
                                $billAddressString .= trim($order[0]->house) ? ucwords($order[0]->house) . '&nbsp;' : '';
                                $billAddressString .= trim($order[0]->street) ? ucwords($order[0]->street) . ', ' : '';
                                $billAddressString .= trim($order[0]->city) ? ucwords($order[0]->city) . ', ' : '';
                                $billAddressString .= trim($order[0]->postcode) ? ucwords($order[0]->postcode) : '';
                                echo $billAddressString;
                                ?>
                            </td>
                        </tr>
                    <?php endif; ?>
                    <tr>
                        <td colspan="2">
                            <table class="table table-responsive table-bordered table-bg-color-white">
                                <tr>
                                    <td class="text-center"><a href='javascript:void(0)'  style="padding: 20px; width: 100%;" class="btn btn-warning btn-large gradient" onclick="resendToKitchen('<?php echo $order[0]->id ?>')">RKTC</a></td>
                                    <?php if ($order[0]->paid_status == 1): ?>
                                        <td class="text-center" style="width: 25%;"><a href='javascript:void(0)' onclick="alert('This order already paid')" style="padding: 20px 40px;width: 100%;" class="btn btn-success btn-large gradient">Paid</a></td>
                                    <?php else: ?>
                                        <td class="text-center" style="width: 25%;"><a href='javascript:void(0)'  style="padding: 20px;width: 100%;" class="btn btn-primary btn-large gradient" onclick="payOpener('<?php echo $order[0]->id ?>')">Pay</a></td>
                                    <?php endif; ?>
                                    <td class="text-center" style="width: 25%;">
                                        <?php if ($this->config->item('gk_guest_bill_from_browser') == 'yes'): ?>
                                            <a class="btn btn-primary" style="padding: 20px;width: 100%;" href="javascript:void(0)" onclick="printOnlineGuestBillServer('<?php echo $order[0]->id ?>', '3')"><?php echo $this->lang->line('gkpos_print_guest_bill'); ?></a>
                                        <?php else: ?>
                                            <a class="btn btn-info gradient" style="padding: 20px;width: 100%;" href="javascript:void(0)" onclick="printOnlineGuestBill('<?php echo $order[0]->id ?>', '3')"><?php echo $this->lang->line('gkpos_print_guest_bill'); ?></a>
                                        <?php endif ?>
                                    </td>
                                    <?php if ($order[0]->online_status == 0 || $order[0]->online_status == 2): ?>
                                        <td class="text-center" style="width: 25%;"><span class="btn btn-success gradient" style="padding: 20px 40px; width: 100%;" onclick="showSoloUpdateBlock('soloDeliveryTimeBlock', 'soloOrderRejectedBlock')">ACCEPT</span></td>
                                    <?php endif; ?>
                                    <?php if ($order[0]->online_status == 1): ?>
                                        <td class="text-center" style="width: 25%;"><span class="btn btn-danger gradient" style="padding: 20px 40px; width: 100%;" onclick="showSoloUpdateBlock('soloOrderRejectedBlock', 'soloDeliveryTimeBlock')">REJECT</span></td>
                                    <?php endif; ?>
                                </tr>
                                <tr id="soloDeliveryTimeBlock" style="display: none;" class="show-hide">
                                    <td colspan="4">
                                        <form class="form-horizontal col-lg-12  col-md-12 col-sm-12 col-xs-12" id="soloDeliveryTimeBlockForm">
                                            <div class="form-group">
                                                <div data-toggle="buttons">
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="5"><i class="glyphicon">05</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="10"><i class="glyphicon">10</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="15"><i class="glyphicon">15</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="20"><i class="glyphicon">20</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="25"><i class="glyphicon">25</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="30"><i class="glyphicon">30</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="35"><i class="glyphicon">35</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="40"><i class="glyphicon">40</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="45"><i class="glyphicon">45</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="50"><i class="glyphicon">50</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="55"><i class="glyphicon">55</i></label>
                                                    <label class="btn btn-default btn-circle"><input type="radio" name="delivery_time" value="60"><i class="glyphicon">60</i></label>
                                                </div>
                                                <input type="hidden" name="online_status" value="1">
                                                <input type="hidden" name="id" value="<?php echo $order[0]->id ?>">
                                            </div>
                                            <div id="confirmErrorMessage"></div>
                                            <div><p class="btn btn-danger btn-block" style="width: 100%;height: 60px; padding: 20px 10px" onclick="soloUpdateOnlineOrder('soloDeliveryTimeBlockForm')"><?php echo $this->lang->line('gkpos_numpad_key_enter') ?></p></div>
                                        </form>
                                    </td>
                                </tr>
                                <tr id="soloOrderRejectedBlock" style="display: none;" class="show-hide">
                                    <td colspan="4">
                                        <form class="form-horizontal col-xs-10 col-xs-offset-1" id="soloOrderRejectedBlockForm">
                                            <div class="form-group">
                                                <p><textarea rows="3" placeholder="Reject reason ..." id="SoloRejectMessage" style="width: 100%;color: #000; border-radius:10px; border: none; padding: 10px;" autofocus="true" name="message" class="form-control"></textarea></p>
                                                <input type="hidden" name="online_status" value="2">
                                                <input type="hidden" name="id" value="<?php echo $order[0]->id ?>">
                                                <div style="margin: 20px 0px;"><p class="btn btn-danger btn-block" style="width: 100%;height: 60px; padding: 20px 10px" onclick="soloUpdateOnlineOrder('soloOrderRejectedBlockForm')"><?php echo $this->lang->line('gkpos_numpad_key_enter') ?></p></div>
                                            </div>
                                        </form>
                                    </td>
                                </tr>
                            </table>  
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <table class="table table-bordered text-left table-bg-color-white">
                                <tbody>
                                    <tr class="even">
                                        <td width="70%" style='padding: 2px 4px;'><strong>Name</strong></td>
                                        <td width="10%" style='padding: 2px 4px;'><strong>U.P</strong></td>
                                        <td width="10%" style='padding: 2px 4px; text-align: center;'><strong>Qty</strong></td>
                                        <td width="10%" style='padding: 2px 4px;'><strong>Price</strong></td>
                                    </tr>
                                    <?php if (!empty($items)): ?>
                                        <?php foreach ($items as $item): ?>
                                            <tr class="odd">
                                                <td width="70%" style='padding: 2px 4px;'>
                                                    <?php
                                                    $itemString = isset($item->selection_title) && $item->selection_title != null ? $item->selection_title . '-' . $item->menu_title : $item->menu_title;
                                                    $itemString .= $item->set_items != null ? '<br/><i><strong style="font-size:11px;">Items: </strong>' . $item->set_items . '</i>' : '';
                                                    $itemString .= $item->toppings != null ? '<br/><i><strong style="font-size:10px; text-transform: uppercase;">T/S:</strong>' . $item->toppings . '</i>' : '';
                                                    echo $itemString;
                                                    ?>
                                                </td>
                                                <td width="10%" style='padding: 2px 4px;'><?php echo to_currency($item->price) ?></td>
                                                <td  width="10%" style='padding: 2px 4px;text-align: center;'><?php echo $item->quantity ?></td>
                                                <td width="10%" style='padding: 2px 4px;'><?php echo to_currency($item->price * $item->quantity) ?></td>
                                            </tr>
                                        <?php endforeach; ?>
                                    <?php endif; ?>
                                    <tr class="even">
                                        <td colspan="3" width="80%" style="text-align: right; padding: 2px 4px;"><strong>Subtotal :</strong></td>
                                        <td  width="20%" style="text-align: left; padding: 2px 4px;"><strong><?php echo to_currency($order[0]->order_total) ?></strong></td>
                                    </tr>

                                    <?php if (isset($vat) && $vat > 0): ?>
                                        <tr class="even">
                                            <td colspan="3" width="80%" style="text-align: right;padding: 2px 4px;">VAT(+):</td>
                                            <td width="20%" style="text-align: left; padding: 2px 4px;"><?php echo to_currency($vat) ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php if ($order[0]->cc_fee != null && $order[0]->cc_fee > 0) : ?>    
                                        <tr class="odd">
                                            <td colspan="3" width="80%" style="text-align: right; padding: 2px 4px;">ccFee(+):</td>
                                            <td width="20%" style="text-align: left; padding: 2px 4px;"><?php echo to_currency($order[0]->cc_fee) ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php if ($order[0]->delivery_charge > 0): ?>
                                        <tr class="odd">
                                            <td colspan="3" width="80%" style="text-align: right; padding: 2px 4px;">DeliveryFee(+):</td>
                                            <td width="20%" style="text-align: left; padding: 2px 4px;"><?php echo to_currency($order[0]->delivery_charge) ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php if ($order[0]->bogo_discount != null && $order[0]->bogo_discount > 0) : ?>    
                                        <tr class="odd">
                                            <td colspan="3" width="80%" style="text-align: right; padding: 2px 4px;">Multi Discount(-):</td>
                                            <td width="20%" style="text-align: left; padding: 2px 4px;"><?php echo to_currency($order[0]->bogo_discount) ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php if (isset($discount) && $discount > 0): ?>
                                        <tr class="odd">
                                            <td colspan="3"  width="80%" style="text-align: right;padding: 2px 4px;">Discount(-):</td>
                                            <td  width="20%" style="text-align: left; padding: 2px 4px;"><?php echo to_currency($discount) ?></td>
                                        </tr>
                                    <?php endif; ?>

                                    <tr class="odd">
                                        <td colspan="3"  width="80%" style="text-align: right; padding: 2px 4px;"><strong>Grand Total :</strong></td>
                                        <td width="20%" style="text-align: left; padding: 2px 4px;"><strong><?php echo to_currency($order[0]->grand_total) ?></strong></td>
                                    </tr>

                                    <?php $paidPayments = $payments ?>
                                    <?php if (isset($paidPayments['Cash']['method'])): ?>
                                        <tr>
                                            <td colspan="3"  width="80%" style="text-align: right; padding: 2px 4px;" class="Cash"><?php isset($paidPayments['Cash']['method']) ? print $paidPayments['Cash']['method'] . ':' : '' ?></td>
                                            <td width="20%" style="text-align: left; padding: 2px 4px;" class="CashAmount"><?php isset($paidPayments['Cash']['amount']) ? print to_currency($paidPayments['Cash']['amount']) : '' ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php if (isset($paidPayments['EFT']['method'])): ?>
                                        <tr>
                                            <td colspan="3"  width="80%" style="text-align: right; padding: 2px 4px;" class="EFT"><?php isset($paidPayments['EFT']['method']) ? print $paidPayments['EFT']['method'] . ':' : '' ?></td>
                                            <td style="text-align: left; padding: 2px 4px;" class="EFTAmount"><?php isset($paidPayments['EFT']['amount']) ? print to_currency($paidPayments['EFT']['amount']) : '' ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php if (isset($paidPayments['Cheque']['method'])): ?>
                                        <tr>
                                            <td colspan="3"  width="80%" style="text-align: right; padding: 2px 4px;" class="Cheque"><?php isset($paidPayments['Cheque']['method']) ? print $paidPayments['Cheque']['method'] . ':' : '' ?></td>
                                            <td style="text-align: left; padding: 2px 4px;" class="ChequeAmount"><?php isset($paidPayments['Cheque']['amount']) ? print to_currency($paidPayments['Cheque']['amount']) : '' ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php if (isset($paidPayments['Voucher']['method'])): ?>
                                        <tr>
                                            <td colspan="3"  width="80%" style="text-align: right; padding: 2px 4px;" class="Voucher"><?php isset($paidPayments['Voucher']['method']) ? print $paidPayments['Voucher']['method'] . ':' : '' ?></td>
                                            <td style="text-align: left; padding: 2px 4px;" class="VoucherAmount"><?php isset($paidPayments['Voucher']['amount']) ? print to_currency($paidPayments['Voucher']['amount']) : '' ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php if (isset($paidPayments['online']['method'])): ?>
                                        <tr>
                                            <td colspan="3"  width="80%" style="text-align: right; padding: 2px 4px;" class="Voucher"><?php isset($paidPayments['online']['method']) ? print $paidPayments['online']['method'] . ':' : '' ?></td>
                                            <td style="text-align: left; padding: 2px 4px;" class="VoucherAmount"><?php isset($paidPayments['online']['amount']) ? print to_currency($paidPayments['online']['amount']) : '' ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <?php
                                    $changeDueString = null;
                                    $changeAmount = null;
                                    if ($order[0]->change_due != null && $order[0]->change_due < 0) {

                                        if ($order[0]->pay_tip == 'yes') {
                                            $changeDueString = 'Tips:';
                                        } else {
                                            $changeDueString = 'Paid Back:';
                                        }
                                        $changeAmount = abs($order[0]->change_due);
                                    }
                                    ?>
                                    <tr>
                                        <td colspan="3"  width="80%" style="text-align: right; padding: 2px 4px;" id="billChangeOption"><?php ($order[0]->change_due != null && $order[0]->change_due < 0) ? print $changeDueString : '' ?></td>
                                        <td style="text-align: left; padding: 2px 4px;" id="billChangeAmount"><?php ($order[0]->change_due != null && $order[0]->change_due < 0) ? print to_currency($changeAmount) : '' ?></td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </table>
                <div style="display: none;">
                    <div id="browserGuestBillCopy_<?php echo $order[0]->id ?>" 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 echo strtoupper($order[0]->id) ?></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 (!empty($items)): ?>
                                <?php foreach ($items as $key => $obj): ?>
                                    <tr>
                                        <td style="text-transform: capitalize;text-align: left;width: 60mm ">
                                            <?php echo $obj->quantity ?>&nbsp;&nbsp;
                                            <?php
                                            $dbcItemString = $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; ?>
                            <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($order[0]->order_total) ?></td>
                            </tr>
                            <?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($discount) ?></td>
                                </tr>
                            <?php endif; ?>
                            <?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 echo to_currency($vat) ?></td>
                                </tr>
                            <?php endif; ?>

                            <?php if ($order[0]->cc_fee != null && $order[0]->cc_fee > 0) : ?>    
                                <tr class="odd">
                                    <td style="width: 60mm;text-align: right;padding-right: 3mm;">ccFee:</td>
                                    <td style='width: 20mm;text-align: right;padding-right: 3mm;'><?php echo to_currency($order[0]->cc_fee) ?></td>
                                </tr>
                            <?php endif; ?>
                            <?php if ($order[0]->delivery_charge > 0): ?>
                                <tr class="odd">
                                    <td style="width: 60mm;text-align: right;padding-right: 3mm;">deliveryFee:</td>
                                    <td style='width: 20mm;text-align: right;padding-right: 3mm;'><?php echo to_currency($order[0]->delivery_charge) ?></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($order[0]->grand_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 = $payments ?>
                            <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 style="width: 60mm; text-align: right;padding-right: 3mm;" class="Voucher"><?php isset($paidPayments['online']['method']) ? print $paidPayments['online']['method'] . ':' : '' ?></td>
                                <td style='width: 20mm;text-align: right;padding-right: 3mm;' class="VoucherAmount"><?php isset($paidPayments['online']['amount']) ? print to_currency($paidPayments['online']['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 ($order[0]->change_due != null && $order[0]->change_due < 0) {

                                if ($order[0]->pay_tip == 'yes') {
                                    $changeDueString = 'Tips:';
                                } else {
                                    $changeDueString = 'Paid Back:';
                                }
                                $changeAmount = abs($order[0]->change_due);
                            }
                            ?>
                            <tr>
                                <td style="width: 60mm; text-align: right;padding-right: 3mm;" ><?php ($order[0]->change_due != null && $order[0]->change_due < 0) ? print $changeDueString : '' ?></td>
                                <td style='width: 20mm;text-align: right;padding-right: 3mm;'><?php ($order[0]->change_due != null && $order[0]->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 = $order[0]->online_type ?>
                                            <td colspan="2" style="font-size: 1.2em; width: 40mm; text-transform: uppercase;font-weight: bold; text-align: center;"><?php echo 'Online ' . $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>
                            <tr>
                                <td colspan="2">
                                    <table style="width: 80mm; margin: 0 auto;padding: 0" >
                                        <?php if ($order[0]->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 $order[0]->name ?></td>
                                            </tr>
                                        <?php endif; ?>
                                        <?php if ($order[0]->phone != null): ?>
                                            <tr>
                                                <td colspan="2" style="width: 80mm; font-size: 1em;text-align: center;"><?php echo $this->lang->line('gkpos_phone') ?>:<?php echo $order[0]->phone ?></td>
                                            </tr>
                                        <?php endif; ?>
                                        <?php if ($billOrderType == 'delivery' && $order[0]->postcode != null): ?>
                                            <?php
                                            $billAddressString = '';
                                            $billAddressString .= trim($order[0]->floor_or_apt) ? $this->lang->line('gkpos_floor_or_apt_no') . '&nbsp;:&nbsp;' . ucwords($order[0]->floor_or_apt) . ', ' : '';
                                            $billAddressString .= trim($order[0]->building) ? $this->lang->line('gkpos_building') . '&nbsp;:&nbsp;' . ucwords($order[0]->building) . ', ' : '';
                                            $billAddressString .= trim($order[0]->house) ? ucwords($order[0]->house) . '&nbsp;' : '';
                                            $billAddressString .= trim($order[0]->street) ? ucwords($order[0]->street) . ', ' : '';
                                            $billAddressString .= trim($order[0]->city) ? ucwords($order[0]->city) . ', ' : '';
                                            $billAddressString .= trim($order[0]->postcode) ? ucwords($order[0]->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') ?>&nbsp;:&nbsp;<?php echo date('F j, Y H:i:a', strtotime($order[0]->delivery_time)) ?></td>
                                            </tr>
                                        <?php endif; ?>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div id="payOpener"></div>
            <?php endif; ?>
        </div>
    </div>


<?php endif; ?>
<script type="text/javascript">
    function showSoloUpdateBlock(showBlock, hideBlock) {
        $('#' + showBlock).toggle('slow');
        $('#' + hideBlock).hide();
        if (showBlock == 'soloOrderRejectedBlock') {
<?php if ($this->config->item('is_touch') == 'enable') { ?>
                jsKeyboard.currentElement = $('#soloRejectMessage');
<?php } ?>
        }

    }
    function soloUpdateOnlineOrder(fromIdentity) {
        
        var myform = document.getElementById(fromIdentity);
        var formdata = new FormData(myform);
        $.ajax({
            url: '<?php echo site_url('gkpos/report/update') ?>',
            data: formdata,
            cache: false,
            processData: false,
            contentType: false,
            type: 'POST',
            dataType: 'json',
            beforeSend: function () {
                $('#GkposAjaxPageLoader').toggle('slow');
            },
            success: function (output) {
                if (output.success) {
                    getPage('<?php echo site_url('gkpos/online_solo_order/' . $order[0]->id) ?>');
                } else {
                    alert(output.message);
                }
            },
            complete: function (xhr, status) {
                $('#GkposAjaxPageLoader').toggle('slow');
            }
        });
    }
    function printOnlineGuestBill(order_id, status) {
        
        $.ajax({
            url: "<?php echo site_url('gkpos/orders/print_guest_bill'); ?>",
            data: {
                order_id: order_id,
                status: status
            },
            type: "POST", dataType: "json", success: function (output) {
                if (output.success) {
                    alert('Print sent successfully');
                } else {
                    alert('There some problem');
                }
            }
        });

    }
    function printOnlineGuestBillServer(order_id, status) {
        
        $.ajax({
            url: "<?php echo site_url('gkpos/orders/update_guest_bill_status'); ?>",
            data: {
                order_id: order_id,
                status: status
            },
            type: "POST", dataType: "json", success: function (output) {
                if (output.success) {
                    if ($("#browserGuestBillCopy_" + order_id).length > 0) {
                        $("#browserGuestBillCopy_" + order_id).printThis();
                    }
                } else {
                    alert('There some problem');
                }

            }
        });
    }
    function payOpener(id) {
        $.ajax({
            url: '<?php echo site_url('gkpos/payopen') ?>',
            type: 'POST',
            data: {
                id: id
            },
            success: function (output) {
                $('#payOpener').html(output);
                if ($('.payAndClose').length > 0) {
                    jQuery(".payAndClose").colorbox({inline: true, slideshow: false, scrolling: false, height: "auto", open: true, width: '76%', left: "12%", right: "12%"});
                    return false;
                }
            }
        });
    }
    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('Order sent to kitchen succesfully');
                } else {
                    alert('Order sending to kitchen failed, try again');
                }
            }
        });
    }
</script>
<script>
  $(document).ready(function(){
      manageWindowHeight();
  });
</script>
