<?php 
  $header_file=APPPATH.'views/include/header.php';
  require($header_file);
  
  ?>

    <!-- BEGIN: Content-->
    <div class="app-content content">
      <div class="content-overlay"></div>
      <div class="content-wrapper">
        <div class="content-header row">
          <div class="content-header-left col-md-12 col-12 mb-2 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-inline-block">Month Report</h3>
            <div class="row breadcrumbs-top d-inline-block">
              <div class="breadcrumb-wrapper col-12">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="#">Home</a>
                  </li>
                  <li class="breadcrumb-item"><a href="#"> Report</a>
                  </li>
                  <li class="breadcrumb-item active">Month Report
                  </li>
                </ol>
              </div>
            </div>
          </div>
        
        </div>
        <div class="content-body"><!-- Zero configuration table -->
<section id="configuration">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
					<form autocomplete="off" method="post" action="<?php echo site_url('ExcelReport/search_MonthReport/');?>">
					
						
							<div class="row justify-content-md-center">
								<div class="col-md-3 mleft">
									<div class="form-body">
										<div class="form-group">
										    <label for="eventInput1">From Date</label>
        									<input type="text" class="form-control num"  name="from_date" id="from_date" required>
        								</div>
        							</div>
								</div>
								<div class="col-md-3 ">
									<div class="form-body">
										<div class="form-group">
										    <label for="eventInput1">To Date</label>
									        <input type="text" class="form-control num"  name="to_date" id="to_date" required>
									    </div>
        							</div>
								</div>
								
								
								<div class="col-sm-2" style="margin-top: 10px;">
									<label for="inputEmail3" class="col-sm-12 control-label"></label>
									<input type="submit" name="submit" id="s_click" class="btn btn-warning pull-right" value="Search" >
								</div>
							</div>
						
					</form>
				
				
				<div class="col-sm-12">
				<div class="table-responsive">
					<?php
						if(isset($_POST['submit'])) {
							if (isset($result_display)) {
								//echo "<p><u>Result</u></p>";
								if ($result_display == 'No record found !') {
									echo $result_display;
									} else {
									    ?>
								<div class="row">
									<div class="col-sm-3">
										<input type="text" name="from_date" id="from_date" class="form-control" readonly value="<?php echo $_POST['from_date']; ?>">
									</div>
									<div class="col-sm-3">	
										<input type="text" name="to_date" id="to_date" class="form-control" readonly value="<?php echo $_POST['to_date']; ?>">
									</div>
									
								
								</div>
										<br/>
							 <table id="example" class="table table-striped table-bordered">
							<thead >
								<tr>
									
    								<th>Date</th>
    								
    								<th>Nill Rate Tax</th>
    								<th>Basic(5%)</th>
    								<th>Basic(12%)</th>
    								<th>Basic(18%)</th>
    								<th>Tax(5%)</th>
    								<th>Tax(12%)</th>
    								<th>Tax(18%)</th>
    								<th>Amt</th>
								</tr>
							</thead>
							<tbody>
								<?php
								$i=0;
								$total_price = 0;
								$zbasic = 0;
								$fbasic = 0;
								$tbasic = 0;
								$ebasic = 0;
								$ftax = 0;
								$ttax = 0;
								$etax = 0;
									//if(isset($result_display) && is_array($result_display) && count($result_display)): $i=1;
										foreach ($result_display as $record) { 
										    
									    $total_price = $total_price + $record['total_amount'];
									if($record['taxp'] == '0') {
									    $zbasic = $zbasic + round($record['basic_amt'],2);
									}
									if($record['taxp'] == '5') {
									    $fbasic = $fbasic + round($record['basic_amt'],2);
									    $ftax = $ftax + round(($record['Tax_5']),2);
									}
									if($record['taxp'] == '12') {
									    $tbasic = $tbasic + round($record['basic_amt'],2);
									    $ttax = $ttax + round(($record['Tax_12']),2);
									}
									if($record['taxp'] == '18') {
									    $ebasic = $ebasic + round($record['basic_amt'],2);
									    $etax = $etax + round(($record['Tax_18']),2);
									}
									?>
									<tr >
										
										<td>
											<span ><?php echo date('d-m-Y',strtotime($record['issue_date'])); ?></span>
										</td>
										
										<td>
										    <span >0</span>
										    
										</td>
										<td>
											<span ><?php	echo $record['Tax_5B']; ?></span>
											
										</td>
										<td>
										<span ><?php 	echo $record['Tax_12B']; ?></span>
										</td>
										<td>
											 <span ><?php 	echo $record['Tax_18B']; ?></span>
											
										</td>
										<td>
											<span ><?php echo $record['Tax_5'];
											//$record['qty']*$record['Tax_5']; ?></span><input type="hidden" id="" class="f_tax" value="<?php echo $record['Tax_5'];//$record['qty']*$record['Tax_5'] ; ?>">
										</td>
										<td>
											<span ><?php 
											echo $record['Tax_12'];//number_format((float)$record['qty']*$record['Tax_12'], 2, '.', '');
											//echo $record['qty']*$record['Tax_12']; ?></span><input type="hidden" id="" class="t_tax" value="<?php echo $record['Tax_12']; //$record['qty']*$record['Tax_12'] ; ?>">
										</td>
										<td>
											<span ><?php echo $record['Tax_18'];//$record['qty']*$record['Tax_18']; ?></span>
											<input type="hidden" id="" class="e_tax" value="<?php echo $record['Tax_18'];//$record['qty']*$record['Tax_18'] ; ?>">
										</td>
										<td >
											<span ><?php 
											echo number_format((float)$record['total_amount'], 2, '.', '');
											//echo $record['total_amount'] ?></span><input type="hidden" id="" class="total" value="<?php echo $record['total_amount']; ?>">
										</td>
										
									</tr>
									<?php
										$i++;
									} ?>
								
								
							   <tr>
    								<td><strong>Total</strong></td>
    								
    							<?php  foreach ($result_display1 as $record1) {  ?>	
    								<td><strong><?php echo $zbasic; ?></strong></td>
    								
    								
    								<td><strong><?php echo $record1['Tax_5_basic']; ?></strong></td>
    								<td><strong><?php echo $record1['Tax_12_basic']; ?></strong></td>
    								<td><strong><?php echo $record1['Tax_18_basic']; ?></strong></td>
    					
    								<td><strong><?php echo $record1['Tax_5']; ?></strong></td>
    								<td><strong><?php echo $record1['Tax_12']; ?></strong></td>
    								<td><strong><?php echo $record1['Tax_18']; ?></strong></td>
    								<td><strong><?php echo round($record1['total_amount'],2); ?></strong></td>
						        <?php } ?>
						        </tr>
						    </tbody>
						</table>
							
								<?php
									
								}
							}		
						} else { ?>	
						
					<?php } ?>
					<br/>
				 </div>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<!--/ Zero configuration table -->



