                <html>
    <head>
        <title><?php echo $b_header['title']; ?></title>
         <style>
            @media print
            {
                * {-webkit-print-color-adjust:exact;}
                @page {margin:0in 0.10in 0in 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-5{width:5%;}
            .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:4px transparent #18a05e;
                
                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,h4,p{
                color:#191970;
                font-family:calibri;
                text-align:center;
            }
            .boxed{color:#000000;width:80%;margin:0 auto;}
            .header{
                width:100%;
                border-bottom:4px solid #191970;            
            }
            .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 #000;
                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;
            }
            .tbl1
            {
                border: 1px solid #000;
                text-align:center;
                width:100%;
                min-height:20px;
            }
            th{
                font-size: 12px;
                border: 1px solid #000;
                  border-right: 0px;
                border-bottom: 0px; 
                background-color:#ccccb3; 
                padding: 3px !important;
            }
            td{
                font-size:12px;
                border: 1px solid #000;
                text-align: left;
                  border-right: 0px;
                border-bottom: 0px; 
                padding: 2px !important;
            }
            .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>
    </head>
    <body class="clear">
        <?php date_default_timezone_set("Asia/Karachi"); ?>
        <div class="super_container">
            <div class="page_break clear">
                <div class="watermark_wrapper">
                    <div class="watermark"></div>
                </div>
                <div class="super_wrapper">
                    <div class="wrapper left2 left">
                        <div class="header">
                            <div class="wd-100 clear">
                                <div class=" text-left left ">
                                    <img src="<?php echo base_url().$b_header['logo1']; ?>" style="width:50px;height:50px;">
                                </div>
                                <div class=" text-left right ">
                                    <img src="<?php echo base_url().$b_header['logo2']; ?>" style="width:50px;height:50px;">
                                </div>
                                <div style="">
                                     <center><h2 style="color:#000000"><?php echo $b_header['title']; ?></h1></center>
                                    <center><h3 style="color:#000 !important;"><i><?php echo $b_header['tagline']; ?></i></h3></center>
                                    <!--<center><i><h3 style="color:#000 !important;font-weight:normal;"><?php echo $b_header['short_address']; ?></h3></i></center>-->
                                    <!--<center><h4>Contact# <?php //echo $b_header['phone_no']; ?> / <?php //echo $b_header['email']; ?></h4></center>-->
                                    <center><h3 class="boxed" style="margin-top:0px !important;font-size:23px;">Balance Sheet</h3></center>
                                </div>
                            </div>
                          
                             <div class="wd-100 clear">
                        <div class=" text-left left ">
                            <p style="font-size:18px;color: #000000;margin-right:20px "><b>Start Date: </b><?php echo date('d-m-Y', strtotime($from));?></p>
                            <?php
                            if(!empty($comment))
                            {
                                ?>
                                <p style = "font-size:18px;color: #000000;margin-right: 60px" ><b > Comments: </b >
                                    <?php echo $comment;?>
                                </p >
                                <?php
                            }
                            ?>
                        </div>

                        <div class=" text-right right ">
                            <p style="font-size:18px;color: #000000"><b>End Date: </b><?php echo date('d-m-Y', strtotime($to));?></p>
                        </div>
                        </div>
                        </div>
                        <div class="body">
                     <table class="tbl1">
     
            <thead>
                <tr>
                     <th>Code</th>
                  <th >Head </th>
                              <th>Amount</th>
        </tr>  
            </thead>
             
                 <tbody>
           <tr>
               <th>200</th>
                  <th>Assets & Prosperities </th>
                              <th></th>
        </tr>   
   <?php
         //  Assets
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><strong>";
                             echo $values['code'];
                              echo"</strong></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><strong>";
                             echo $values['code'];
                              echo"</strong></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 align="right">
                <?php echo "<h4 style='color:#000000'><strong>"."Total"."</strong></h4>";?>
                </td>
                 <td style = "text-align: right;"><strong>
                      <?php echo "<b>".number_format($sm_asst)."</b>";?>
                            </strong></td>
                           </tr>
     
      <?php
         //  Lib
if(!empty($heads_lib))
{
  echo"<tr>";
                           echo"<th><strong>";
                              echo 300; 
                              echo"</strong></th>";
                              
                              echo"<td align='center' style='font-size: 18px;'><strong><strong>";
                              echo "Funds & Liabilities"; 
                              echo"</strong></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><strong>";
                             echo $values['code'];
                              echo"</strong></td>";
                               echo"<td>";
                             echo $values['name'];
                              echo"</td>";
                               echo"<td 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><strong>";
                             echo $values['code'];
                              echo"</strong></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 align="right">
                <?php echo "<h4 style='color:#000000'><strong>"."Total"."</strong></h4>";?>
                </td>
                 <td style = 'text-align: right;'>
                      <?php echo "<b><strong>".number_format($sm_exp)."</strong></b>";?>
                            </td>
                           </tr>
<tr>
      <td></td>
    <td style="font-size: 18px;" align="right">
                <?php echo "<h4 style='color:#000000'><strong>"."Owner's Equity"." </strong></h4>";?>
               </td>
                 <td style = "text-align: right;">
                      <?php 
                      
                      echo "<b><strong>".number_format($sm_asst-abs($sm_exp))."</strong></b>";
                      ?>
                            </td>
                           </tr>
              </tbody>             
        </table>
                  </div>
                 
                </div>
              </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
</div>
    </div>

       <script>
        window.print();
    </script>
  </body>
</html>