ria/app/Views/report_sales.php
2025-03-13 16:55:45 +05:30

320 lines
12 KiB
PHP

<script>
$(document).ready(function() {
$("#client").select2();
$("#product").select2();
$("#hsn_number").select2();
});
</script>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
<style>
table{
width:auto;
}
.dataTables_filter input {
padding: 4px;
}
.dataTables_filter {
/* width: 50%; */
float: right;
text-align: right;
}
.dataTables_paginate {
width: 50%;
float: right;
text-align: right;
}
div.dt-buttons {
position: relative;
/* float: right; */
}
</style>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Sales</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title"><b> Sales Report </b></h4>
</li>
</ol>
</div>
</div>
</div>
<?php if(isset($headline)) : if(!empty($headline)) : ?>
<div class="col-12">
<div class="page-title-right">
<span>Result filter by : </span><h4 class="page-title" style="display: inline;"><?php echo $headline; ?></h4>
</div>
</div>
<?php endif; endif; ?>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<!-- <form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;"> -->
<div class="card-body">
<form method="post" action="<?php echo base_url("sales_report"); ?>">
<div class="form-group">
<div class="row">
<div class="col-2">
<label for="from_date">
<?php echo 'From Date'; ?>
</label>
<div class="input-group">
<input name="from_date" id="max-date" class="form-control datepicker" autocomplete="off" value="<?php if(isset($from_date)){ echo $from_date; } ?>">
</div>
</div>
<div class="col-2">
<label for="to_date">
<?php echo 'To Date'; ?>
</label>
<div class="input-group">
<input name="to_date" id="min-date" class="form-control datepicker" autocomplete="off" value="<?php if(isset($to_date)){ echo $to_date; } ?>">
</div>
</div>
<div class="col-2">
<label for="hsn_number">
<?php echo 'HSN'; ?>
</label>
<select class="form-control" id="hsn_number" name="hsn_number">
<option value="">Select HSN</option>
<?php
foreach ($hsn as $val): { ?>
<option <?php if(isset($hsn_number) && ($hsn_number == $val->hsn_or_sac)){ echo 'selected'; } ?> value="<?php echo $val->hsn_or_sac; ?>"><?php echo $val->hsn_or_sac; ?></option>
<?php }
endforeach; ?>
</select>
</div>
<div class="col-3">
<label for="product">
<?php echo 'Products'; ?>
</label>
<select class="form-control" id="product" name="product">
<option value="">Select Product</option>
<?php
foreach ($product as $val): { ?>
<option <?php if(isset($product_id) && ($product_id == $val->product_id)){ echo 'selected'; } ?> value="<?php echo $val->product_id; ?>"><?php echo $val->product_name; ?></option>
<?php }
endforeach; ?>
</select>
</div>
<div class="col-3">
<label for="client">
<?php echo 'Clients'; ?>
</label>
<select class="form-control" id="client" name="client">
<option value="">Select Client</option>
<?php
foreach ($client as $val): { ?>
<option <?php if(isset($client_id) && ($client_id == $val->client_id)){ echo 'selected'; } ?> value="<?php echo $val->client_id; ?>"><?php echo $val->client_name; ?></option>
<?php }
endforeach; ?>
</select>
</div>
<div class="col-md-8"></div>
<div class="col-md-4 text-right">
<input type="button" class="btn btn-danger m-2" value="Reset" onclick="window.location.href='<?= base_url('sales_report') ?>';">
<input type="submit" class="btn btn-success m-2" name="btn_submit" value="View Report">
</div>
</div>
</div>
<div class="form-group has-feedback">
</div>
</form>
<table id="cc" class="table table-bordered table-hover wrap" style="background-color:#fff;width: 100% !important;">
<thead>
<tr>
<th>Invoice Date</th>
<th>Invoice No</th>
<th>Client Name</th>
<th>Product</th>
<th>HSN</th>
<th>Quantity</th>
<th>Rate</th>
<th>Sub Total</th>
<th>GST</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php if (!empty($sales_invoice)) {
$tot = 0; $totGst = 0; $totSubTot = 0;
foreach ($sales_invoice as $invoice) {
$subtotal = $invoice->item_price * $invoice->item_quantity;
// Calculate CGST and SGST
$cgst_amount = ($subtotal * $invoice->cgst) / 100;
$sgst_amount = ($subtotal * $invoice->sgst) / 100;
$total = $subtotal + $cgst_amount + $sgst_amount; ?>
<!-- Main invoice row -->
<tr>
<td><?php echo date('d-m-Y', strtotime($invoice->invoice_date_created)); ?></td>
<td>
<?php if (!empty($invoice->invoice_url)) { ?>
<a href="<?php echo $invoice->invoice_url; ?>" target="_blank" class="invoice-link">
<?php } ?>
<?php echo $invoice->invoice_number; ?>
<?php if (!empty($invoice->invoice_url)) { ?>
</a>
<?php } ?>
</td>
<td><?php echo $invoice->client_name ?></td>
<td><?php echo $invoice->item_name ?></td>
<td><?php echo $invoice->hsn_or_sac ?></td>
<td align="right"><?php echo number_format($invoice->item_quantity, 2, '.', ',') ?></td>
<td align="right"><?php echo number_format($invoice->item_price, 2, '.', ',') ?></td>
<td align="right"><?php echo number_format($subtotal, 2, '.', ',') ?></td>
<td align="right"><?php echo number_format($cgst_amount + $sgst_amount, 2, '.', ',') ?></td>
<td align="right"><?php echo number_format($total, 2, '.', ',') ?></td>
</tr>
<?php
$tot = $total + $tot;
$totGst = ($cgst_amount + $sgst_amount) + $totGst;
$totSubTot = $subtotal + $totSubTot;
} ?>
</tbody>
<tfoot width="100%">
<tr>
<td style="text-align:center;"><strong>Total</strong></td>
<td style="text-align:right"><strong><?php {echo '';}?></strong></td>
<td style="text-align:right"><strong><?php {echo '';}?></strong></td>
<td style="text-align:right"><strong><?php {echo '';}?></strong></td>
<td style="text-align:right"><strong><?php {echo '';}?></strong></td>
<td style="text-align:right"><strong><?php {echo '';}?></strong></td>
<td style="text-align:right"><strong><?php {echo '';}?></strong></td>
<td style="text-align:right"><strong><?php {echo number_format($totSubTot, 2, '.', ','); }?></strong></td>
<td style="text-align:right"><strong><?php {echo number_format($totGst, 2, '.', ','); }?></strong></td>
<td style="text-align:right"><strong><?php {echo number_format($tot, 2, '.', ','); }?></strong></td>
</td>
</tr>
</tfoot>
<?php
}
?>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div>
</div> <!-- container -->
</div> <!-- content -->
</div>
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
<script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script>
// Bootstrap datepicker
// Set up your table
$(document).ready(function() {
// Initialize the DataTable
var table = $('#cc').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv' // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [
[10, 20, 30, 50, -1],
[10, 20, 30, 50, "All"]
], // Rows per page options
responsive: true, // Responsive table
ordering : false,
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
}
});
});
$('#mySelect').on('change', function() {
table
.column(4)
.search(this.value)
.draw();
});
$(function() {
var dateFormat = 'dd-mm-yyyy';
// Initialize min-date (Start Date)
var from = $("#min-date").datepicker({
format: dateFormat,
autoclose: true,
todayHighlight: true,
clearBtn: true,
orientation: 'bottom'
}).on('changeDate', function(e) {
// When a date is selected in #min-date, update the minDate option for #max-date
// to.datepicker('setStartDate', e.date);
});
// Initialize max-date (End Date)
var to = $("#max-date").datepicker({
format: dateFormat,
// startDate: new Date(), // Start date cannot be in the past
autoclose: true,
todayHighlight: true,
clearBtn: true,
orientation: 'bottom'
}).on('changeDate', function(e) {
// When a date is selected in #max-date, update the endDate option for #min-date
from.datepicker('setStartDate', e.date);
});
});
</script>