<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>



<div class="row">
    <div class="col-sm-12">
        <div class="col-sm-4">
            <div class="small-box padding1010 bdarkGreen">
                <h4 class="bold"><?= lang('Sale_Summary') ?></h4>
                <i class="icon fa fa-heart"></i>
                <h3 class="bold"><?= $this->sma->formatMoney($total_sales->total_amount) ?></h3>
                <p><?= lang('Total_Sales : ').' '. $this->sma->formatMoney($total_sales->total)  ?><br>
                <?= lang('Receive_Amount :').''.$this->sma->formatMoney($total_sales->paid) ?>,<br>
                <?= lang('Vat_Amount :'). ' '. $this->sma->formatMoney($total_sales->tax) ?> <br>
                <?= lang('Due_Amount : ') .''.$this->sma->formatMoney($total_sales->due_amnt)  ?></p>
                </div>
                </div>
            <div class="col-sm-3">
              <div class="small-box padding1010 bpurple">
                 <h4 class="bold"><?= lang('Expense_Summary') ?></h4>
                 <i class="icon fa fa-usd"></i>
                 <h3 class="bold"><?= $this->sma->formatMoney($total_expenses->total_amount) ?></h3>
                 <p class="bold"><?= lang('Total_Expense : ').''.$total_expenses->total ?></p>
                <p>&nbsp;</p>
                </div>
            </div>
                        
            <div class="col-sm-4">
                <div class="small-box padding1010 borange">
                    <h4 class="bold"><?= lang('Purchase_Summary') ?></h4>
                    <i class="icon fa fa-star"></i>
                    <h3 class="bold"><?= $this->sma->formatMoney($total_purchases->total_amount) ?></h3>
                        <p><?= lang('Total_Purchase : ').''.$this->sma->formatMoney($total_purchases->total)  ?><br>
                        <?= lang('Receive_Amount : ').''.$this->sma->formatMoney($total_purchases->paid)  ?><br>
                         <?= lang('Vat_Amount : ') .''.$this->sma->formatMoney($total_purchases->tax)  ?><br>
                        <?= lang('Due_Amount : ') .''.$this->sma->formatMoney($total_purchases->due_amnt)  ?></p>
                    </div>
                </div>
            </div>    
        </div>
            
       <div class="row">
                    <div class="col-sm-12">
                        <div class="col-sm-12">
                            <div class="small-box padding1010 bmGreen">
                                <h4 class="bold"><?= lang('Operation_Summary') ?></h4>
                                <i class="icon fa fa-pie-chart"></i>
                                 
                                
                                 <p class="bold"><?= $this->sma->formatMoney($total_sales->total_amount  - $total_expenses->total_amount - $total_purchases->total_amount) . ' ' . lang('Operation_Summary') ?> </p>
                            </div>
                        </div>
                    </div>
                </div>
     
<ul id="myTab" class="nav nav-tabs no-print">
    
    <li class=""><a href="#payments-con" class="tab-grey"><?= lang('Sales') ?></a></li>
    <li class=""><a href="#quotes-con" class="tab-grey"><?= lang('Expense') ?></a></li>
    <li class=""><a href="#deposits-con" class="tab-grey"><?= lang('Purchase') ?></a></li>
    
</ul>