<!--/ Language - Comma decimal place table -->

        </div>
      </div>
    </div>
    <!-- END: Content-->

   <?php //require('include/theme_customizer.php');?>
 <?php 
  $footer_file=APPPATH.'views/include/footer.php';
  require($footer_file);
  ?>
		<script>
		
	$(document).ready(function() {
			$('#example').DataTable( {
			    "ordering": false,
				dom: 'Bfrtip',
					buttons: [
			{
				extend: 'csv',
				exportOptions: {
					columns: [0,1,2,3,4,5,6,7,8]
				}
			},
			{
				extend: 'copy',
				exportOptions: {
					columns: [0,1,2,3,4,5,6,7,8]
				}
			},
			{
				extend: 'excel',
				exportOptions: {
					columns: [0,1,2,3,4,5,6,7,8]
				}
			},
			{
				extend: 'pdf',
				orientation: 'landscape',
				exportOptions: {
					columns: [0,1,2,3,4,5,6,7,8]
				}
			},
			{
				extend: 'print',
				exportOptions: {
					columns: [0,1,2,3,4,5,6,7,8]
				}
			},
			]
			, "displayLength": 100
			, "order": [[0, 'desc']]
			} );
			
			$('#example4').DataTable( {
				dom: 'Bfrtip',
					buttons: [
			{
				extend: 'csv',
				exportOptions: {
					columns: [0,1,2,3]
				}
			},
			{
				extend: 'copy',
				exportOptions: {
					columns: [0,1,2,3]
				}
			},
			{
				extend: 'excel',
				exportOptions: {
					columns: [0,1,2,3]
				}
			},
			{
				extend: 'pdf',
				exportOptions: {
					columns: [0,1,2,3]
				}
			},
			{
				extend: 'print',
				exportOptions: {
					columns: [0,1,2,3]
				}
			},
			]
			, "displayLength": 100
			, "order": [[0, 'desc']]
			} );
			
		} );
		
	
	</script>
	<script>
		$( function() {
			$("#from_date" ).datepicker({ //minDate: 1, 
			dateFormat: 'dd-mm-yy' });
			$("#to_date" ).datepicker({ //minDate: 1, 
			dateFormat: 'dd-mm-yy' });
		});
		
		
		$(document).ready(function() {  
			$("#outlet_name").change(function(){  
				/*dropdown post *///  
				$.ajax({  
					url:"<?php echo  
					base_url();?>index.php/Super_section/buildDropProduct",  
					data: {id:  
					$(this).val()},  
					type: "POST",  
					success:function(data){  
						$("#product_name").html(data);  
					}  
				});  
			});  
		/*	$('#s_click').click(function(){
			
				var pr = $('#product_name').val();
				alert(pr);
			});*/
		});
	</script>
	<script type="text/javascript">
	$( document ).ready(function() {
		var sum1 = 0;
		var sum2 = 0;
		var sum3 = 0;
		var sum4 = 0;
		var sum5 = 0;
		var sum6 = 0;
		var sum7 = 0;
		var sum10=0;
		// we use jQuery each() to loop through all the textbox with 'price' class
		// and compute the sum for each loop
		
		
		$('.z_basic').each(function() {
			sum10 += Number($(this).val());
		});
		var z_sum = (sum10).toFixed(2);
		$('#zbasic').html(z_sum);
		
		$('.f_basic').each(function() {
			sum1 += Number($(this).val());
		});
		var t_sum = (sum1).toFixed(2);
		$('#fbasic').html(t_sum);
		
		//BASIC Amt
		
		$('.t_basic').each(function() {
			sum2 += Number($(this).val());
		});
		var b_sum = (sum2).toFixed(2);
		// set the computed value to 'totalPrice' textbox
		$('#tbasic').html(b_sum);
		
		//CGST
		$('.e_basic').each(function() {
			sum3 += Number($(this).val());
		});
		var c_sum = (sum3).toFixed(2);
		// set the computed value to 'totalPrice' textbox
		$('#ebasic').html(c_sum);
		
		//SGST
		$('.f_tax').each(function() {
			sum4 += Number($(this).val());
		});
		var s_sum = (sum4).toFixed(2);
		// set the computed value to 'totalPrice' textbox
		$('#ftax').html(s_sum);
		
		$('.t_tax').each(function() {
			sum6 += Number($(this).val());
		});
		var s_sum1 = (sum6).toFixed(2);
		// set the computed value to 'totalPrice' textbox
		$('#ttax').html(s_sum1);
		
		$('.e_tax').each(function() {
			sum7 += Number($(this).val());
		});
		var s_sum2 = (sum7).toFixed(2);
		// set the computed value to 'totalPrice' textbox
		$('#etax').html(s_sum2);
		
		//Total
		$('.total').each(function() {
			sum5 += Number($(this).val());
		});
		var s_sum3 = (sum5).toFixed(2);
		// set the computed value to 'totalPrice' textbox
		$('#total_amt').html(s_sum3);
		
		/*var tot_sum = (sum5).toFixed(2);
		var tot_sum1 = Math.round(tot_sum)
		var tot_round = (parseFloat(tot_sum1) - parseFloat(tot_sum)).toFixed(2);
		// set the computed value to 'totalPrice' textbox
		$('#total_amt').html(tot_sum);
		$('#total_round').html(tot_round);
		$('#total_amts').html(tot_sum1);*/
	});
</script>
	<script>
		/*$(window).on('beforeunload', function () {
			//$("input[type=submit], input[type=button]").prop("disabled", "disabled");
			$("input[type=submit]").prop("disabled", "disabled");
			$("#submit").css("background-color","#dcdcdc");
		});*/
	</script>	
</body>
</html>