<fieldset style="margin-top:0px; margin-bottom: 100px; padding-bottom: 0px; border-radius: 0px 0px 10px 10px">
    <div class="row report-row">
        <div id="entireReport">
            <table class="table table-responsive table-bordered" id="reportTableContent">
                <tr class="first-row table-bg-color">
                    <td colspan="4" style="border: none;">&nbsp;</td>
                    <td colspan="3" class="text-center text-capitalize" style="border: none;">Tendered</td>
                    <td colspan="5" style="border: none;">&nbsp;</td>
                </tr>
                <tr class="table-bg-color">
                    <th class="text-center text-capitalize">Date</th>
                    <th class="text-center text-capitalize">Type</th>
                    <th class="text-center text-capitalize">Total</th>
                    <th class="text-center text-capitalize">Cash</th>
                    <th class="text-center text-capitalize">EFT</th>
                    <th class="text-center text-capitalize">Cheq</th>
                    <th class="text-center text-capitalize">Vouch</th>
                    <th class="text-center text-capitalize">Web</th>
                    <th class="text-center text-capitalize">Tips</th>
                    <th class="text-center text-capitalize">Tips</th>
                    <th class="text-center text-capitalize">cFee</th>
                    <th class="text-center text-capitalize">Update</th>
                </tr>
                <?php
                $total_grand = 0;
                $total_cash = 0;
                $total_eft = 0;
                $total_cheque = 0;
                $total_voucher = 0;
                $total_online = 0;
                $total_cash_tips = 0;
                $total_eft_tips = 0;

                $cash_table = 0;
                $cash_collection = 0;
                $cash_delivery = 0;
                $cash_waiting = 0;
                $cash_bar = 0;
                $cash_online = 0;


                $eft_table = 0;
                $eft_collection = 0;
                $eft_delivery = 0;
                $eft_waiting = 0;
                $eft_bar = 0;
                $eft_online = 0;

                $cheque_table = 0;
                $cheque_collection = 0;
                $cheque_delivery = 0;
                $cheque_waiting = 0;
                $cheque_bar = 0;
                $cheque_online = 0;

                $voucher_table = 0;
                $voucher_collection = 0;
                $voucher_delivery = 0;
                $voucher_waiting = 0;
                $voucher_bar = 0;
                $voucher_online = 0;

                $tips_table = 0;
                $tips_delivery = 0;
                $tips_collection = 0;
                $tips_waiting = 0;
                $tips_bar = 0;
                $tips_online = 0;

                $count_table = 0;
                $count_collection = 0;
                $count_delvery = 0;
                $count_waiting = 0;
                $count_bar = 0;
                $count_online = 0;
                $table_guest_served = 0;
                $total_cc_fee = 0;
                ?>
                <?php if (!empty($orderList)): ?>
                    <?php foreach ($orderList as $obj): ?>
                        <tr class="table-bg-color-white table-content">
                            <td class="text-center text-capitalize"><?php echo date($this->config->item('dateformat'), strtotime($obj->created)) ?></td>
                            <td class="text-center text-capitalize"><?php echo $obj->order_type ?></td>
                            <td class="text-center text-capitalize"><?php
                                echo to_currency($obj->grand_total);
                                $total_grand += $obj->grand_total
                                ?></td>
                            <?php
                            $payments = $this->Report_Model->get_order_paymentscool($obj->id);
                            $cash = isset($payments['Cash']) ? ($payments['Cash']['amount']) : 0;
                            $eft = isset($payments['EFT']) ? ($payments['EFT']['amount']) : 0;
                            $cheque = isset($payments['Cheque']) ? ($payments['Cheque']['amount']) : 0;
                            $voucher = isset($payments['Voucher']) ? ($payments['Voucher']['amount']) : 0;
                            $online = isset($payments['online']) ? ($payments['online']['amount']) : 0;

                            if ($cash > 0 && $obj->change_due < 0 && $obj->pay_tip == 'yes') {
                                $cash = $cash;
                            }
                            if ($cash > 0 && $obj->change_due < 0 && $obj->pay_tip == 'no') {
                                $cash = $cash + $obj->change_due;
                            }
                            if ($cash == 0 && $eft > 0 && $obj->change_due < 0 && $obj->pay_tip == 'yes') {
                                $eft = $eft;
                            }
                            if ($cash == 0 && $eft > 0 && $obj->change_due < 0 && $obj->pay_tip == 'no') {
                                $eft = $eft + $obj->change_due;
                            }

                            $total_cash += $cash;
                            $total_eft += $eft;
                            $total_cheque += $cheque;
                            $total_voucher += $voucher;
                            $total_online += $online;
                            if ($obj->order_type == 'table') {
                                $cash_table += $cash;
                                $eft_table += $eft;
                                $cheque_table += $cheque;
                                $voucher_table += $voucher;
                            }
                            if ($obj->order_type == 'collection') {
                                $cash_collection += $cash;
                                $eft_collection += $eft;
                                $cheque_collection += $cheque;
                                $voucher_collection += $voucher;
                            }
                            if ($obj->order_type == 'delivery') {
                                $cash_delivery += $cash;
                                $eft_delivery += $eft;
                                $cheque_delivery += $cheque;
                                $voucher_delivery += $voucher;
                            }
                            if ($obj->order_type == 'waiting') {
                                $cash_waiting += $cash;
                                $eft_waiting += $eft;
                                $cheque_waiting += $cheque;
                                $voucher_waiting += $voucher;
                            }
                            if ($obj->order_type == 'bar') {
                                $cash_bar += $cash;
                                $eft_bar += $eft;
                                $cheque_bar += $cheque;
                                $voucher_bar += $voucher;
                            }
                            if ($obj->order_type == 'online') {
                                $cash_online += $cash;
                                $eft_online += $eft;
                                $cheque_online += $cheque;
                                $voucher_online += $voucher;
                            }
                            ?>

                            <?php
                            $cash_tips = 0;
                            $eft_tips = 0;
                            if ($obj->change_due < 0 && $obj->pay_tip == 'yes') {
                                if (isset($payments['Cash']) && !isset($payments['EFT'])) {
                                    $cash_tips = abs($obj->change_due);
                                }
                                if (!isset($payments['Cash']) && isset($payments['EFT'])) {
                                    $eft_tips = abs($obj->change_due);
                                }
                                if (isset($payments['Cash']) && isset($payments['EFT'])) {
                                    $cash_tips = abs($obj->change_due);
                                }
                                if (!isset($payments['Cash']) && !isset($payments['EFT'])) {
                                    $cash_tips = abs($obj->change_due);
                                }
                            } else {
                                if ($obj->change_due < 0 && $obj->pay_tip == 'no') {
                                    
                                }
                            }
                            $total_cash_tips += $cash_tips;
                            $total_eft_tips += $eft_tips;
                            if ($obj->order_type == 'table') {
                                $tips_table += $cash_tips + $eft_tips;
                                $count_table += 1;
                                $table_guest_served += $obj->guest_quantity;
                            }
                            if ($obj->order_type == 'collection') {
                                $tips_collection += $cash_tips + $eft_tips;
                                $count_collection += 1;
                            }
                            if ($obj->order_type == 'delivery') {
                                $tips_delivery += $cash_tips + $eft_tips;
                                $count_delvery += 1;
                            }
                            if ($obj->order_type == 'waiting') {
                                $tips_waiting += $cash_tips + $eft_tips;
                                $count_waiting += 1;
                            }
                            if ($obj->order_type == 'bar') {
                                $tips_bar += $cash_tips + $eft_tips;
                                $count_bar += 1;
                            }
                            if ($obj->order_type == 'online') {
                                $tips_online += $cash_tips + $eft_tips;
                                $count_online += 1;
                            }
                            ?>
                            <td class="text-center text-capitalize"><?php echo to_currency($cash) ?></td>
                            <td class="text-center text-capitalize"><?php echo to_currency($eft) ?></td>
                            <td class="text-center text-capitalize"><?php echo to_currency($cheque) ?></td>
                            <td class="text-center text-capitalize"><?php echo to_currency($voucher) ?></td>
                            <td class="text-center text-capitalize"><?php echo to_currency($online) ?></td>
                            <td class="text-center text-capitalize"><?php echo to_currency($cash_tips) ?></td>
                            <td  class="text-center text-capitalize"><?php echo to_currency($eft_tips) ?></td>
                            <?php $total_cc_fee += $obj->cc_fee; ?>
                            <td  class="text-center text-capitalize"><?php echo to_currency($obj->cc_fee) ?></td>
                            <td class="text-center text-capitalize">
                                <?php if ($eft <= 0): ?>
                                    <img src="<?php echo ASSETS_GKPOS_PATH ?>images/delete.png" width="24px" height="24px" onclick="deleteReportRow('<?php echo $obj->id ?>', '<?php echo $segment ?>')">  |
                                <?php endif; ?>
                                <?php if ($this->config->item('gk_only_online_admin') == 'no'): ?>
                                    <img src="<?php echo ASSETS_GKPOS_PATH ?>images/view.png" width="24px" height="24px" onclick="getBaseAjaxPage('<?php echo site_url('gkpos/orders/indexajax/' . $obj->id) ?>', 'Create Order')">
                                <?php endif; ?>
                            </td>
                        </tr>
                        <!--Prepare Summary data-->
                        <!--End summary-->
                    <?php endforeach; ?>
                <?php else: ?>
                    <tr><td colspan="10">No Orders Found</td></tr>
                <?php endif; ?>
                <tr class="table-bg-color table-content">
                    <td class="text-center text-capitalize">&nbsp;</td>
                    <td class="text-center text-capitalize">All Total</td>
                    <td class="text-center text-capitalize">Total<br/><?php echo to_currency($total_grand) ?></td>
                    <td class="text-center text-capitalize">Cash<br/><?php echo to_currency($total_cash) ?></td>
                    <td class="text-center text-capitalize">EFT<br/><?php echo to_currency($total_eft) ?></td>
                    <td class="text-center text-capitalize">Cheq<br/><?php echo to_currency($total_cheque) ?></td>
                    <td class="text-center text-capitalize">Vouch<br/><?php echo to_currency($total_voucher) ?></td>
                    <td class="text-center text-capitalize">Web<br/><?php echo to_currency($total_online) ?></td>
                    <td class="text-center text-capitalize">Cash<br/><?php echo to_currency($total_cash_tips) ?></td>
                    <td class="text-center text-capitalize">Card<br/><?php echo to_currency($total_eft_tips) ?></td>
                    <td class="text-center text-capitalize">CFee<br/><?php echo to_currency($total_cc_fee) ?></td>
                    <td class="text-center text-capitalize">&nbsp;</td>
                </tr>
                <?php if (!empty($orderList) && $maxCounter > 1): ?>
                    <tr>
                        <td colspan="12">
                            <div class="table-bg-color">
                                <?php if (isset($maxCounter) && $maxCounter > 1): ?>
                                    <div class="main-arrowbg text-center pull-left">
                                        <ul class="pagination">
                                            <?php for ($i = 0; $i < $maxCounter; $i++): ?>
                                                <li <?php $segment == $i ? print'class="active"' : '' ?>><a href="javascript:void(0)" onclick="paginateReport('<?php echo $i ?>')" style="padding: 5px 10px !important"><?php echo $i + 1; ?></a></li>
                                            <?php endfor; ?>
                                        </ul>
                                    </div>
                                <?php endif ?>
                            </div>
                        </td>
                    </tr>
                <?php endif; ?>
            </table>

            <table class="table table-responsive table-bordered" id="printDetailedArea">
                <tr class="first-row table-bg-color">
                    <td colspan="9" class="text-center text-capitalize" style="border: none;"><span style="margin-right: 60px;">Summary</span></td>
                </tr>
                <tr class="table-bg-color">
                    <th class="text-center text-capitalize">Type</th>
                    <th class="text-center text-capitalize">Served</th>
                    <th class="text-center text-capitalize">Guest Served</th>
                    <th class="text-center text-capitalize">Cash</th>
                    <th class="text-center text-capitalize">EFT</th>
                    <th class="text-center text-capitalize">Cheque</th>
                    <th class="text-center text-capitalize">Voucher</th>
                    <th class="text-center text-capitalize">Online</th>
                    <th class="text-center text-capitalize">Tips</th>

                </tr>
                <tr class="table-bg-color-white table-content">
                    <td class="text-center text-capitalize">Table</td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($count_table) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($table_guest_served) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cash_table) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($eft_table) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cheque_table) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($voucher_table) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency(0) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($tips_table) ?></td>
                </tr>
                <tr class="table-bg-color-white table-content">
                    <td class="text-center text-capitalize">Collection</td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($count_collection) ?></td>
                    <td class="text-center text-capitalize">------</td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cash_collection) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($eft_collection) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cheque_collection) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($voucher_collection) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency(0) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($tips_collection) ?></td>
                </tr>
                <tr class="table-bg-color-white table-content">
                    <td class="text-center text-capitalize">Delivery</td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($count_delvery) ?></td>
                    <td class="text-center text-capitalize">------</td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cash_delivery) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($eft_delivery) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cheque_delivery) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($voucher_delivery) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency(0) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($tips_delivery) ?></td>
                </tr>
                <tr class="table-bg-color-white table-content">
                    <td class="text-center text-capitalize">Waiting</td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($count_waiting) ?></td>
                    <td class="text-center text-capitalize">------</td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cash_waiting) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($eft_waiting) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cheque_waiting) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($voucher_waiting) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency(0) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($tips_waiting) ?></td>
                </tr>
                <tr class="table-bg-color-white table-content">
                    <td class="text-center text-capitalize">Bar</td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($count_bar) ?></td>
                    <td class="text-center text-capitalize">------</td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cash_bar) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($eft_bar) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cheque_bar) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($voucher_bar) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency(0) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($tips_bar) ?></td>
                </tr>
                <tr class="table-bg-color-white table-content">
                    <td class="text-center text-capitalize">Online</td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($count_online) ?></td>
                    <td class="text-center text-capitalize">------</td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cash_online) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($eft_online) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($cheque_online) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($voucher_online) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($total_online) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($tips_online) ?></td>
                </tr>

                <?php
                $total_tips = $tips_table + $tips_collection + $tips_delivery + $tips_waiting + $tips_bar + $tips_online;
                $final_total_voucher = $voucher_table + $voucher_collection + $voucher_delivery + $voucher_waiting + $voucher_bar + $voucher_online;
                $final_total_eft = $eft_table + $eft_collection + $eft_delivery + $eft_waiting + $eft_bar + $eft_online;
                $final_total_cheque = $cheque_table + $cheque_collection + $cheque_delivery + $cheque_waiting + $cheque_bar + $cheque_online;
                $final_total_cash = $cash_table + $cash_collection + $cash_delivery + $cash_waiting + $cash_bar + $cash_online;
                ?>
                <tr class="table-bg-color table-content">
                    <td class="text-center text-capitalize">Total</td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($count_table + $count_collection + $count_delvery + $count_waiting + $count_bar) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_quantity_decimals($table_guest_served) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($final_total_cash) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($final_total_eft) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($final_total_cheque) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($final_total_voucher) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($total_online) ?></td>
                    <td class="text-center text-capitalize"><?php echo to_currency($total_tips) ?></td>
                </tr>
                <tr class="table-bg-color first-row">
                    <td class="text-center text-capitalize" colspan="3">&nbsp;</td>
                    <td class="text-center text-capitalize" colspan="2">
                        <table class="table table-bordered table-bg-color-white">
                            <tr>
                                <td class="text-left text-capitalize"><strong>Total</strong></td>
                                <td class="text-right" style="border-bottom: 2px double  #000; border-bottom-width:3px;"><strong><?php echo to_currency($total_grand + $total_tips) ?></strong></td>
                            </tr>
                            <tr>
                                <td class="text-left text-capitalize">EFT</td>
                                <td class="text-right"><?php echo to_currency($final_total_eft) ?></td>
                            </tr>

                            <tr>
                                <td class="text-left text-capitalize">Cheque</td>
                                <td class="text-right"><?php echo to_currency($final_total_cheque) ?></td>
                            </tr>
                            <tr>
                                <td class="text-left text-capitalize">Voucher</td>
                                <td class="text-right"><?php echo to_currency($final_total_voucher) ?></td>
                            </tr>
                            <tr>
                                <td class="text-left text-capitalize">Card Tips</td>
                                <td class="text-right"><?php echo to_currency($total_eft_tips) ?></td>
                            </tr>
                            <tr>
                                <td class="text-left text-capitalize">Cash</td>
                                <td class="text-right"><?php echo to_currency($final_total_cash) ?></td>
                            </tr>
                            <tr>
                                <td class="text-left text-capitalize">Cash Tips</td>
                                <td class="text-right"><?php echo to_currency($total_cash_tips) ?></td>
                            </tr>
                            <tr>
                                <td class="text-left text-capitalize">Total Cash</td>
                                <td class="text-right" style="border-style: double;  border-top-color: #000;  border-top-width: 3px;"><?php echo to_currency($final_total_cash + $total_cash_tips) ?></td>
                            </tr>
                            <tr>
                                <td class="text-left text-capitalize">Cash Expense</td>
                                <td class="text-right"><?php echo to_currency($expense) ?></td>
                            </tr>
                            <tr>
                                <td class="text-left text-capitalize">Cash In the Till</td>
                                <?php $cash_in_till = $final_total_cash > 0 ? ($final_total_cash + $total_cash_tips) - $expense : $final_total_cash ?>
                                <td class="text-right" style="border-style: double;  border-top-color: #000;  border-top-width: 3px;"><?php echo to_currency($cash_in_till) ?></td>
                            </tr>
                        </table>
                    </td>
                    <td class="text-center text-capitalize" colspan="4">&nbsp;</td>
                </tr>
            </table>
        </div>
    </div>
