Added and Edited some Reports

This commit is contained in:
Srinivas-Saravanan 2024-10-29 15:37:48 +05:30
parent afb7349ec7
commit f36d3fbd1e
7014 changed files with 856 additions and 102 deletions

2
.env Normal file → Executable file
View File

@ -154,7 +154,7 @@ APP_TIMEZONE = 'Asia/Kolkata'
# WAAI_TOKEN = '6568739969f28'
# WAAI_INSTANCE = '656876690A9FD'
app.debug = true;
# for Testing Purpose
# 4th Account - Dummy Account by sanjeev created on 10th april 24 Testing purpose
# Dummy Office Mail ID - venba.it.chennai@venbainfotech.com

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
app/.htaccess Normal file → Executable file
View File

0
app/Common.php Normal file → Executable file
View File

0
app/Config/App.php Normal file → Executable file
View File

2
app/Config/Autoload.php Normal file → Executable file
View File

@ -97,5 +97,5 @@ class Autoload extends AutoloadConfig
* @var string[]
* @phpstan-var list<string>
*/
public $helpers = [];
public $helpers = ['date_picker'];
}

0
app/Config/Boot/development.php Normal file → Executable file
View File

0
app/Config/Boot/production.php Normal file → Executable file
View File

0
app/Config/Boot/testing.php Normal file → Executable file
View File

0
app/Config/CURLRequest.php Normal file → Executable file
View File

0
app/Config/Cache.php Normal file → Executable file
View File

0
app/Config/Constants.php Normal file → Executable file
View File

0
app/Config/ContentSecurityPolicy.php Normal file → Executable file
View File

0
app/Config/Cookie.php Normal file → Executable file
View File

0
app/Config/Database.php Normal file → Executable file
View File

0
app/Config/DocTypes.php Normal file → Executable file
View File

0
app/Config/Email.php Normal file → Executable file
View File

0
app/Config/Encryption.php Normal file → Executable file
View File

0
app/Config/Events.php Normal file → Executable file
View File

0
app/Config/Exceptions.php Normal file → Executable file
View File

0
app/Config/Feature.php Normal file → Executable file
View File

0
app/Config/Filters.php Normal file → Executable file
View File

0
app/Config/ForeignCharacters.php Normal file → Executable file
View File

0
app/Config/Format.php Normal file → Executable file
View File

0
app/Config/Generators.php Normal file → Executable file
View File

0
app/Config/Honeypot.php Normal file → Executable file
View File

0
app/Config/Images.php Normal file → Executable file
View File

0
app/Config/Kint.php Normal file → Executable file
View File

0
app/Config/Logger.php Normal file → Executable file
View File

0
app/Config/Migrations.php Normal file → Executable file
View File

0
app/Config/Mimes.php Normal file → Executable file
View File

0
app/Config/Modules.php Normal file → Executable file
View File

0
app/Config/Pager.php Normal file → Executable file
View File

0
app/Config/Paths.php Normal file → Executable file
View File

0
app/Config/Publisher.php Normal file → Executable file
View File

4
app/Config/Routes.php Normal file → Executable file
View File

