<html>
    <head>
        <title><?php echo $b_header['title']; ?></title>
      
   
    
    <style>
             @media print
            {
                * {-webkit-print-color-adjust:exact;}
                @page {margin:0.20in 0.10in 0.20in 0in; }
                .super_container
                {
                    page-break-after: always;
                    margin-top:0.25in;
                    position:relative;
                    width:100vw;
                    height:710px;
                }
            }
            body {margin: 0.25in 0.25in 0.63in 0.25in; box-sizing:border-box;width:100vw; height:100vh;padding-bottom:0.63in;}
            *{margin:0;padding:0;font-family:calibri;}
            .clear:after{content:"";clear:both;display:block;}
            .left{float:left;}
            .right{float:right;}
            .wd-10{width:10%;}
            .wd-20{width:20%;}
            .wd-30{width:30%;}
            .wd-40{width:40%;}
            .wd-50{width:50%;}
            .wd-60{width:60%;}
            .wd-70{width:70%;}
            .wd-80{width:80%;}
            .wd-90{width:90%;}
            .wd-100{width:100%;}
            .wd-15{width:15%;}
            .wd-25{width:25%;}
            .wd-35{width:35%;}
            .wd-45{width:45%;}
            .wd-55{width:55%;}
            .wd-65{width:65%;}
            .wd-75{width:75%;}
            .wd-85{width:85%;}
            .wd-95{width:95%;}
            .wd-100{width:100%;}
            .title{font-size:35px;}
            .super_container
            {
                margin-bottom:200px;
                position:relative;
                width:100vw;
                height:710px;
            }
            .wrapper{
                border:2px transparent #0e2746;
                
                outline-offset: 5px;
                box-sizing: border-box;
                padding:5px;
            }
            .super_wrapper
            {
                position:absolute;
                top:0;
                left:0;
                width:100%;
                z-index:120;
                margin:0;
                padding:0;
            }
            /*.watermark*/
            /*{*/
            /*    height:200px;*/
            /*    width:300px;*/
            /*    margin:auto;*/
            /*    padding-top:50px;*/
            /*    padding-left:100px;*/
            /*    opacity:0.1;*/
            /*    background:url("<?php echo base_url().$b_header['logo1']; ?>");*/
            /*    background-size:100% 100%;*/
            /*}*/
            /*.watermark_wrapper*/
            /*{*/
            /*    height:470px;*/
            /*    width:100%;*/
            /*    margin-top:50px;*/
            /*    display:inline-flex;*/
            /*    display:-webkit-inline-flex;*/
            /* }*/
            .wrapper.left2{
                width: calc(90vw);
                margin-right: 20px;
                margin-left: 20px;
            }
            h1,h2,h3{
                color:black;
                font-family:calibri;
                text-align:center;
            }
            .boxed{color:#000000;width:80%;margin:0 auto;}
            .header{
                width:100%;
                           
            }
            .body{
                padding:10px;
            }
            .row{
                width:100%;
                margin: 0px auto;  
            }
            .text-center{text-align:center;}
            .bold{font-weight:bold;}
            .b-u-l{
                border-bottom: 1px solid #0e2746;
                height:inherit;
            }
            .x-small{
                font-size: 12px;
            }
            .x-x-small{
                font-size: 9px;
            }
            .page_break{
                width: 100vw;
                height: 100vh;
                padding: 10px 0px;
                box-sizing: border-box;
            }
           
            th{
                border: 1px solid #000;
                 border-right: 0px;
                background-color:LightGray; 
                padding: 1px !important;
                font-size: 13px;
            }
            td{
                border: 1px solid #000;
                 border-right: 0px;
                border-bottom: 0px;
                padding: 1px !important;
                text-align:left;
                font-size: 13px;
            }
            .normal{
                font-weight: normal !important;
            }
            .text-right{
                text-align: right !important;
            }
            .text-left{
                text-align: left !important;
            }
            .margin-a{margin: 30px auto 0px auto;}
        </style>
    <body>

        <div class="super_container">
        <div class="container-fluid">
          <div class="row header">
              <div class="col-md-12 col-sm-12 col-xs-12">
                  <div class="row">
                      <div class="col-md-1 col-sm-2 col-xs-2 text-left" ><img class="logo" src="<?php echo base_url().$b_header['logo1']; ?>" width="100px" height="100px"></div>
                      <div class="col-md-10 col-sm-9 col-xs-9 text-center" style="margin-top:-50px;">
                            <h2 class="wd-100"><?php echo $b_header['title']; ?></h2>
                            <h3 class="wd-100"><?php echo $b_header['tagline']; ?></h3>
                      </div>
                      <div class="col-md-1 col-sm-2 col-xs-2 text-right" style="margin-top:-100px;"><img class="logo" src="<?php echo base_url().$b_header['logo1']; ?>" width="100px" height="100px"></div>
                      <div class="col-md-12 col-sm-12 col-xs-12">
                             <div class="col-md-4 col-sm-4 col-xs-4 text-left">
                                <h3> </h3>
                             </div>
                             
                             <div class="col-md-4 col-sm-4 col-xs-4 text-center">
                                <h2><u><?php echo "Balance Sheet"; ?></u></h2>
                             
                             </div>
                              <div class="col-md-4 col-sm-4 col-xs-4 text-center">
                                <h5> <u> <?php echo "<b>From</b>: ".$newDate = date("d-m-Y", strtotime($from)); ?></u>
                                  <u> <?php echo "<b>To</b> ".$newDate = date("d-m-Y", strtotime($to)); ?></u></h5>
                      </div>
                  </div>  
              </div>
          </div>


 <div class="row header">
    <div>
 <table id="datatable-buttons" class="table table-striped table-bordered nowrap" style="width:100%;border: 2px solid #000;" >
  <thead>
                <tr>
                     <td style="font-size: 17px;">
                            Code
                              </td>
                  <td style="font-size: 17px;">
                            Head
                              </td>
                              <td style="font-size: 17px;">Amount</td>
        </tr>  
            </thead>
             
                 <tbody>
           <tr>
               <td>
                           200
                              </td>
                  <td style="text-align:center">
                            Assets & Prosperities
                              </td>
                              <td></td>
        </tr>   
   <?php
         //  Lib
if(!empty($heads))
{
  $sm_inc=0;$sm_exp=0;$sm_asst=0;   
   $datefrm = str_replace('/', '-', $from);
   $datefrom= date('Y-m-d', strtotime($datefrm));
   
   $datet = str_replace('/', '-', $to);
   $dateto= date('Y-m-d', strtotime($datet));
   
   $branch=$this->user_model->getbranch();
    foreach($heads as $key=>$values)
    {               
         $fetch_level_1=$this->db->select('*')
                             ->from('transction')
                             ->where('head',$values['id'])
                             ->where('date >=',$datefrom)
                             ->where('date <=',$dateto)
                             ->where('branch',$branch)
                             ->limit(1)
                             ->order_by('id','desc')
                             ->get()->row_array();
                             
                 if(!empty($fetch_level_1))
                                {
                             echo"<tr>";
                            
                            echo"<td>";
                             echo $values['code'];
                              echo"</td>";
                               echo"<td>";
                             echo $values['name'];
                              echo"</td>";
                               echo"<td style='text-align:right'>";
                            $sm_asst=$sm_asst+$fetch_level_1['after_transction'];
                            echo number_format($fetch_level_1['after_transction']);
                              echo"</td>";
                              echo "</tr>";
                             }else
                             {
                   $op_bln=$this->db->select('*')
                                    ->from('opening_balance')
                                    ->where('branch',$branch)
                                    ->where('head',$values['id'])
                                    ->get()->row_array();
                            if(!empty($op_bln)) 
                            {
                                if($op_bln['has_cr']==0)
                                {
                                   $tut=0-$op_bln['amount'];
                                }else
                                {
                                    $tut=$op_bln['amount'];
                                }
                                
                              echo"<tr>";
                             echo"<td>";
                             echo $values['code'];
                              echo"</td>";
                               echo"<td>";
                             echo $values['name'];
                              echo"</td>";
                               echo"<td style='text-align:right'>";
                               $sm_asst=$sm_asst+$tut;
                            echo number_format($tut);
                              echo"</td>";
                              echo "</tr>";
                              
                            }
                               
                             }
                         
             }
    }
       ?> 
              <tr>
                  <td>
                      
                  </td>
               <td style="text-align:right">
                <?php echo "<b>"."Total"."</b>";?>
                </td>
                 <td  style="text-align:right">
                      <?php echo number_format($sm_asst);?>
                            </td>
                           </tr>
     
      <?php
         //  Lib
if(!empty($heads_lib))
{
  echo"<tr>";
                           echo"<td >";
                              echo 300; 
                              echo"</td>";
                              
                              echo"<td style='text-align:center;'>";
                              echo "Funds & Liabilities"; 
                              echo"</td>";
                               echo"<td>";
                             
                              echo"</td>"; 
                              echo "</tr>";
    $branch=$this->user_model->getbranch();
    foreach($heads_lib as $key=>$values)
    {               
         $fetch_level_1=$this->db->select('*')
                             ->from('transction')
                             ->where('head',$values['id'])
                             ->where('date >=',$datefrom)
                             ->where('date <=',$dateto)
                             ->where('branch',$branch)
                             ->limit(1)
                             ->order_by('id','desc')
                             ->get()->row_array();
                 if(!empty($fetch_level_1))
                                {
                             echo"<tr>";
                             echo"<td>";
                             echo $values['code'];
                              echo"</td>";
                               echo"<td>";
                             echo $values['name'];
                              echo"</td>";
                               echo"<td style='text-align:right'>";
                            $sm_exp=$sm_exp+$fetch_level_1['after_transction'];
                             echo number_format($fetch_level_1['after_transction']);
                              echo"</td>";
                              echo "</tr>";
                             }else
                             {
                   $op_bln=$this->db->select('*')
                                    ->from('opening_balance')
                                    ->where('branch',$branch)
                                    ->where('head',$values['id'])
                                    ->get()->row_array();
                            if(!empty($op_bln)) 
                            {
                                if($op_bln['has_cr']==0)
                                {
                                   $tut=0-$op_bln['amount'];
                                }else
                                {
                                    $tut=$op_bln['amount'];
                                }
                                
                              echo"<tr>";
                             echo"<td>";
                             echo $values['code'];
                              echo"</td>";
                               echo"<td>";
                             echo $values['name'];
                              echo"</td>";
                               echo"<td style='text-align:right'>";
                               $sm_exp=$sm_exp+$tut;
                            echo number_format($tut);
                              echo"</td>";
                              echo "</tr>";
                              
                            }
                               
                             }
                         
             }
    }
       ?> 
       
       
      <tr>
            <td></td>
               <td style="text-align:right">
                <?php echo "<b>"."Total"."</b>";?>
                </td>
                 <td style="text-align:right">
                      <?php echo number_format($sm_exp);?>
                            </td>
                           </tr>
<tr>
      <td></td>
    <td style="text-align:right">
                <?php echo "<b>"."Owner's Equity"."</b>";?>
                </td>
                 <td  style="text-align:right">
                      <?php echo number_format($sm_asst-abs($sm_exp));?>
                            </td>
                           </tr>
   </table>   
 </div>
</div>

 <script>window.print();</script>
 <!-- Datatables -->
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/jszip/dist/jszip.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/vfs_fonts.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-scroller/js/datatables.scroller.min.js"></script>
    
         <!-- Datatables -->
 
<script>

$(document).ready(function(){
         
            $(document).ajaxStart(function() {
                $('#ajaxload').show();
            });
            
            
        // $('#datatable-buttons').DataTable();
   $.ajax({
    url: '<?php echo base_url(); ?>admin/fetch_user/',data: {},
         success: function (result) {
            
      $(document).ajaxStop(function() {
           $('#ajaxload').hide();
      });
        
        
             console.log(result);
              $("#datatable-buttons").dataTable().fnDestroy();
               setTimeout(function(){
               
               $("tbody.center").html(result);
                $("#datatable-buttons").DataTable({
                "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
                "pageLength": 10,
              dom: "lBfrtip",
              
              "bPaginate": true,
               
             buttons: [
                 {
                  extend: "print",
                  className: "btn-sm",
                   exportOptions: {
                       <?php  if($this->user_model->is_super()){ ?>
                        columns: [0,1,2,3,4,5,6,7],
                       <?php }else{?>
                       columns: [0,1,2,3,4,5,6],
                       <?php }?>
                        modifier: {
                            selected: true
                        }
                    }
                },
                {
                  extend: "copy",
                  className: "btn-sm",
                  exportOptions: {
                       <?php  if($this->user_model->is_super()){ ?>
                        columns: [0,1,2,3,4,5,6,7],
                       <?php }else{?>
                       columns: [0,1,2,3,4,5,6],
                       <?php }?>
                        modifier: {
                            selected: true
                        }
                    }
                },
                {
                  extend: "csv",
                  className: "btn-sm",
                  exportOptions: {
                       <?php  if($this->user_model->is_super()){ ?>
                        columns: [0,1,2,3,4,5,6,7],
                       <?php }else{?>
                       columns: [0,1,2,3,4,5,6],
                       <?php }?>
                        modifier: {
                            selected: true
                        }
                    }
                },
                {
                  extend: "excel",
                  className: "btn-sm",
                  exportOptions: {
                       <?php  if($this->user_model->is_super()){ ?>
                        columns: [0,1,2,3,4,5,6,7],
                       <?php }else{?>
                       columns: [0,1,2,3,4,5,6],
                       <?php }?>
                        modifier: {
                            selected: true
                        }
                    }
                },
                {
                extend: 'pdfHtml5',
                className: "btn-sm",
                title: '',
                exportOptions: {
                       <?php  if($this->user_model->is_super()){ ?>
                        columns: [0,1,2,3,4,5,6,7],
                       <?php }else{?>
                       columns: [0,1,2,3,4,5,6],
                       <?php }?>
                        modifier: {
                            selected: true
                        }
                    }
                },
              ],
              responsive: true
            });
            },500);
           }
     });//end ajax for loading form


});
</script>
    </body>
</html>