</fieldset>
<div class="row report-button-operations">
    <div class="report-button" style="margin: 20px 0px 20px 0px">
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-center text-uppercase btn btn-small btn-info" style="font-size: 10px" onclick="printSelectedArea('entireReport')">Print Report</div>
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-center text-uppercase btn btn-small btn-success" style="font-size: 10px" onclick="printSelectedArea('printDetailedArea')">Print Detail</div>
        <div class="col-lg-3 col-md-3 col-sm-2 col-xs-2 text-center text-uppercase btn btn-small btn-primary" style="font-size: 10px" onclick="printSelectedAreaSummaray('daysSummary')">Print Summary</div>

    </div>
</div>
<div id="summaryHeader" style="display: none;">
    <div id="daysSummary" style="width: 80mm; margin-bottom: 30mm" >
        <p style="text-align: center"><img src="<?php echo UPLOAD_PATH ?>gkpos/logo/<?php echo $this->config->item('gk_logo') ?>" class="center-block"></p>
        <table style="width: 75mm; margin: 0 auto">
            <?php if ($this->config->item('gk_name_show') != null) : ?>
                <tr>
                    <td colspan="4" style="text-align: center;"><h3 style="padding: 0px;margin: 0mm 0mm 0mm 0mm; text-decoration: underline"><?php echo $this->config->item('gk_name') ?></h3></td>
                </tr>
            <?php endif; ?>
            <tr>
                <td style="text-align: left;"><?php echo $this->lang->line('gkpos_date') . ':' ?></td>
                <td colspan="3"  style="text-align: left;"><span id="printClosingDay"><?php echo date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat')) ?></span></td>
            </tr>
            <tr>
                <td style="text-align: left; width: 10mm;"><?php echo $this->lang->line('gkpos_day') . ':' ?></td>
                <td style="text-align: left; width: 10mm;"><?php echo date('D') ?></td>
                <td style="text-align: right; width: 25mm;"><?php echo $this->lang->line('gkpos_closed_by') . ':' ?></td>
                <td style="text-align: left; width: 30mm;" ><?php echo get_user_name($this->session->userdata('gkpos_userid')); ?></td>
            </tr>
            <tr>
            <tr>
                <td colspan="4">
                    <table>
                        <tr>
                            <td colspan="4" style="text-align: center;" ><h3 style="padding: 0px;margin: 0mm 0mm 0mm 0mm; text-decoration: underline"><?php echo $this->lang->line('gkpos_summary') ?></h3></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;"><strong>Total</strong></td>
                            <td style="width: 25mm;  text-align: right; border-bottom: 2px double  #000; border-bottom-width:3px;"><strong><?php echo to_currency($total_grand + $total_tips) ?></strong></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;">EFT</td>
                            <td style="width: 25mm;  text-align: right;"><?php echo to_currency($final_total_eft) ?></td>
                        </tr>

                        <tr>
                            <td style="width: 50mm; text-align: left;">Cheque</td>
                            <td style="width: 25mm;  text-align: right;"><?php echo to_currency($final_total_cheque) ?></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;">Voucher</td>
                            <td style="width: 25mm;  text-align: right;"><?php echo to_currency($final_total_voucher) ?></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;">Card Tips</td>
                            <td style="width: 25mm;  text-align: right;"><?php echo to_currency($total_eft_tips) ?></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;">Cash</td>
                            <td style="width: 25mm;  text-align: right;"><?php echo to_currency($final_total_cash) ?></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;">Cash Tips</td>
                            <td style="width: 25mm;  text-align: right;"><?php echo to_currency($total_cash_tips) ?></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;">Total Cash</td>
                            <td style="width: 25mm;  text-align: right; border-style: double;  border-top-color: #000;  border-top-width: 3px;"><?php echo to_currency($final_total_cash + $total_cash_tips) ?></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;">Cash Expense</td>
                            <td style="width: 25mm;  text-align: right;"><?php echo to_currency($expense) ?></td>
                        </tr>
                        <tr>
                            <td style="width: 50mm; text-align: left;">Cash In the Till</td>
                            <?php $cash_in_till = $final_total_cash > 0 ? ($final_total_cash + $total_cash_tips) - $expense : $final_total_cash ?>
                            <td style="width: 25mm;  text-align: right;border-style: double;  border-top-color: #000;  border-top-width: 3px;"><?php echo to_currency($cash_in_till) ?></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</div>
