ria/app/Views/sales_dashboard.php
2024-08-21 10:14:49 +05:30

248 lines
13 KiB
PHP

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<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>
</div>
</div>
<div class="row">
<div class="col-xl-4 col-md-6">
<div class="card">
<div class="card-body" style="height: 150px;">
<h4 class="header-title" style="margin-bottom: 22px;">Today Sales</h4>
<div class="d-flex justify-content-between align-items-center">
<div class="knob-chart" dir="ltr">
<div class="text-left">
<p class="text-muted mb-0">Invoices</p>
<h4 class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_green"><?php echo $today_sales->Invoices ?></span> </h4>
</div>
</div>
<div class="text-left">
<p class="text-muted mb-0">Qty in Kgs</p>
<h4 class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_green"><?php echo $today_sales->Qty ?></span> </h4>
</div>
<div class="text-left">
<p class="text-muted mb-0">Sales in Rs.</p>
<h4 class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_green"><?php echo number_format($today_sales->Sales, 2); ?></span> </h4>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-4 col-md-6">
<div class="card">
<div class="card-body" style="height: 150px;">
<h4 class="header-title" style="margin-bottom: 22px;">This Month Sales</h4>
<div class="d-flex justify-content-between align-items-center">
<div class="knob-chart" dir="ltr">
<div class="text-left">
<p class="text-muted mb-0">Invoices</p>
<h4 class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_bule"><?php echo $this_month_sales->Invoices ?></span> </h4>
</div>
</div>
<div class="text-left">
<p class="text-muted mb-0">Qty in Kgs</p>
<h4 class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_bule"><?php echo $this_month_sales->Qty ?></span> </h4>
</div>
<div class="text-left">
<p class="text-muted mb-0">Sales in Rs.</p>
<h class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_bule"><?php echo number_format($this_month_sales->Sales, 2); ?></span> </h4>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-4 col-md-6">
<div class="card">
<div class="card-body" style="height: 150px;">
<h4 class="header-title" style="margin-bottom: 22px;">This year Sales</h4>
<div class="d-flex justify-content-between align-items-center">
<div class="knob-chart" dir="ltr">
<div class="text-left">
<p class="text-muted mb-0">Invoices</p>
<h4 class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_red"><?php echo $this_year_sales->Invoices ?></span> </h4>
</div>
</div>
<div class="text-left">
<p class="text-muted mb-0">Qty in Kgs</p>
<h4 class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_red"><?php echo $this_year_sales->Qty ?></span> </h4>
</div>
<div class="text-left">
<p class="text-muted mb-0">Sales in Rs.</p>
<h4 class="mb-1 mt-0"> <span data-plugin="counterup" class="card_font_colorset_red"><?php echo number_format($this_year_sales->Sales, 2); ?></span> </h4>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12 col-md-12">
<div class="card">
<div class="card-body">
<h4 class="header-title">This Year Sales Trend</h4>
<canvas id="salesComparisonChart" height="60"></canvas>
</div>
</div>
</div>
</div>
<!-- <div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Invoices Table</h4>
</div>
</div>
</div> -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<!-- <div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Invoices Table</h4>
</div>
</div>
</div> -->
<table id="datatable-buttonss" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th>Invoice No.</th>
<th>Invoice Date</th>
<th>Invoice Time</th>
<th>Vehicle No.</th>
<th>Product</th>
<th>Client</th>
<th>Quantity</th>
<th>Rate</th>
<th>Value</th>
<th>CGST</th>
<th>SGST</th>
<th>IGST</th>
<th>TCS</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php foreach ($get_today_invoices as $invoice) : ?>
<tr>
<td><?php echo $invoice['Invoice No.']; ?></td>
<td><?php echo $invoice['Invoice Date']; ?></td>
<td><?php echo $invoice['Invoice Time']; ?></td>
<td><?php echo $invoice['Vehicle No.']; ?></td>
<td><?php echo $invoice['Product']; ?></td>
<td><?php echo $invoice['Client']; ?></td>
<td><?php echo $invoice['Quantity']; ?></td>
<td><?php echo $invoice['Rate']; ?></td>
<td><?php echo $invoice['Value']; ?></td>
<td><?php echo $invoice['CGST']; ?></td>
<td><?php echo $invoice['SGST']; ?></td>
<td><?php echo $invoice['IGST']; ?></td>
<td><?php echo $invoice['TCS']; ?></td>
<td><?php echo $invoice['Total']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div>
<!-- end row -->
<!-- end page title -->
</div> <!-- container -->
</div> <!-- content -->
</div>
<script>$(document).ready(function() {
$('#datatable-buttonss').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print' // 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
order: [[0, 'desc']], // Default ordering (column index 0, ascending)
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
}
});
});
</script>
<script>
const currentYearSales = <?php echo json_encode($currentYearSales); ?>;
const lastYearSales = <?php echo json_encode($lastYearSales); ?>;
const ctx = document.getElementById('salesComparisonChart').getContext('2d');
const salesComparisonChart = new Chart(ctx, {
type: 'bar', // Bar chart
data: {
labels: ['April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', 'January', 'February', 'March'], // Months of the year
datasets: [
{
label: 'Current Year Sales',
data: currentYearSales,
backgroundColor: 'rgba(86, 166, 75, 0.6)', // Green color with opacity
borderColor: 'rgb(86, 166, 75)', // Green border color
borderWidth: 1,
},
{
label: 'Last Year Sales',
data: lastYearSales,
backgroundColor: 'rgba(173, 3, 23, 0.6)', // Red color with opacity
borderColor: 'rgb(173, 3, 23)', // Red border color
borderWidth: 1,
}
]
},
options: {
scales: {
y: {
beginAtZero: true, // Ensures the y-axis starts at zero
ticks: {
stepSize: 10000000, // Sets the interval between ticks
callback: function(value) {
return value; // Return plain number without formatting
}
},
min: 0, // Minimum value for y-axis
max: 30000000 // Maximum value for y-axis
}
},
plugins: {
legend: {
display: true,
labels: {
color: '#495057' // Color of legend text
}
}
}
}
});
</script>