@ -145,8 +145,12 @@ $routes->get('print_address_landscape/(:num)', 'Invoice::print_address_landscape
$routes->match(['get','post'],'/general_inv_rp','Invoice::general_inv_rp');
$routes->match(['get','post'],'/mem_inv_rp','Invoice::general_membership_inv_rp');
$routes->match(['get','post'],'/itemwise_report','Invoice::itemwise_report');
$routes->match(['get','post'],'/report_userwise_and_eventwise','Invoice::userwise_eventwise_report');
$routes->match(['get','post'],'/expired_customer_report','Invoice::expired_customer_report');
$routes->match(['get','post'],'/received_payments_report','Invoice::received_payments_report');
$routes->match(['get','post'],'/book_publishwise_Report','Invoice::book_publishwise_Report');
$routes->match(['get','post'],'/itemwise_report_with_payment_method','Invoice::itemwise_report_with_payment_method');

0
app/Config/Security.php Normal file → Executable file
View File

0
app/Config/Services.php Normal file → Executable file
View File

0
app/Config/Session.php Normal file → Executable file
View File

0
app/Config/Toolbar.php Normal file → Executable file
View File

0
app/Config/UserAgents.php Normal file → Executable file
View File

0
app/Config/Validation.php Normal file → Executable file
View File

0
app/Config/View.php Normal file → Executable file
View File

0
app/Controllers/Address.php Normal file → Executable file
View File

0
app/Controllers/ApiIntegration.php Normal file → Executable file
View File

0
app/Controllers/BaseController.php Normal file → Executable file
View File

0
app/Controllers/Business.php Normal file → Executable file
View File

0
app/Controllers/Customer.php Normal file → Executable file
View File

0
app/Controllers/Event.php Normal file → Executable file
View File

0
app/Controllers/Home.php Normal file → Executable file
View File

125
app/Controllers/Invoice.php Normal file → Executable file
View File

@ -8,6 +8,7 @@ use App\Models\InvoiceModel;
use App\Models\BusinessModel;
use App\Models\BooksModel;
use App\Helpers\NotificationHelper;
use App\Helpers\date_picker;
use Mpdf\Mpdf;
use Dompdf\Dompdf;
@ -954,12 +955,13 @@ class Invoice extends BaseController
} else {
$dateParts = explode(' - ', $this->request->getVar('date'));
$fromDate = $dateParts[0];
$toDate = $dateParts[1];
$dateTime = \DateTime::createFromFormat('d/m/Y', $fromDate);
$dateTime1 = \DateTime::createFromFormat('d/m/Y', $toDate);
$dates = datePicker($dateParts);
// $fromDate = $dateParts[0];
// $toDate = $dateParts[1];
// $dateTime = \DateTime::createFromFormat('d/m/Y', $fromDate);
// $dateTime1 = \DateTime::createFromFormat('d/m/Y', $toDate);
$model = new InvoiceModel();
$data['expired_customers'] = $model->getExpiredCustomers($dateTime->format('Y-m-d'), $dateTime1->format('Y-m-d'));
$data['expired_customers'] = $model->getExpiredCustomers($dates['dateTime']->format('Y-m-d'), $dates['dateTime1']->format('Y-m-d'));
$data['selected_data'] = $this->request->getVar('date');
$this->logger->info("Itemwise Report ");
}
@ -970,29 +972,112 @@ class Invoice extends BaseController
public function itemwise_report()
{
$model = new InvoiceModel();
if ($this->request->getmethod() == 'get') {
$model = new InvoiceModel();
$data['report_data'] = $model->itemwise_report_data();
$this->logger->info("Itemwise Report ");
$data['page_name'] = 'Bookswise Report';
$this->render_page('report_itemwise', $data);
$this->logger->info("Itemwise Report getMETHOD ");
$data['selected_data'] = "";
} else {
if ($this->request->getPost('export_csv')) {
$value = $this->request->getPost('value');
if (!isset($value)){
// Handle CSV export
$this->exportCsv();
} else {
// Handle date range filter
$this->logger->info("Itemwise Report CSV ");
$model = new InvoiceModel();
$data['report_data'] = $model->itemwise_report_data();
$this->logger->info("Itemwise Report ");
$data['page_name'] = 'Bookswise Report';
$this->exportCsv();
$this->render_page('report_itemwise', $data);
}
else{
// Handle date range filter
$this->logger->info("Itemwise Report getPOST ");
$dateParts = explode(' - ', $this->request->getVar('date'));
$dates = datePicker($dateParts);
// $fromDate = $dateParts[0];
// $toDate = $dateParts[1];
// $dateTime = \DateTime::createFromFormat('d/m/Y', $fromDate);
// $dateTime1 = \DateTime::createFromFormat('d/m/Y', $toDate);
$model = new InvoiceModel();
$data['report_data'] = $model->itemwise_report_data($dates['dateTime']->format('Y-m-d'), $dates['dateTime1']->format('Y-m-d'));
$data['selected_data'] = $this->request->getVar('date');
$this->logger->info('dsvawvsd');
$this->logger->info("Itemwise Report2 ");
}
}
$data['page_name'] = 'Bookswise Report';
$this->render_page('report_itemwise', $data);
}
public function userwise_eventwise_report(){
$model = new InvoiceModel();
if ($this->request->getMethod() == 'get'){
$data['report_data'] = $model->userwise_eventwise_report();
$data['selected_data'] = '';
$this->logger->info("Inside GEt method");
}
else{
$dateParts = explode(' - ', $this->request->getVar('date'));
$dates = datePicker($dateParts);
$model = new InvoiceModel();
$data['report_data'] = $model->userwise_eventwise_report($dates['dateTime']->format('Y-m-d'), $dates['dateTime1']->format('Y-m-d'));
$data['selected_data'] = $this->request->getVar('date');
$this->logger->info('dsvawvsd');
$this->logger->info("Itemwise Report2 ");
}
$data['page_name'] = 'User and Event wise Report';
$this->render_page('report_userwise_and_eventwise',$data);
}
public function received_payments_report(){
$model = new InvoiceModel();
if ($this->request->getMethod() == 'get'){
$data['payment_data'] = $model->getPaymentReport();
$data['selected_data'] = "";
$this->logger->info("Inside the get method");
}
else{
$dateParts = explode(' - ',$this->request->getVar(('date')));
$dates = datePicker($dateParts);
// $fromDate = $dateParts[0];
// $toDate = $dateParts[1];
// $dateTime = \DateTime::createFromFormat('d/m/Y',$fromDate);
// $dateTime1 = \DateTime::createFromFormat('d/m/Y',$toDate);
$data['payment_data'] = $model->getPaymentReport($dates['dateTime']->format('Y-m-d'), $dates['dateTime1']->format('Y-m-d'));
$data['selected_data'] = $this->request->getVar('date');
}
$data['page_name'] = 'Received Payments Report';
$this->render_page('received_payments_report',$data);
}
public function itemwise_report_with_payment_method(){
$model = new InvoiceModel();
if ($this->request->getMethod() == 'get'){
$data['report_data'] = $model->itemwise_report_data_with_payment_method();
$data['selected_data'] = "";
$this->logger->info("Inside the get method");
}
else{
$dateParts = explode(' - ',$this->request->getVar(('date')));
$dates = datePicker($dateParts);
// $fromDate = $dateParts[0];
// $toDate = $dateParts[1];
// $dateTime = \DateTime::createFromFormat('d/m/Y',$fromDate);
// $dateTime1 = \DateTime::createFromFormat('d/m/Y',$toDate);
$data['report_data'] = $model->itemwise_report_data_with_payment_method($dates['dateTime']->format('Y-m-d'), $dates['dateTime1']->format('Y-m-d'));
$data['selected_data'] = $this->request->getVar('date');
}
$data['page_name'] = 'Sales By Books';
// var_dump($data);
// die();
$this->render_page('itemwise_report_with_payment_method',$data);
}
}
private function exportCsv()
{

0
app/Controllers/Scheme.php Normal file → Executable file
View File

0
app/Controllers/Subscription.php Normal file → Executable file
View File

0
app/Controllers/email_temp.php Normal file → Executable file
View File

0
app/Database/Migrations/.gitkeep Normal file → Executable file
View File

0
app/Database/Seeds/.gitkeep Normal file → Executable file
View File

0
app/Filters/.gitkeep Normal file → Executable file
View File

0
app/Helpers/.gitkeep Normal file → Executable file
View File

0
app/Helpers/NotificationHelper.php Normal file → Executable file
View File

0
app/Helpers/apiIntegration_helper.php Normal file → Executable file
View File

View File

@ -0,0 +1,19 @@
<?php
/**
* Formats the given date range from string 'd/m/Y' to date object'd-m-Y'.
*
* @param array $dateParts An array containing the start and end dates
* in 'd/m/Y' format or in any format where the datatype is string.
* @return array An array with formatted start and end dates in 'd-m-Y' format.
*/
function datePicker($dateParts){
$fromDate = $dateParts[0];
$toDate = $dateParts[1];
$date['dateTime']= \DateTime::createFromFormat('d/m/Y', $fromDate);
$date['dateTime1'] = \DateTime::createFromFormat('d/m/Y', $toDate);
return $date;
}
?>

0
app/Helpers/financial_year_helper.php Normal file → Executable file
View File

0
app/Helpers/session_helper.php Normal file → Executable file
View File

0
app/Language/.gitkeep Normal file → Executable file
View File

0
app/Language/en/Validation.php Normal file → Executable file
View File

0
app/Libraries/.gitkeep Normal file → Executable file
View File

0
app/Models/.gitkeep Normal file → Executable file
View File

0
app/Models/ApiIntegrationModel.php Normal file → Executable file
View File

0
app/Models/AuthenticationModel.php Normal file → Executable file
View File

0
app/Models/BooksModel.php Normal file → Executable file
View File

0
app/Models/BusinessModel.php Normal file → Executable file
View File

0
app/Models/CustomerModel.php Normal file → Executable file
View File

0
app/Models/EventModel.php Normal file → Executable file
View File

0
app/Models/HomeModel.php Normal file → Executable file
View File

132
app/Models/InvoiceModel.php Normal file → Executable file
View File

@ -433,16 +433,24 @@ public function get_mem_invoice_data($f_date = null, $t_date = null)
// return $result;
// }
public function itemwise_report_data()
public function itemwise_report_data($f_date = null, $t_date = null)
{
// Fetch invoice data
$query = $this->db->table('invoice')
->select('books.publishers_code, COUNT(invoiceitems.product) as publisher_item_count, books.title as book_name, COUNT(invoiceitems.product) as item_count, SUM(invoiceitems.quantity * invoiceitems.unit_price) as total_cost')
->where('invoice.isactive', 1)
->select('books.publishers_code, COUNT(invoiceitems.product) as publisher_item_count, books.title as book_name, COUNT(invoiceitems.product) as item_count, SUM(invoiceitems.quantity * invoiceitems.unit_price) as total_cost ,DATE_FORMAT(books.publication_date, "%d/%m/%Y") AS book_publication_date');
$query->where('invoice.isactive', 1)
->where('invoice.invoice_type',1)
->where('books.isactive', 1);
// Add date range filter if provided
if ($f_date !== null && $t_date !== null) {
$newf_date = date("Y-m-d", strtotime($f_date));
$newt_date = date("Y-m-d", strtotime($t_date));
$query->where('books.publication_date >=', $newf_date)
->where('books.publication_date <=', $newt_date);
}
$result = $query->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id', 'left')
@ -452,7 +460,9 @@ public function itemwise_report_data()
->getResult();
// print_r($result);
// Group by publisher_code and include books
// // Group by publisher_code and include books
// var_dump($result);
// die();
$groupedResult = [];
foreach ($result as $row) {
$publisherCode = $row->publishers_code;
@ -462,6 +472,8 @@ public function itemwise_report_data()
'publisher_item_count' => 0,
'publisher_total_cost' => 0,
'books' => [],
'book_name'=>'',
];
}
@ -472,9 +484,10 @@ public function itemwise_report_data()
'book_name' => $row->book_name,
'item_count' => $row->item_count,
'total_cost' => $row->total_cost,
'book_publication_date' =>$row->book_publication_date,
];
}
return array_values($groupedResult);
}
@ -542,6 +555,115 @@ public function itemwise_report_data_with_publish_code($f_date = null, $t_date =
return $result;
}
public function userwise_eventwise_report($f_date = null, $t_date = null){
$builder = $this->db->table('invoice');
$builder->select([
'users.user_id',
'users.first_name',
'events.event_name',
'COUNT(invoice.created_by) AS books_sold',
'ABS(SUM(invoice.exact_total_amount)) AS total_amount',
'invoice.payment_method',
'invoice.invoice_date'
]);
$builder->join('users', 'users.user_id = invoice.created_by');
$builder->join('events', 'events.event_id = invoice.event_id');
$builder->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id');
$builder->join('books', 'books.book_id = invoiceitems.product');
$builder->where('invoice.event_id <>', 0);
if ($f_date !== null && $t_date !== null) {
$builder->where('invoice.invoice_date >=', $f_date)
->where('invoice.invoice_date <=', $t_date);
}
$builder->groupBy([
'users.user_id',
'users.first_name',
'events.event_name',
'payment_method'
]);
$query = $builder->get();
$results = $query->getResultArray();
return $results;
}
public function getPaymentReport($f_date = null, $t_date = null)
{
$builder = $this->db->table('invoice');
$builder->select('invoice.invoice_number, customers.first_name, invoice.total_amount, invoice.payment_status, invoice.payment_method, invoice.invoice_date');
$builder->join('customers', 'invoice.customer_id = customers.customer_id', 'inner');
if ($f_date !== null && $t_date !== null) {
$builder->where('invoice.invoice_date >=', $f_date)
->where('invoice.invoice_date <=', $t_date);
}
$query = $builder->get();
$results = $query->getResultArray();
return $results;
}
public function itemwise_report_data_with_payment_method($f_date = null, $t_date = null)
{
$builder = $this->db->table('invoice');
$builder->select('books.publishers_code,
COUNT(invoiceitems.product) AS publisher_item_count,
books.title AS book_name,
COUNT(invoiceitems.product) AS item_count,
SUM(invoiceitems.quantity * invoiceitems.unit_price) AS total_cost,
invoice.payment_method,
DATE_FORMAT(books.publication_date, "%d-%m-%Y") AS book_publication_date');
$builder->join('invoiceitems', 'invoiceitems.invoice_id = invoice.invoice_id', 'left');
$builder->join('books', 'books.book_id = invoiceitems.product', 'left');
$builder->where('invoice.isactive', 1);
$builder->where('invoice.invoice_type', 1);
$builder->where('books.isactive', 1);
$builder->groupBy(['books.publishers_code', 'books.title', 'invoice.payment_method']);
$query = $builder->get();
$results = $query->getResultArray();
$groupedResult = [];
foreach ($results as $row) {
// Use a unique key for each combination of publisher and payment method
$publisherCode = $row['publishers_code'];
$paymentMethod = $row['payment_method'];
$uniqueKey = $publisherCode . '-' . $paymentMethod; // Unique key for grouping
// Initialize the group if it does not exist
if (!isset($groupedResult[$uniqueKey])) {
$groupedResult[$uniqueKey] = (object)[
'publisher_code' => $publisherCode,
'publisher_item_count' => 0,
'publisher_total_cost' => 0,
'books' => [],
'payment_method' => $paymentMethod,
];
}
// Update the groups cumulative values
$groupedResult[$uniqueKey]->publisher_item_count += $row['publisher_item_count'];
$groupedResult[$uniqueKey]->publisher_total_cost += $row['total_cost'];
// Add the book-specific information to the books array
$groupedResult[$uniqueKey]->books[] = (object)[
'book_name' => $row['book_name'],
'item_count' => $row['item_count'],
'total_cost' => $row['total_cost'],
'book_publication_date' => $row['book_publication_date'],
];
}
return array_values($groupedResult);
}
public function updateInvoiceStatus($invoiceId, $voidReason)
{
// Assuming 'invoices' is the name of your table

0
app/Models/NotificationModel.php Normal file → Executable file
View File

0
app/Models/SchemeModel.php Normal file → Executable file
View File

0
app/Models/SettingsModel.php Normal file → Executable file
View File

0
app/Models/SubscriptionModel.php Normal file → Executable file
View File

0
app/Models/UsersModel.php Normal file → Executable file
View File

0
app/ThirdParty/.gitkeep vendored Normal file → Executable file
View File

0
app/Views/address_list.php Normal file → Executable file
View File

0
app/Views/address_pdf_landscape_template.php Normal file → Executable file
View File

0
app/Views/address_pdf_template.php Normal file → Executable file
View File

0
app/Views/approve_template.php Normal file → Executable file
View File

0
app/Views/auth_confirm_mail.php Normal file → Executable file
View File

0
app/Views/auth_lock_screen.php Normal file → Executable file
View File

0
app/Views/auth_reset_password.php Normal file → Executable file
View File

0
app/Views/book_form.php Normal file → Executable file
View File

0
app/Views/book_list.php Normal file → Executable file
View File

0
app/Views/business_form.php Normal file → Executable file
View File

0
app/Views/business_list.php Normal file → Executable file
View File

0
app/Views/campaign_creation.php Normal file → Executable file
View File

0
app/Views/campaign_creation_form.php Normal file → Executable file
View File

0
app/Views/customer_form.php Normal file → Executable file
View File

0
app/Views/customer_group.php Normal file → Executable file
View File

0
app/Views/customer_group_form.php Normal file → Executable file
View File

0
app/Views/customer_list.php Normal file → Executable file
View File

6
app/Views/dashboard.php Normal file → Executable file
View File

@ -165,10 +165,14 @@
<?php
$notifications = $e['notifications'];
$lastNotification = end($notifications);
$lastStartDateTime = $lastNotification['start_date_time'];
$lastStartDateTime = (!$lastNotification)? '':['start_date_time'];
$startDateTime = isset($lastStartDateTime) ? $lastStartDateTime : '';
echo $startDateTime ? date('d/m/Y', strtotime($startDateTime)) : '';
?>
<script>
var lastNotification = <?=$lastNotification?>lastNotification
console.log(lastNotification);
</script>
</td>
</tr>
<?php endforeach; else : ?>

Some files were not shown because too many files have changed in this diff Show More