<?php echo $this->load->view('gkpos/report/day_close') ?>
<script>
    $(document).ready(function () {
        $('#orderType').change(function () {
            if ($(this).val() == 'online') {
                $("#posPayment").hide();
                $('#onlinePayment').show();
            } else {
                $('#onlinePayment').hide();
                $("#posPayment").show();
            }
        });
        jQuery(".closeServiceChargePopup").click(function () {
            jQuery.colorbox.close();
            return false;
        });
        $('.date_filter').datepicker({
            dateFormat: "dd/mm/yy",
            maxDate: "<?php echo date('d/m/Y') ?>"
        });
        $("#closing_date").datepicker({
            dateFormat: "dd/mm/yy",
            maxDate: "<?php echo date('d/m/Y') ?>"
        });
    });
    function filterReport() {
        $('#reportFilterForm').validate({
            submitHandler: function (form) {
                var myform = document.getElementById('reportFilterForm');
                var formdata = new FormData(myform);
                $.ajax({
                    url: $('#reportFilterForm').attr('action'),
                    data: formdata,
                    cache: false,
                    processData: false,
                    contentType: false,
                    type: 'POST',
                    beforeSend: function () {
                        $('#GkposAjaxPageLoader').show();
                    },
                    success: function (response) {
                        if ($("#filterContent").html(response)) {
                            manageWindowHeight();
                        }
                    },
                    complete: function (xhr, status) {
                        $('#GkposAjaxPageLoader').hide();
                    }
                });
            }
        });
    }

    function paginateReport(segment) {
        $.ajax({
            url: "<?php echo site_url('gkpos/report/filter/') ?>" + segment,
            data: {
                start_date: $('#reportStartDate').val(),
                end_date: $('#reportEndDate').val(),
                order_type: $('#filterOrderType').val(),
                pos_method: $('#filterPosMethod').val(),
                online_method: $('#filterOnlineMethod').val(),
                is_by_closing: $('#byClosingDay').is(':checked') ? 'yes' : 'no'
            },
            type: "POST",
            beforeSend: function () {
                $('#GkposAjaxPageLoader').show();
            },
            success: function (response) {
                $('#GkposAjaxPageLoader').hide();
                $("#filterContent").html(response)
                manageWindowHeight();
            }
        });
    }
    function deleteReportRow(id, segment) {
        $.confirm({
            'title': 'Order Delete Warning',
            'message': 'Are you sure? You want to delete this order ',
            'buttons': {
                'Yes': {
                    'class': 'btn btn-danger',
                    'action': function () {
                        $.ajax({
                            url: "<?php echo site_url('gkpos/report/deleteReportRow') ?>",
                            type: "POST",
                            dataType: "json",
                            data: {
                                id: id
                            },
                            success: function (response) {
                                if (response.status) {
                                    paginateReport(segment);
                                }
                            }
                        });
                    }
                },
                'NO': {
                    'class': 'btn btn-success',
                    'action': function () {}
                }
            }
        });
    }
    function closeTheDay() {
        $.ajax({
            url: "<?php echo site_url('gkpos/report/getmaxclosingday') ?>",
            type: "GET",
            dataType: "json",
            success: function (json) {
                if ($('#closing_date').val(json.availableClosingDate)) {
                    jQuery(".DayClose").colorbox({inline: true, slideshow: false, scrolling: false, height: "320px", open: true, width: '100%', maxWidth: '450px', left: "30%"});
                    return false;
                }
            }
        });
    }
    function printSelectedArea(div) {
        var filterStartDate = $("#filterStartDate").val();
        var filterEndDate = $("#filterEndDate").val();
        var header = '<div>';
<?php if ($this->config->item('gk_name_show') != null) { ?>
            header = "<p style='text-align:center; font-weight:bold; text-transform:uppercase; text-decoration:underline;font-size:20px;'><?php echo $this->config->item('gk_name') ?></p>"
<?php } ?>
        header += '<p style="text-align: center"><img src="<?php echo UPLOAD_PATH ?>gkpos/logo/<?php echo $this->config->item('gk_logo') ?>" class="center-block"></p>';
        header += "<p style='text-align:center; font-weight:bold; text-transform:uppercase;'>Report" + filterStartDate + "-" + filterEndDate + "</p>";
        header += '</div>';
        $("#" + div).printThis({
            header: header
        });
    }
    function printSelectedAreaSummaray(div) {
        $("#" + div).printThis();
    }
</script>