diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index 970dafaf..4df396b0 100755 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -24,16 +24,43 @@ class Sales extends BaseController $this->isLoggedIn(); } + function formatIndianCurrency($amount) { + // Convert the amount to a string with 2 decimal places + $formattedAmount = number_format((float)$amount, 2, '.', ''); + + // Split the integer and decimal parts + $parts = explode('.', $formattedAmount); + $integerPart = $parts[0]; + $decimalPart = isset($parts[1]) ? $parts[1] : '00'; + + // Format the integer part for Indian numbering system + if (strlen($integerPart) > 3) { + $lastThreeDigits = substr($integerPart, -3); // Get the last 3 digits (thousands) + $remainingDigits = substr($integerPart, 0, -3); // Get the remaining digits + + // Add commas to the remaining digits in groups of 2 + $remainingDigits = preg_replace('/\B(?=(\d{2})+(?!\d))/', ',', $remainingDigits); + + // Combine the formatted parts + $integerPart = $remainingDigits . ',' . $lastThreeDigits; + } + + // Combine the integer and decimal parts + return $integerPart . '.' . $decimalPart; + } public function sales_dashboard() { $this->global['pageTitle'] = 'Sales Dashboard'; $data = []; $data['today_sales'] = $this->ipinvoice_model->todaySales(); + $data['today_sales']->Sales = $this->formatIndianCurrency($data['today_sales']->Sales, 2, '.', ','); $data['this_month_sales'] = $this->ipinvoice_model->thisMonthSales(); + $data['this_month_sales']->Sales = $this->formatIndianCurrency($data['this_month_sales']->Sales); $data['this_year_sales'] = $this->ipinvoice_model->thisYearSales(); + $data['this_year_sales']->Sales = $this->formatIndianCurrency($data['this_year_sales']->Sales, 2, '.', ','); $data['this_year_sales_trend'] = $this->ipinvoice_model->thisYearSalesTrend(); $data['get_today_invoices'] = $this->ipinvoice_model->getTodayInvoices(); - // dd($data); + // Define months from April to March $months = ['Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar']; diff --git a/app/Views/POlist.php b/app/Views/POlist.php index 02fc9969..1410bdde 100755 --- a/app/Views/POlist.php +++ b/app/Views/POlist.php @@ -131,8 +131,8 @@
-
- +
+
@@ -255,23 +255,13 @@ - - - - - - - - - + + @@ -609,7 +593,9 @@ @@ -621,6 +607,7 @@ + + @@ -658,16 +649,16 @@ @@ -71,7 +71,7 @@

Sales in Rs.

- Sales, 2, '.', ','); ?> + Sales; ?>

@@ -101,7 +101,7 @@

Sales in Rs.

- Sales, 2, '.', ','); ?> + Sales; ?>

Created Date