<div class="tab-content">
    
    <div id="payments-con" class="tab-pane fade in">

        
        
        <script type="text/javascript">
        $(document).ready(function () {
            $('#payform').hide();
            $('.paytoggle_down').click(function () {
                $("#payform").slideDown();
                return false;
            });
            $('.paytoggle_up').click(function () {
                $("#payform").slideUp();
                return false;
            });
        });
        </script>

        <div class="box payments-table">
            <div class="box-header">
               
                
            </div>
            <div class="box-content">
                <h2 class="blue"><i class="fa-fw fa fa-heart-o nb"></i><?=  lang('Sales'); ?>
            </h2>
            <div class="row">
                  <div class="col-lg-12">
               <!--<button id="btnExport" class="dt-button-primary buttons-excel buttons-html5 btn btn-primary" style="float:right;"><span>Excel</span></button>-->
			<button id="btnExportPdf" class="dt-button-primary buttons-excel buttons-html5 btn btn-primary"   style="float:right;" onclick="exportpdf()"><span>Pdf</span></button>
			 
                </div>
            </div>
            	  
                <div class="row">
                    <div class="col-lg-12">
                        
                        <div id="payform">
                         
                        </div>
                        <div class="clearfix"></div>

                        <div class="table-responsive table">
                            <table id="SlRData"
                            class="table table-bordered table-hover table-striped table-condensed reports-table reports-table sa">

                            <thead>
                                <tr>
                            <th><?= lang("date"); ?></th>
                            <th><?= lang("reference_no"); ?></th>
                            <th><?= lang("biller"); ?></th>
                            <th><?= lang("customer"); ?></th>
                            <th><?= lang("product_qty"); ?></th>
                            <th><?= lang("grand_total"); ?></th>
                            <th><?= lang("paid"); ?></th>
                            <th><?= lang("balance"); ?></th>
                            <th><?= lang("payment_status"); ?></th>
                        </tr>
                            </thead>
                            
                            
                            <tbody>
                                
                               <?php 
                               
                                if(!empty($getSales)){
                               foreach($getSales as $row):
                               //print_r($getSales);
                               ?>
                                <tr>
                                    <td><?=$row->date;?></td>
                                    <td><?=$row->reference_no;?></td>
                                    <td><?=$row->biller;?></td>
                                    <td><?=$row->customer;?></td>
                                    <td><?=$row->product_name;?></td>
                                    <td><?=$row->grand_total;?></td>
                                    <td><?=$row->paid;?></td>
                                    <td><?=$row->balance;?></td>
                                    <td><?=$row->payment_status;?></td>
                                    <!--<td colspan="7" class="dataTables_empty"><?= lang('loading_data_from_server') ?></td>-->
                                </tr>
                                
                                <?php endforeach;
                                }
                                ?>
                            </tbody>
                             
                            
                            <tfoot class="dtFilter">
                                <tr class="active">
                            <th><?= lang("Date"); ?></th>
                            <th><?= lang("reference_no"); ?></th>
                            <th><?= lang("biller"); ?></th>
                             <th><?= lang("customer"); ?></th>
                           
                            <th><?= lang("product_qty"); ?></th>
                            <th><?= lang("grand_total"); ?></th>
                            <th><?= lang("paid"); ?></th>
                            <th><?= lang("balance"); ?></th>
                            <th><?= lang("payment_status"); ?></th>
                        </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>



