<style>
    .table thead tr th{
        border-top:2px solid #000;
        border-bottom:2px solid #000;
        background: #fcfcfc;
    }
     .table tfoot tr th{
        border-top:2px solid #000;
        border-bottom:2px solid #000;
        background: #fcfcfc;
    }
     tr.strikethrough > td {text-decoration:line-through !important; color:red;} 
      a[href]:after {
        content: none !important;
      }
     
    @media print{
         @page {
          size: auto;
        }
        @page {size: landscape;}
        
    }
</style>
<div class="wrapper">
    <div class="container-full">
        <div class="row m-t-20">
            <div class="col-md-12">
                <div class="panel panel-default m-t-20">
                    <div class="panel-body">
                        
                        <?php if(isset($business[0]['show_cash_reg']) && $business[0]['show_cash_reg']=='No' && $this->session->userdata('role')=="Reception"){ ?>
                        
                        <div class="row">
                            <div col-md-12>
                                <h1>Nothing to Show</h1>
                            </div>
                        </div>
                        <?php } else { ?>
                        <div class="row">
                            <div class="pull-left" >
                                <h3 class="logo invoice-logo"><?php if(isset($business[0]['business_logo'])){ echo "<img src='".base_url().'assets/images/business/'.$business[0]['business_logo']."' alt='".$business[0]['business_name']."' class='img-responsive' />";} else {echo 'SkedWise';}?></h3>
                                
                            </div>
                            <div class="pull-right m-t-20" >
                                <div class="col-md-8 hidden-print m-t-20">
                                    <?php if($this->session->userdata('show_previous')=='Y' || $this->session->userdata('role')=='Admin' || $this->session->userdata('role')=='Super User' || $this->session->userdata('role')=='Accountant' || $this->session->userdata('role')=='Sh-Users' ){?>
                                    <?php if($this->session->userdata('role')=='Sh-Users'){ ?>
                                    <form method="POST" action='<?php echo base_url();?>sh_controller/todaydashboard'>
                                    <?php } else {?>    
                                    <form method="POST" action='<?php echo base_url();?>today_dashboard_controller/index'>
                                    <?php } ?>
                                        <input type="hidden" name="csrf_test_name" id="daily_sheet_csrf" value=""/>
                                        <div class="col-md-4">
                                            <?php if($this->session->userdata('role')!=='Sh-Users'){ ?>
                                            <select class="form-control inline m-r-5"  name="user" id="user">
                                                <option value="All">All</option>
                                                <?php foreach($users as $user){ ?>
                                                <option <?php if($selecteduser == $user['user_name']){ echo "selected: selected";} ?> value="<?php echo $user['user_name']; ?>"><?php echo $user['user_name']; ?></option>
                                                <?php } ?>
                                            </select>
                                            <?php } ?>
                                        </div>
                                        <div class="col-md-4">
                                            
                                            <input type="text" class="form-control inline m-r-5"  placeholder="mm/dd/yyyy" name="calendar_date" id="datepicker-autoclose">
                                            
                                        </div>
                                        <div class="col-md-4">
                                            <button type='submit' onclick="$('#daily_sheet_csrf').val($('#cook').val());" class="btn btn-pink btn-bordred waves-effect w-md waves-light m-b-5">Run</button>
                                        </div>
                                    </form>
                                    <?php } ?>
                                </div>
                                <div class="col-md-4 hidden-print m-t-20">
                                <?php if(DOWNLOAD == true || $this->session->userdata('role') == 'Admin' || $this->session->userdata('role')=='Super User'){ ?>
                                    <a class="btn btn-warning m-l-10" onclick="tableToExcel('sheet1', 'Daily Sheet')" style="float:right">Export to Excel</a>
                                    <a href="javascript:window.print()" class="btn btn-inverse waves-effect waves-light hidden-print pull-right" id="btnprint"><i class="fa fa-print"></i></a>
                                <?php } ?>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                        <!-- end row -->

                        <div class="row">
                            <table class="table m-t-10"  id='sheet1'>
                                <tr>
                                    <td ><strong>Daily Sheet <span style="text-decoration:underline;"> <?php echo isset($date) && !empty($date) ? date('d-m-Y', strtotime($date)) : date('d-m-Y'); ?></span> <span><?php echo $business[0]['business_name'];?></span></strong></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td colspan="3">
                                         <table class="table" border="1" id='tblInvoices'>
                                            <thead>
                                                <tr>
                                                    <th colspan='20'><strong>Invoice Details</strong></th>
                                                </tr>
                                                <tr>
                                                    <th>Inv.ID</th>
                                                    <th>Visit | InService | Invoice</th>
                                                    <th>Customer</th>
                                                    <th>By</th>
                                                    <th>Cash Received</th>
                                                    <th>Cash Return</th>
                                                    <th>Cash</th>
                                                    <th>Card</th>
                                                    <th>Voucher</th>
                                                    <th>Check</th>                                                    
                                                    <th>Gross Sale</th>
                                                    <th>Addition</th>
                                                    <th>Discount</th>
                                                    <th>Retained</th>
                                                    <th>Balance</th>
                                                    <th>Adv.Adj.</th>
                                                    <!--<th>Ret.Adj.</th>-->
                                                    <th>CC.Tip</th>
                                                    <th>Tax</th>
                                                    <th>CC.Fee</th>
                                                    <th>Payments Received</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php $last_id_invoice_detail=0;  $id=0; $cash=0; $card=0; $voucher=0; $check=0; $inv_addition=0; $inv_discount=0; $paid=0;$retained=0; $balance=0;$gross=0; $advanceAdj=0;$recovery=0;$cctip=0; $tax=0;$cccharge=0; $cashretained=0; $retained_adj=0; $price=0; $returnamount=0; $cashreceived=0; $totalRetained=0;
                                                foreach ($invoices as $invoice){ ?>
                                                <?php if($selecteduser == $invoice['created_by'] || $selecteduser=="All"){ if($id !== $invoice['id_invoice']){ ?>
                                                    <tr class="<?php if($invoice['invoice_status']!=='valid'){echo 'strikethrough';}?>">
                                                        <?php if($invoice['invoice_type']=='service'){?>
                                                        <td><b><?php echo '('.$invoice['invoice_seq'].') '.'<a href="'.base_url().'existinginvoice/'.$invoice['id_invoice'].'" target="_blank">'.$invoice['id_invoice'].'</a>'; ?></b></td>
                                                        <?php } else if ($invoice['invoice_type']=='sale'){?>
                                                        <td><b><?php echo '('.$invoice['invoice_seq'].') '.'<a href="'.base_url().'existingorderinvoice/'.$invoice['id_invoice'].'" target="_blank">'.$invoice['id_invoice'].'</a>'; ?></b></td>
                                                        <?php } ?>
                                                        <td><b><?php if($invoice['invoice_status']!=='valid'){echo 'Cancelled ';}?><?php if($invoice['reference_invoice_number']!==''){echo '<span class="text-danger"> Recovery '.$invoice['visit_date'] .' | '.$invoice['invoice_time'];}else {echo $invoice['visit_time'].' | '.$invoice['inservice_time'] .' | '. $invoice['invoice_time'];}?></b></td>
                                                        <td><b><?php echo $invoice['customer_name']; ?></b></td>
                                                        <td><b><?php echo $invoice['created_by']; ?></b></td>
                                                        <?php if($invoice['payment_mode']!="Mixed"){?>
                                                        <?php $tempcash = $invoice['paid_cash']>0 ? $invoice['paid_cash']+$invoice['returnamount']: $invoice['paid_cash'];?>
                                                        <?php } else { ?>
                                                        <?php $tempcash = $invoice['paid_cash'];?>
                                                        <?php } ?>                                                        
                                                        <td><b><?php if($tempcash != null){ echo number_format($tempcash,2);} ?></b></td>                                                        
                                                        <td><b><?php if($invoice['returnamount'] != null){echo number_format($invoice['returnamount'],2); } ?></b></td>
                                                        <td><b><?php if($invoice['paid_cash'] != null){echo number_format($invoice['paid_cash'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['paid_card'] != null){echo number_format($invoice['paid_card'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['paid_voucher'] != null){echo number_format($invoice['paid_voucher'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['paid_check'] != null){echo number_format($invoice['paid_check'],2);} ?></b></td>
                                                        <td style="text-align: right;"><b><?php if($invoice['reference_invoice_number']==''){echo number_format($invoice['sub_total'],2);} ?></b></td>
                                                        <td><b>0.00<?php //if($invoice['reference_invoice_number']==''){echo number_format($invoice['invoice_addition'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['reference_invoice_number']==''){echo number_format($invoice['invoice_discount'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['retained_amount']!=null){echo number_format($invoice['retained_amount'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['reference_invoice_number']==''){echo number_format($invoice['balance'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['reference_invoice_number']==''){echo number_format($invoice['advance_amount'],2);} ?></b></td>
                                                        <!--<td><b><?php // if($invoice['reference_invoice_number']==''){echo number_format($invoice['retained_amount_used'],2);} ?></b></td>-->
                                                        <td><b><?php if($invoice['reference_invoice_number']==''){echo number_format($invoice['cctip'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['reference_invoice_number']==''){echo number_format($invoice['tax_total'],2);} ?></b></td>
                                                        <td><b><?php if($invoice['reference_invoice_number']==''){echo number_format($invoice['cc_charge'],2);} ?></b></td>
                                                        <td style='text-align: right;'><b><?php echo number_format($invoice['paid_amount'] + $invoice['retained_amount'],2); ?></b></td>
                                                    </tr>
                                                <?php 
                                                    if($invoice['invoice_status']=='valid'){
                                                        $paid=$paid+ $invoice['paid_amount']; 
                                                        if($invoice['payment_mode']=="Mixed"){ 
                                                             $cashreceived = $invoice['paid_cash'] > 0 ? $cashreceived + $invoice['paid_cash']: $cashreceived + $invoice['paid_cash'];
                                                        } else { 
                                                            $cashreceived = $invoice['paid_cash'] > 0 ? $cashreceived + $invoice['paid_cash']+$invoice['returnamount'] : $cashreceived + $invoice['paid_cash'];
                                                        } 
                                                        $returnamount=$returnamount + $invoice['returnamount'];
                                                        $cash = $cash + $invoice['paid_cash'];
                                                        $card=$card+ $invoice['paid_card']; 
                                                        $voucher=$voucher+ $invoice['paid_voucher']; 
                                                        $check = $check + $invoice['paid_check'];
                                                        $tax = $tax + $invoice['tax_total'];
                                                        $cccharge = $cccharge + $invoice['cc_charge'];
                                                        $totalRetained = $totalRetained+ $invoice['retained_amount'];
                                                        if($invoice['paid_cash']>0){
                                                            $cashretained = $cashretained + $invoice['retained_amount'];                                                            
                                                        }
                                                        if($invoice['reference_invoice_number']==''){$gross = $gross + $invoice['sub_total'];}
                                                        if($invoice['reference_invoice_number']==''){$inv_addition=$inv_addition + $invoice['invoice_addition'];}
                                                        if($invoice['reference_invoice_number']==''){$inv_discount=$inv_discount + $invoice['invoice_discount'];}
                                                        //$inv_discount=$inv_discount + $invoice['discount'];}  
                                                        $retained=$retained+$invoice['retained_amount'];
                                                        if($invoice['reference_invoice_number']==''){$balance=$balance + $invoice['balance'];}
                                                        if($invoice['reference_invoice_number']==''){$advanceAdj=$advanceAdj + $invoice['advance_amount'];}
                                                        if($invoice['reference_invoice_number']==''){$cctip=$cctip + $invoice['cctip'];}
                                                        
    //                                                    if($invoice['reference_invoice_number']==''){$retained_adj=$retained_adj + $invoice['retained_amount_used'];}
                                                    }
                                                }?>
                                                <tr class="<?php if($invoice['invoice_status']!=='valid'){echo 'strikethrough';}?>">
                                                    <?php if($invoice['invoice_type']=='service'){?>
                                                        <?php if($last_id_invoice_detail !== $invoice['id_invoice_details']){?>
                                                        <td colspan="3" style="text-align: right;"> <?php echo $invoice['staff']; ?></td>
                                                        <td colspan="7" style="text-align: right; "><?php echo $invoice['service']; ?></td>
                                                        <td style='text-align: left;'><?php echo number_format($invoice['price']- $invoice['service_addition'],2);  ?></td>
                                                        <td><?php echo number_format($invoice['service_addition'],2); ?></td>
                                                        <td><?php echo number_format($invoice['discount'],2); ?></td>
                                                        <td colspan="6"></td>
                                                       
                                                        <!--changing to paid of invoice details--> 
                                                        <td style='text-align: left;'><?php echo number_format($invoice['paid_details'],2); 
                                                        if($invoice['invoice_status']=='valid' && $invoice['reference_invoice_number']==''){$inv_discount=$inv_discount + $invoice['discount'];}
                                                        ?></td>
                                                        <?php } else { ?>
                                                        <td colspan="3" style="text-align: right;"> <?php echo $invoice['staff']; ?></td>
                                                        <td colspan="7" style="text-align: right; "><?php echo $invoice['service']; ?></td>
                                                        <td style='text-align: left;'></td>
                                                        <td></td>
                                                        <td colspan="6"></td>
                                                        <!--<td style='text-align: left;'><?php //echo number_format($invoice['price'] -  $invoice['discount'],2); ?></td>-->
                                                        <!--changing to paid of invoice details--> 
                                                        <td style='text-align: left;'></td>
                                                        
                                                        <?php } $last_id_invoice_detail = $invoice['id_invoice_details'];?>
                                                    <?php } else { ?>
                                                        <td colspan="3" style="text-align: right;"> <?php echo $invoice['product_staff']; ?></td>
                                                        <td colspan="7" style="text-align: right; "><?php echo $invoice['product_name']; ?></td>
                                                        <td style='text-align: left;'><?php echo number_format($invoice['product_price'] * $invoice['invoice_qty'] ,2); ?></td>
                                                        <td><?php echo number_format($invoice['product_addition'],2); ?></td>
                                                        <td><?php echo number_format($invoice['product_discount'],2); ?></td>
                                                        <td colspan="6"></td>
                                                        <td style='text-align: left;'><?php echo number_format(($invoice['product_price']*$invoice['invoice_qty']) + $invoice['product_addition'] -  $invoice['product_discount'],2); ?></td>
                                                    <?php } ?>
                                                    <?php 
                                                        $id=$invoice['id_invoice']; 
                                                        if($invoice['reference_invoice_number']==''){$inv_addition=$inv_addition + $invoice['product_addition'];}
                                                        if($invoice['reference_invoice_number']==''){$inv_discount=$inv_discount + $invoice['product_discount'];}
                                                        }                                                    
                                                    } ?>    
                                                </tr>
                                                
                                                <!--Moved invoice headings above training-->
                                                <tr>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td> <!-- Here-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash Received</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash Returned</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Card</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Voucher</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Check</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Gross Sale</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Addition</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Discount</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Retained</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Balance</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Adv.Adj.</b></td>
                                                    <!--<td><b>Ret.Adj.</b></td>-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>CC.Tip</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Tax</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>CC.Fee</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Payments Received</b></td>

                                                </tr>
                                                
                                                
                                                 <?php $paymentreceivedtotal=0;?>
                                                 <tr>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Invoice Breakup:</b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td> <!-- Here-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;" style="text-align: right;" ><b><?php echo number_format($cashreceived,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($returnamount,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($cashreceived - $returnamount,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($card,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($voucher,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($check,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($gross,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($inv_addition,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($inv_discount,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($retained,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($balance,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($advanceAdj,2);?></b></td>
                                                    <!--<th style="text-align: right;" ><b><?php echo number_format($retained_adj,2);?></b></th>-->
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($cctip,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($tax,2);?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($cccharge,2);?></b></td>
                                                    <?php $subtotal = ($cashreceived - $returnamount) +$card+$voucher+$check;?>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($subtotal+$totalRetained,2); $paymentreceivedtotal += $subtotal+$totalRetained;?></b></th>
                                                </tr>
                                                
                                                <!-- end invoices-->
                                                
                                                <?php if($this->session->userdata('role')!=="Sh-Users"){ ?>
                                                <!--Trainings-->
                                                
                                                
                                                <tr>
                                                    <td style="background:#fcfcfc; border-top:2px solid #000;" colspan='20'><strong>Training Details</strong></td>
                                                </tr>
                                                <?php $idtraining=0; $trainingcash=0; $trainingcard=0; $trainingcheck=0;$trainingtotal=0;?>
                                                <?php if(sizeof($trainings)>0){?>
                                                <?php foreach ($trainings as $training){ ?>
                                                <?php //print_r($training['program_name']);?>
                                                <?php if($selecteduser == $training['created_by'] || $selecteduser=="All"){ 
                                                    if($idtraining !== $training['id_program_invoices']){ ?>
                                                <tr>
                                                        <td><?php $paid=$paid+ $training['paid_amount']; echo $training['id_program_invoices']; ?></td>
                                                        <td><?php echo $training['program_name'];?></td>
                                                        <td><?php echo $training['customer_name']; ?></td>
                                                        <td><?php echo $training['created_by']; ?></td>
                                                        <td></td>
                                                        <td></td>
                                                        <td style="text-align: right;"><?php echo number_format($training['paid_cash'],2); $trainingcash=$trainingcash+$training['paid_cash']; ?></td>                                                        
                                                        <td style="text-align: right;"><?php echo number_format($training['paid_card'],2); $trainingcard=$trainingcard+$training['paid_card']; ?></td>
                                                        <td style="text-align: right;">0.00</td>
                                                        <td style="text-align: right;"><?php echo number_format($training['paid_check'],2); ?></td>
                                                        <td style="text-align: right;"><?php echo number_format($training['paid_amount'],2);  $trainingcheck=$trainingcheck+$training['paid_check'];  ?></td>
                                                        <td style="text-align: right;"></td>
                                                        <td style="text-align: right;"></td>
                                                        <td style="text-align: right;"></td>
                                                        <td style="text-align: right;"></td>
                                                        <td style="text-align: right;"></td>
                                                        <!--<td><b><?php // if($invoice['reference_invoice_number']==''){echo number_format($invoice['retained_amount_used'],2);} ?></b></td>-->
                                                        <td style="text-align: right;"></td>
                                                        <td style="text-align: right;"></td>
                                                        <td style="text-align: right;"></td>
                                                        <td style="text-align: right;"><b><?php echo number_format($training['paid_amount'],2); $trainingtotal=$trainingtotal+$training['paid_amount'];?></b></td>
                                                </tr>
                                                <?php $idtraining=$training['id_program_invoices']; }}} ?>
                                                
                                                <!--Training Totals -->
                                                <tr>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td> <!-- Here-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash Received</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash Returned</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Card</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Voucher</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Check</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Gross Sale</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Addition</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Discount</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Retained</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Balance</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Adv.Adj.</b></td>
                                                    <!--<td><b>Ret.Adj.</b></td>-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>CC.Tip</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Tax</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>CC.Fee</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Payments Received</b></td>

                                                </tr>
                                                <tr>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"  ><b>Training Breakup:</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"  ></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td> <!-- Here-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="text-align: right;background:#fcfcfc;  border:1px solid #000;" ><b><?php echo number_format($trainingcash,2);?></b></td>                                                    
                                                    <td style="text-align: right;background:#fcfcfc;  border:1px solid #000;" ><b><?php echo number_format($trainingcard,2);?></b></td>
                                                    <td style="text-align: right;background:#fcfcfc;  border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right;background:#fcfcfc;  border:1px solid #000;" ><b><?php echo number_format($trainingcheck,2);?></b></td>
                                                    <td style="text-align: right;background:#fcfcfc;  border:1px solid #000;" ><b><?php echo number_format($trainingtotal,2);?></b></td>
                                                    <td style="text-align: right;background:#fcfcfc;  border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right;background:#fcfcfc;  border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right; background:#fcfcfc; border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right; background:#fcfcfc; border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right; background:#fcfcfc; border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right; background:#fcfcfc; border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right; background:#fcfcfc; border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right; background:#fcfcfc; border:1px solid #000;" ><b></b></td>
                                                    <td style="text-align: right; background:#fcfcfc; border:1px solid #000;" ><b><?php echo number_format($trainingtotal,2); $paymentreceivedtotal += $trainingtotal;?></b></td>
                                                </tr>
                                                
                                                
                                                <?php } ?>
                                                <!-- Trainings End-->
                                                
                                                
                                                <!-- Advance Start -->
                                                 
                                                <tr>
                                                    <td style="background:#fcfcfc; border-top:2px solid #000;" colspan='20'><strong>Advances Details</strong></td>
                                                </tr>
                                                <?php  $advid=0; $advcash=0; $advcard=0; $advcheck=0;$advtotal=0; $advccfeetotal=0;?>
                                                <?php if(sizeof($advances)>0){?>
                                                <?php foreach ($advances as $advance){ 
                                                    if($selecteduser == $advance['advance_user'] || $selecteduser=="All"){
                                                    if($advid !==$advance['id_customer_visits']){ ?>
                                                        <tr>
                                                            <td></td>
                                                            <td><b>Advance</b></td>
                                                            <td><b><?php echo $advance['customer_name']; ?></b></td>
                                                            <td><b><?php echo $advance['advance_user']; ?></b></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td><b><?php if($advance['advance_mode']=="cash"){ echo $advance['advance_amount']; $advcash=$advcash+$advance['advance_amount'];}  else {echo "0.00";}?></b></td>                                                            
                                                            <td><b><?php if($advance['advance_mode']=="card"){ echo $advance['advance_amount']; $advcard=$advcard+$advance['advance_amount'];}  else {echo "0.00";}?></b></td>
                                                            <td></td>
                                                            <td><b><?php if($advance['advance_mode']=="check"){ echo $advance['advance_amount']; $advcheck=$advcheck+$advance['advance_amount'];}  else {echo "0.00";}?></b></td>
                                                            <td style="text-align: right;"><b><?php echo $advance['advance_amount']; //$gross = $gross +  $advance['advance_amount'];?></b></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td style="text-align: right;"><b><?php if($advance['advance_mode']=="card"){ echo $advance['advance_cc_charge']; } ?></td>
                                                            <td ><?php if($advance['advance_mode']=="card"){ echo $advance['advance_amount']+$advance['advance_cc_charge'];}else { echo $advance['advance_amount'];} if($advance['advance_mode']=="card"){$paid=$paid + $advance['advance_amount']+$advance['advance_cc_charge'];}else {$paid = $paid + $advance['advance_amount'];}?></b></td>
                                                            <?php if($advance['advance_mode']=="card"){$advccfeetotal = $advccfeetotal + $advance['advance_cc_charge'];}?>
                                                        </tr>
                                                         <tr>
                                                            <td colspan="3"></td>
                                                            <td colspan="8" style='text-align:right;'><?php echo $advance['service_category'].' '.$advance['service_name'].' <?php echo CURRENCY_CODE;?>. '.$advance['service_rate']; ?></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td colspan="6"></td>
                                                            <td></td>
                                                        </tr>
                                                    <?php $advtotal=$advtotal + $advance['advance_amount'] + $advance['advance_cc_charge'] ;} else { ?>
                                                        <tr>
                                                            <td colspan="3"></td>
                                                            <td colspan="8" style='text-align:right;'><?php echo $advance['service_category'].' '.$advance['service_name'].' <?php echo CURRENCY_CODE;?>. '.$advance['service_rate']; ?></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td colspan="6"></td>
                                                            <td></td>
                                                        </tr>
                                                <?php }}?>
                                                <?php $advid = $advance['id_customer_visits'];
                                                } ?>
                                                <!-- Advance Totals-->
                                                <tr>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td> <!-- Here-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash Received</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash Returned</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Card</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Voucher</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Check</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Gross Sale</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Addition</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Discount</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Retained</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Balance</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Adv.Adj.</b></td>
                                                    <!--<td><b>Ret.Adj.</b></td>-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>CC.Tip</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Tax</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>CC.Fee</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Payments Received</b></td>

                                                </tr>
                                                <tr>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"  ><b>Advance Breakup:</b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"  ></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></th> <!-- Here-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000;text-align: right;" ><b><?php echo number_format($advcash,2);?></b></th>
                                                    
                                                    <td style="background:#fcfcfc; border:1px solid #000;text-align: right;" ><b><?php echo number_format($advcard,2);?></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($advcheck,2);?></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($advccfeetotal ,2);?></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;" ><b><?php echo number_format($advtotal,2); $paymentreceivedtotal += $advtotal;?></b></th>
                                                </tr>        
                                                        
                                                 <?php } ?>        
                                                <!-- Advance End -->   
                                                
                                                <!--Gift Voucher Start-->
                                                 
                                                <tr>
                                                    <td style="background:#fcfcfc; border-top:2px solid #000;" colspan='20'><strong>Gift Voucher Details</strong></td>
                                                </tr>
                                                <?php  $vouchercash=0; $vouchercard=0; $vouchercheck=0; $vouchertotal=0; $vgross=0; ?>
                                                <?php if(sizeof($vouchers)>0){?>
                                                <?php foreach ($vouchers as $v){ 
                                                    if($selecteduser == $v['created_by'] || $selecteduser=="All"){
                                                    ?>
                                                        <tr>
                                                            <td></td>
                                                            <td><b>Voucher: <?php echo $v['voucher_number'] ?></b></td>
                                                            <td><b><?php echo $v['customer_name']; ?></b></td>
                                                            <td><b><?php echo $v['created_by']; ?></b></td> <!-- Here-->
                                                            <td></td>
                                                            <td></td>
                                                            <td><b><?php echo $v['paid_cash']; $vouchercash=$vouchercash+$v['paid_cash']; $vouchertotal += $v['paid_cash'];?></b></td>
                                                            <td><b><?php echo $v['paid_card'];  $vouchercard=$vouchercard+$v['paid_card'];  $vouchertotal += $v['paid_card'];?></b></td>
                                                            <td></td>
                                                            <td><b><?php echo $v['paid_check']; $vouchercheck=$vouchercheck+$v['paid_check'];  $vouchertotal += $v['paid_check'];?></b></td>
                                                            <td style="text-align: right;"><b><?php echo $v['voucher_value']; $gross=$gross+$v['voucher_value']; $vgross += $v['voucher_value'];?></b></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td style="text-align:right"><?php echo $v['voucher_tax']; $tax=$tax + $v['voucher_tax'];?></td>
                                                            <td style="text-align:right"><?php echo $v['voucher_cccharge']; $cccharge =$cccharge+$v['voucher_cccharge']; ?></td>
                                                            <td ><?php echo $v['voucher_value']+$v['voucher_cccharge']+ $v['voucher_tax']; $paid=$paid+$v['voucher_value']+$v['voucher_cccharge']+ $v['voucher_tax'];?></td>
                                                            
                                                        </tr>
                                                    
                                                <?php } }?>
                                                <!--Voucher totals-->
                                                <tr>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td> <!-- Here-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash Received</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash Returned</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Cash</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Card</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Voucher</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Check</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Gross Sale</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Addition</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Discount</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Retained</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Balance</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Adv.Adj.</b></td>
                                                    <!--<td><b>Ret.Adj.</b></td>-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>CC.Tip</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Tax</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>CC.Fee</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"><b>Payments Received</b></td>

                                                </tr>
                                                <tr>
                                                    <?php $soldvouchertotal=0;?>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"  ><b>Vouchers Breakup:</b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"  ></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td> <!-- Here-->
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000;"></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b><?php echo number_format($vouchercash,2); $soldvouchertotal+=$vouchercash;?></b></td>
                                                    
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b><?php echo number_format($vouchercard,2); $soldvouchertotal+=$vouchercard;?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></th>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b><?php echo number_format($vouchercheck,2); $soldvouchertotal+=$vouchercheck;?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b><?php echo number_format($vgross,2); $soldvouchertotal=$vouchertotal; ?></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b></b></td>
                                                    <td style="background:#fcfcfc; border:1px solid #000; text-align: right;"><b><?php echo number_format($soldvouchertotal,2); $paymentreceivedtotal += $soldvouchertotal;?></b></td>
                                                </tr>
                                                 <?php } ?>        
                                                <!-- Gift Voucher End -->        
                                                 <?php }?>         
                                                <!-- footer heading were here-->
                                                
                                            </tbody>
                                            <tfoot>
                                               
                                                <?php if($this->session->userdata('role')!=="Sh-Users"){ ?>
                                                <!-- Training was here -->
                                                <!-- Advance was here -->
                                                <!-- Vocuher was here -->
                                                
                                                <?php }?>
                                                 <tr>
                                                    
                                                    <th colspan="6" style=" color: brown;"><b>TOTAL :</b></th>
                                                    
                                                    <th style="text-align: right; color: brown" ><b><?php $totalcash=($cashreceived-$returnamount) + $vouchercash + $advcash + $trainingcash; echo number_format($totalcash,2); ?></b></th>                                                    
                                                    <th style="text-align: right; color: brown" ><b><?php $totalcard=$card + $vouchercard + $advcard + $trainingcard; echo number_format($totalcard,2);?></b></th>
                                                    <th style="text-align: right; color: brown" ><b><?php  echo number_format($voucher,2); ?></b></th>
                                                    <th style="text-align: right; color: brown" ><b><?php $totalvoucher=$check + $vouchercheck + $advcheck + $trainingcheck; echo number_format($totalvoucher,2);?></b></th>
                                                    <th style="text-align: right; color: brown" ><b><?php echo number_format($gross+$trainingtotal,2);?></b></th>
                                                    <th style="text-align: right; color: brown" ><b></b></th>
                                                    <th style="text-align: right; color: brown" ><b></b></th>
                                                    <th style="text-align: right; color: brown" ><b></b></th>
                                                    <th style="text-align: right;" ><b></b></th>
                                                    <th style="text-align: right; color: brown" ><b></b></th>
                                                    <th style="text-align: right; color: brown" ><b></b></th>
                                                    <th style="text-align: right; color: brown" ><b><?php echo number_format($tax,2);?></b></th>
                                                    <th style="text-align: right; color: brown" ><b><?php echo number_format($cccharge,2);?></b></b></th>
                                                    <th style="text-align: right; color: brown" ><b><?php echo number_format($paymentreceivedtotal,2);?></b></th>
                                                </tr>
                                                <tr>
                                                    <th></th>
                                                    <th></th>
                                                    <th></th>
                                                    <th></th> <!-- Here-->
                                                    <th></th>
                                                    <th></th>
                                                    <th><b>Cash</b></th>
                                                    <th><b>Card</b></th>
                                                    <th><b>Voucher</b></th>
                                                    <th><b>Check</b></th>
                                                    <th><b>Gross Sale</b></th>
                                                    <th><b>Addition</b></th>
                                                    <th><b>Discount</b></th>
                                                    <th><b>Retained</b></th>
                                                    <th><b>Balance</b></th>
                                                    <th><b>Adv.Adj.</b></th>
                                                    <!--<th><b>Ret.Adj.</b></th>-->
                                                    <th><b>CC.Tip</b></th>
                                                    <th><b>Tax</b></th>
                                                    <th><b>CC.Fee</b></th>
                                                    <th><b>Payments Received</b></th>

                                                </tr>
                                            </tfoot>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="3">
                                        <?php if($selecteduser=="All"){?>
                                        <table class="table" border="1" name='expenses'>
                                            <thead>
                                                <tr><th colspan="3"> <strong class="pull-left">Expenses-(All)</strong></th>
                                                <tr>
                                                    <th>Account</th>
                                                    <th>Account</th>
                                                    <th>Amount</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php $petty_expenses=0; foreach ($expenses as $expense){ ?>
                                                <tr>
                                                    <td><?php echo $expense['account_head']; ?></td>
                                                    <td><?php echo $expense['description'];  ?></td>
                                                    <td style="text-align:right;"><?php echo number_format($expense['voucher_amount'],2); ?></td>
                                                    
                                                    <?php 
                                                        if(strpos(strtoupper($expense['account_head']), 'TILL')>0){
                                                            $petty_expenses= $petty_expenses+$expense['voucher_amount'];  
                                                        }
                                                        ?>
                                                    
                                                </tr>
                                                <?php } ?>
                                            </tbody>
                                            <tfoot>
                                                <th>Total:</th>
                                                <th></th>
                                                <th style="text-align:right;"><?php echo number_format($petty_expenses,2);?></th>
                                            </tfoot>
                                        </table>
                                        <?php } ?>
                                    </td>
                                </tr>
                                <tr><td colspan="3">&nbsp;</td></tr>
                                <tr>
                                    <td> <!--/*cash reconciliation*/-->
                                        <?php if($selecteduser=="All"){?>
                                        <table border="1" class='table table-bordered'>
                                            <tr><td colspan="2"><b><u>Cash Reconciliation:</u></b></td></tr>
                                            <tr>
                                                <td>Today's Cash Received: </td><td style="text-align:right;"><?php echo number_format($totalcash,2);?></td>
                                            </tr>
                                            <tr>
                                                <td>Add: Cash Retained: </td><td style="text-align:right;"><?php echo number_format($cashretained,2);?></td>
                                            </tr>

                                            <tr>
                                                <td>Less: Card Tips </td><td style="text-align:right;"><?php echo number_format($cctip,2);?></td>
                                            </tr>
                                            <tr>
                                                <td>Less: Till Cash Payments</td><td style="text-align:right;"><?php echo number_format($till_expense,2);?></td>
                                            </tr>
<!--                                            <tr>
                                                <td>Add: Advance Received </td><td style="text-align:right;"><?php echo number_format($cashInfo->totalRetained + $cashInfo->totalAdvance,2); ?></td>
                                            </tr>
                                            <tr>
                                                <td>Add: Old Balance Received (Recovery)</td><td style="text-align:right;"><?php if(isset($cashInfo->totalRecovery)){ echo number_format($cashInfo->totalRecovery,2); $recovery=$cashInfo->totalRecovery;} else {echo "0.00";}?></td>
                                            </tr>-->
                                            <tr>
                                                <!--<td><b>Cash in Hand:</b></td><td style="text-align:right;"><b><?php // $cih = $gross-($card+$check+$voucher+$balance+$advanceAdj+$cctip+$till_expense); $cih=$cih+$cashInfo->totalRetained + $cashInfo->totalAdvance + $recovery; echo number_format($cih,2);?>  </b></td>-->
                                                <td><b>Cash in Hand:</b></td><td style="text-align:right;"><b>
                                                    <?php $cih = ($totalcash + $cashretained) - ($till_expense + $cctip);
                                                    echo number_format($cih,2);?>  
                                                    </b>
                                                </td>
                                            </tr>
                                        </table>
                                        <?php } ?>
                                    </td>
                                    <td> <!--/*cash ledger*/-->
                                        <?php if($selecteduser=="All"){?>
                                         <table border="1" class='table table-bordered'>
                                             <?php $pcbal=0; $pcreimbur=0;?>
                                            <tr><td colspan="2"><b><u>Cash Ledger:</u></b></td></tr>
                                            <tr>
                                                <td>Till Cash Balance C/F: </td><td style="text-align:right;"><?php if(isset($yesterdaytill)){echo number_format($yesterdaytill->till_amounts,2); $pcbal=$yesterdaytill->till_amounts;} else { echo '0.00';}?></td>
                                            </tr>
                                            <tr>
                                                <td>Additional Morning Cash: </td><td style="text-align:right;"><?php if(isset($cashregister)){echo number_format($cashregister->cash_addition,2); $pcbal=$pcbal + $cashregister->cash_addition;} else { echo '0.00';}?></td>
                                            </tr>
                                            <tr>
                                                <td>Today Cash Receipt </td><td style="text-align:right;"><?php echo number_format($cih,2);?></td>
                                            </tr>
                                           
                                            <tr>
                                                <td></td><td style="text-align:right;"></td>
                                            </tr>
                                            <tr>
                                                <td></td><td style="text-align:right;"></td>
                                            </tr>
                                            <tr>
                                                <td></td><td></td>
                                            </tr>
                                            <tr>
                                                <td><b>Total:</b></td><td style="text-align:right;"><b><?php echo number_format(($cih+$pcbal)-$pcreimbur,2); ?></b></td>
                                            </tr>
                                        </table>
                                        <?php } ?>
                                    </td>
                                     <?php if($this->session->userdata('role')!=="Sh-Users"){ ?>
                                    <td>
                                        <?php $denominationcash=0;?>
                                        <?php if($selecteduser=="All"){?>
                                        <table border="1" class="table table-bordered" name='cashregister'>
                                            <tbody>
                                                <tr><td colspan="3"><b><u>Denominations:</u></b></td></tr>
                                                <tr>
                                                    <td style="width: 100px;">Opening Till Amount</td>
                                                    <td colspan="2" style=" padding-top: 20px; text_align:right;">
                                                        <?php echo CURRENCY_CODE;?>. <strong ><?php if(isset($pcbal)){echo number_format($pcbal,2);} else { echo '0.00';}?></strong>
                                                    </td>
                                                </tr>
                                                <?php if(isset($cashregister)){?>
                                                <tr>
                                                    <td style="width: 100px;"><?php echo CURRENCY_CODE;?>. 5000</td>
                                                    <td>x <?php echo $cashregister->x5000;?></td>
                                                    <td style="text-align:right"><?php echo number_format(5000* $cashregister->x5000,2); $denominationcash=$denominationcash+ (5000* $cashregister->x5000); ?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 1000</td>
                                                    <td>x <?php echo $cashregister->x1000;?></td>
                                                    <td style="text-align:right"><?php echo number_format(1000* $cashregister->x1000,2); $denominationcash=$denominationcash+ (1000* $cashregister->x1000);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 500</td>
                                                    <td>x <?php echo $cashregister->x500;?></td>
                                                    <td style="text-align:right"><?php echo number_format(500* $cashregister->x500,2); $denominationcash=$denominationcash+ (500* $cashregister->x500);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 100</td>
                                                    <td>x <?php echo $cashregister->x100;?></td>
                                                    <td style="text-align:right"><?php echo number_format(100* $cashregister->x100,2); $denominationcash=$denominationcash+ (100* $cashregister->x100);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 75</td>
                                                    <td>x <?php echo $cashregister->x75;?></td>
                                                    <td style="text-align:right"><?php echo number_format(75* $cashregister->x75,2); $denominationcash=$denominationcash+ (75* $cashregister->x75);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 50</td>
                                                    <td>x <?php echo $cashregister->x50;?></td>
                                                    <td style="text-align:right"><?php echo number_format(50* $cashregister->x50,2); $denominationcash=$denominationcash+ (50* $cashregister->x50);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 20</td>
                                                    <td>x <?php echo $cashregister->x20;?></td>
                                                    <td style="text-align:right"><?php echo number_format(20* $cashregister->x20,2); $denominationcash=$denominationcash+ (20* $cashregister->x20);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 10</td>
                                                    <td>x <?php echo $cashregister->x10;?></td>
                                                    <td style="text-align:right"><?php echo number_format(10* $cashregister->x10,2); $denominationcash=$denominationcash+ (10* $cashregister->x10);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 5</td>
                                                    <td>x <?php echo $cashregister->x5;?></td>
                                                    <td style="text-align:right"><?php echo number_format(5* $cashregister->x5,2); $denominationcash=$denominationcash+ (5* $cashregister->x5);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td><?php echo CURRENCY_CODE;?>. 1</td>
                                                    <td>x <?php echo $cashregister->x1;?></td>
                                                    <td style="text-align:right"><?php echo number_format(1* $cashregister->x1,2); $denominationcash=$denominationcash+ (1* $cashregister->x1);?>  </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2"><b>Denomination total</b></td>
                                                    <td style="text-align:right"><strong ><?php echo number_format($denominationcash,2); ?></strong></td>
                                                </tr>
                                                <tr>
                                                    <td>Tomorrow's Till Amount</td>
                                                    <td colspan="2" style="padding-top: 13px;"><?php echo CURRENCY_CODE;?>. <strong ><?php echo number_format($cashregister->till_amounts,2);?></strong></td>
                                                </tr>
                                                <?php }?>
                                            </tbody>
                                        </table>
                                        <?php } ?>
                                    </td>
                                     <?php } ?>
                                    
                                    
                                </tr>
                        </table>
                    </div>
                    <!-- end row -->
                <?php }?>
         <div class="clearfix"></div>           
    </div>
</div>

<script>
    $(document).ready(function(){   
         $('#datepicker-autoclose').datepicker({
                autoclose: true,
                todayHighlight: true,
                format: 'yyyy-mm-dd'
            });
    });

     var tableToExcel = (function () {
          //  application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            var uri = 'data:application/vnd.ms-excel;base64,'
              , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>'
              , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
              , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
            return function (table, name) {
                if (!table.nodeType) table = document.getElementById(table)
                var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
                var link = document.createElement("a");
                
                var d = new Date();
                var datestring = ("0" + d.getDate()).slice(-2) + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" +
                d.getFullYear() + " " + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2);
    
                link.download = ctx.worksheet + ' ' + datestring;
                link.href = uri + base64(format(template, ctx));
                link.click();
                //window.location.href = uri + base64(format(template, ctx))
            }
        })()
        
</script>