 
        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>Budget</h3>
                </div>
            </div>
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Add <?php echo $this->account_model->id_('head',$type,'id')['name']; ?> Budget</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content ">
                  <style>
                 .form-control{
                     font-size: 12px;
                     padding:0px;
                 }
                  </style>
                    <form  action="<?php echo $base_url; ?>account/savebudget" method="post" >
                    <input type="hidden" name="date1" value="<?php echo $date1; ?>" >
                    <input type="hidden" name="date2" value="<?php echo $date2; ?>" >
                    <input type="hidden" name="main_head" value="<?php echo $type; ?>" >
                     <table id="myDataTable" class="table table-bordered table-responsive">
                    <thead>
                    <tr>
                    
                    <th>#</th>
                    <th>Head</th>
                    <?php foreach ($date as $key => $value) { ?>
                        <th class="th"><input type="hidden" name="month[]" value="<?php echo  $value['month']; ?>"><?php echo date('y-F',strtotime($value['month'])); ?> </th>
                   <?php  } ?>
                    <th>Total</th>
                    
                    </tr>
                    </thead>
                    <tbody>
                    <?php  foreach ($head as $key => $value) { ?>
                    <tr>
                    <td><?php echo $key++; ?></td>
                    <td><input  type="hidden" name="income[<?php echo $key; ?>][head]" value="<?php echo $value['id']; ?>" /> <?php echo $value['name']; ?></td>
                    <?php $i=0; foreach ($date as $n => $dat) { 
                    if($edit!=null){ 
                       $v=$this->account_model->findbudget($value['id'],$dat['month']);
                      } ?>
                    <td><input value="<?php echo @$v; ?>" name="income[<?php echo $key; ?>][price][]" class="form-control num price-hr price-hr<?php echo $key;?> price-vr price-vr<?php echo $i; ?>" data-vr="<?php echo $i; ?>" data-id="<?php echo $key ?>" /></td>
                    <?php $i++; } ?>
                    <td><input class="form-control total total<?php echo $key ?>"  readonly name="total" ></td>
                    </tr>

                    <?php  } ?>
                    <tr><td></td><td>Total</td><?php foreach ($date as $key => $value) { ?><td class="totaldown<?php echo $key; ?>"></td><?php } ?><td><input readonly class="form-control finaltotal" value="0"  /> </td></tr>
                    </tbody>
                    </table>
                    
                     <div class="ln_solid"></div>
                      
                      <div class="form-group">
                     
                        <div class="col-md-6 col-md-offset-3">
                       
                    
                          <button id="EntrySubmit" type="submit" class="btn btn-success pull-right">Add</button>
                         

                        </div>
                        
                          </div>
                          </div>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
         <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>  
        
         <script>
         $(document).ready(function(){

          setTimeout(function(){
             $('.price-hr').trigger('keyup');
             $('.price-vr').trigger('keyup');
              }, 1000);



         $('body').removeClass('nav-md');
         $('body').addClass('nav-sm');

            $(document).on('keyup','.price-hr',function(){
                
                var id=$(this).attr('data-id');
                var total=calculatepricevr(id);
                $('.total'+id).val(total);
                 var to=calculate_total();
                $('.finaltotal').val(to);
                
                    });
                function calculatepricevr(id){
                var Total = 0;
                //console.log('.price-vr'+id);
                $.each($('.price-hr'+id),function(i,v){
                var val = $(v).val();
                if(val=="")
                val = 0;
                Total += parseFloat( val );
                });
                return Total;

                }
          $(document).on('keyup','.price-vr',function(){               
                var id=$(this).attr('data-vr');
               var total=update_vertical(id);
                $('.totaldown'+id).html(total);
          });

          function update_vertical(id) {
              var Total = 0;
                
                $.each($('.price-vr'+id),function(i,v){
                var val = $(v).val();
                if(val=="")
                val = 0;
                Total += parseFloat( val );
                });
                return Total;
          }
          function calculate_total(){
            var total=0;
             $.each($('.total'),function(i,v){
                var val = $(v).val();
                if(val=="")
                val = 0;
                total += parseFloat( val );
                });
                return total;
          }

          

         });
         </script>