<div id="quotes-con" class="tab-pane fade in">
  
  
    <div class="box">
        
        <div class="box-content">
            <div class="row">
                <div class="col-lg-12">
                   
            <h2 class="blue"><i class="fa-fw fa fa-heart-o nb"></i><?=  lang('Expense'); ?>
            </h2>
             <div class="row">
                  <div class="col-lg-12">
            <!--<button id="btnExport1" class="dt-button buttons-excel buttons-html5 btn btn-primary" style="float:right;"><span>Excel</span></button>-->
			<button id="btnExportPdf1" class="dt-button buttons-excel buttons-html5 btn btn-primary"   style="float:right;" onclick="exportpdf1()"><span>Pdf</span></button>
			</div></div>

                    <div class="table-responsive">
                        <table id="EXPData" class="table table-bordered table-hover table-striped table-condensed reports-table exp">
                            <thead>
                               <tr class="active">
                            <th class="col-xs-2"><?= lang("date"); ?></th>
                            <th class="col-xs-2"><?= lang("reference"); ?></th>
                            <th class="col-xs-2"><?= lang("category"); ?></th>
                            <th class="col-xs-1"><?= lang("amount"); ?></th>
                            <th class="col-xs-3"><?= lang("note"); ?></th>
                           
                        </tr>
                            </thead>
                             <tbody>
                                
                               <?php 
                               
                               if(!empty($getExpense)){
                               foreach($getExpense as $row):
                               //print_r($getSales);
                               ?>
                                <tr>
                                    <td><?=$row->date;?></td>
                                    <td><?=$row->reference;?></td>
                                    <td><?=$row->category;?></td>
                                    <td><?=$row->amount;?></td>
                                    <td><?=$row->note;?></td>
                                   
                                    <!--<td colspan="7" class="dataTables_empty"><?= lang('loading_data_from_server') ?></td>-->
                                </tr>
                                
                                <?php endforeach;
                               }
                                ?>
                            </tbody>
                            <tfoot class="dtFilter">
                                <tr class="active">
                            <th><?= lang("date"); ?></th>
                            <th><?= lang("reference"); ?></th>
                            <th><?= lang("category"); ?></th>
                            <th><?= lang("amount"); ?></th>
                            <th><?= lang("note"); ?></th>

                            
                        </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div id="deposits-con" class="tab-pane fade in">
  
    <div class="box">
        <div class="box-content">
            <div class="row">
                <div class="col-lg-12">
                   
            <h2 class="blue"><i class="fa-fw fa fa-heart-o nb"></i><?=  lang('Purchase'); ?>
            </h2>
            
             <div class="row">
                  <div class="col-lg-12">
             <!--<button id="btnExport2" class="dt-button buttons-excel buttons-html5 btn btn-primary" style="float:right;"><span>Excel</span></button>-->
			<button id="btnExportPdf2" class="dt-button buttons-excel buttons-html5 btn btn-primary"   style="float:right;" onclick="exportpdf2()"><span>Pdf</span></button>
			</div>
			</div>
                    <div class="table-responsive">
                         <table id="PoRData1"
                           class="table table-bordered table-hover table-striped table-condensed reports-table pu">
                        <thead>
                        <tr>
                            <th><?= lang("date"); ?></th>
                            <th><?= lang("reference_no"); ?></th>
                            <th><?= lang("warehouse"); ?></th>
                            <th><?= lang("supplier"); ?></th>
                            <th><?= lang("product_qty"); ?></th>
                            <th><?= lang("grand_total"); ?></th>
                            <th><?= lang("paid"); ?></th>
                            <th><?= lang("balance"); ?></th>
                            <th><?= lang("status"); ?></th>
                        </tr>
                        </thead>
                        <tbody>
                            
                            <?php 
                             if(!empty($getPurchase)){
                            
                            foreach($getPurchase as $row):
                              // print_r($getPurchase);
                               ?>
                            
                        <tr>
                                  <td><?=$row->date;?></td>
                                    <td><?=$row->reference_no;?></td>
                                    <td><?=$row->wname;?></td>
                                    
                                    <td><?=$row->supplier;?></td>
                                     <td><?=$row->iname;?></td>
                                     <td><?=$row->grand_total;?></td>
                                   <td><?=$row->paid;?></td>
                                  <td><?=$row->balance;?></td>
                                    <td><?=$row->status;?></td>
                                    <!--<td colspan="7" class="dataTables_empty"><?= lang('loading_data_from_server') ?></td>-->
                               
                        </tr>
                        
                        <?php endforeach;
                        }
                        ?>
                        </tbody>
                        <tfoot class="dtFilter">
                        <tr class="active">
                            <th><?= lang("Date"); ?></th>
                            <th><?= lang("reference_no"); ?></th>
                            <th><?= lang("warehouse"); ?></th>
                             <th><?= lang("supplier"); ?></th>
                           
                            <th><?= lang("product_qty"); ?></th>
                            <th><?= lang("grand_total"); ?></th>
                            <th><?= lang("paid"); ?></th>
                            <th><?= lang("balance"); ?></th>
                            <th><?= lang("payment_status"); ?></th>
                        </tr>
                        </tfoot>
                    </table>
                </div>
    </div>
</div>
</div>
</div>

</div>

<!-- EXPORT TO EXCEL ENDS HERE -->

<!-- EXPORT TO PDF STARTS HERE -->
<script src="https://cdn.jsdelivr.net/gh/linways/table-to-excel@v1.0.4/dist/tableToExcel.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.22/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
    <script type="text/javascript">
        function exportpdf() {
            html2canvas(document.getElementById('SlRData'), {
                onrendered: function (canvas) {
                    var data = canvas.toDataURL();
                    var docDefinition = {
                        content: [{
                            image: data,
                            width: 500
                        }]
                    };
                    pdfMake.createPdf(docDefinition).download("Operation Summary.pdf");
                }
            });
        }
        
        
        function exportpdf1() {
            html2canvas(document.getElementById('EXPData'), {
                onrendered: function (canvas) {
                    var data = canvas.toDataURL();
                    var docDefinition = {
                        content: [{
                            image: data,
                            width: 500
                        }]
                    };
                    pdfMake.createPdf(docDefinition).download("Operation Summary.pdf");
                }
            });
        }
        
        function exportpdf2() {
            html2canvas(document.getElementById('PoRData1'), {
                onrendered: function (canvas) {
                    var data = canvas.toDataURL();
                    var docDefinition = {
                        content: [{
                            image: data,
                            width: 500
                        }]
                    };
                    pdfMake.createPdf(docDefinition).download("Operation Summary.pdf");
                }
            });
        }
        
    </script>


   <!-- EXPORT TO EXCEL STARTS HERE -->



<script>
    
    $(document).ready(function () {
    $('.sa').DataTable({
        pagingType: 'full_numbers',
    });
});

$(document).ready(function () {
    $('.exp').DataTable({
        pagingType: 'full_numbers',
    });
});


$(document).ready(function () {
    $('.pu').DataTable({
        pagingType: 'full_numbers',
    });
});






</script>


