Wednesday, March 6, 2019

Laravel from_date & to_date report generate.

HTML

<div class="content-wrapper">
    <!-- Main content -->
    <section class="content">
      <div class="row">
        <!-- left column -->
        <div class="col-md-12">
          <!-- general form elements -->
          <div class="box box-primary boxbg">
<div class="box-header with-border">
<div class="box-tools pull-right">
<button class="btn btn-success" id="show"><i class="fa fa-angle-down" aria-hidden="true"></i>  </button>
<button style="display: none" class="btn btn-success" id="hidden"><i class="fa fa-angle-up" aria-hidden="true"></i> </button>
</div>
<h4>Filter</h4>
            </div>
       
<div id="searchBox" class="box-body">
<div class="col-sm-12 col-md-12">
<div class="col-sm-5 col-md-5">
<label class="col-sm-3 col-md-4 control-label">From Date</label>
<div class="col-sm-8 col-md-8">
<input type="text" class="form-control dateFiled" placeholder="Select From Date" id="from_date">
</div>
</div>
<div class="col-sm-5 col-md-5">
<label class="col-sm-3 col-md-4 control-label">To Date</label>
<div class="col-sm-8 col-md-8">
<input type="text" class="form-control dateFiled" placeholder="Select To Date" id="to_date">
</div>
</div>
<div class="col-sm-1 col-md-1">
<input type="button" id="filter" class="btn btn-primary btn-sm" value="Filter">
</div>
</div>
</div>


          </div>
        </div><!--/.col (left) -->

      </div>   <!-- /.row -->
 
  <div class="row">
        <div class="col-xs-12">
          <div class="boxbg">
            <div class="box-body">
<h4 align="center"><?php echo $page_title;?></h4>

            <table class="table table-bordered">
                <thead>
<tr>
<th width="60%">Account</th>
<th width="20%">Debit</th>
<th width="20%">Credit</th>
</tr>
                </thead>
                <tbody id="reportTable">
                </tbody>                 
            </table>

            </div>
          </div>
        </div>
      </div> 
 
    </section><!-- /.content -->
  </div><!-- /.content-wrapper -->


JS

<script type="text/javascript">

jQuery(function(){

$( "#show" ).click(function() {
$( "#hidden" ).toggle();
$( "#show" ).toggle();
$( "#searchBox" ).slideToggle(800);
});

$( "#hidden" ).click(function() {
$( "#hidden" ).toggle();
$( "#show" ).toggle();
$( "#searchBox" ).slideToggle(800);
});


$('#filter').on('click', function(){
var from_date = $('#from_date').val();
var to_date = $('#to_date').val();

$.ajax({
url : "<?php echo base_url();?>accounts/report/TrialBalance",
type : "POST",
dataType : "JSON",
data : {
"from_date" : from_date,
"to_date" : to_date,
},
success : function(response){
var tableFormat = "";
var totalDebit = 0;
var totalCredit = 0;
$.each(response, function(key, value){
// console.log(value);

tableFormat += "<tr>";
tableFormat += "<td>"+value.title+"</td>";



if(value.balance == 'debit' || value.total_debit > '0.00'){
var totalAmount = value.total_debit - value.total_credit;

if(totalAmount < 0) {
tableFormat += "<td>0.00</td>";
tableFormat += "<td>"+Math.abs(totalAmount).toFixed(2)+"</td>";
totalCredit += Math.abs(totalAmount);
}else{
tableFormat += "<td>"+Math.abs(totalAmount).toFixed(2)+"</td>";
tableFormat += "<td>0.00</td>";
totalDebit += Math.abs(totalAmount);
}

}else if(value.balance == 'credit' || value.total_credit > '0.00'){
var totalAmount = value.total_credit - value.total_debit;

if(totalAmount < 0) {
tableFormat += "<td>"+Math.abs(totalAmount).toFixed(2)+"</td>";
tableFormat += "<td>0.00</td>";
totalDebit += Math.abs(totalAmount);
}else{
tableFormat += "<td>0.00</td>";
tableFormat += "<td>"+Math.abs(totalAmount).toFixed(2)+"</td>";
totalCredit += Math.abs(totalAmount);
}

}


// tableFormat += "<td>"+totalAmount+"</td>";
// tableFormat += "<td>0.00</td>";

tableFormat += "</tr>";

})

tableFormat += "<tr style='background:#eaeaea'><td>Total</td><td>"+totalDebit+"</td><td>"+totalCredit+"</td></tr>";



$('#reportTable').html(tableFormat);

}
})
})

});

</script>

No comments:

Post a Comment

Ajax load lage with laravel.

 step-1:  HTML <div class="row">                     <div class="col-lg-12">                           <d...