FIX_REQUESTED_CLIENT_CHANGES

This commit is contained in:
Srinivas-Saravanan 2024-12-09 12:27:33 +05:30
parent 8bd80a6896
commit 5d9b4ca392
19 changed files with 230 additions and 50 deletions

View File

@ -108,6 +108,7 @@ $routes->post('address/generatePdf', 'Address::generatePdf');
#evnts
$routes->get("event_list/", "Event::index");
$routes->get("new_event/(:any)", "Event::new_event/$1");
$routes->get("delete_event/(:any)","Event::delete_event/$1");
$routes->post("insert_event/", "Event::insert_event");
$routes->post("change_default_event/", "Event::change_default_event");
@ -148,6 +149,7 @@ $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->post('getActiveMembers','Invoice::getActiveMembers');
$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');

View File

@ -23,7 +23,7 @@ class Event extends BaseController
$EventModel = new EventModel();
$data['page_name'] = 'Event Details';
$events = $EventModel->where($where)->orderBy('event_id', 'DESC')->findAll(); // Retrieve the events
$events = $EventModel->where('isactive',1)->where($where)->orderBy('event_id', 'DESC')->findAll(); // Retrieve the events
// Sort the events by ID in descending order (newest first)
// usort($events, function ($a, $b) {
@ -209,4 +209,60 @@ class Event extends BaseController
return $this->response->setJSON(['response' => $response]);
}
public function delete_event($id)
{
try {
helper('session');
$session_uid = get_logged_user_id();
$event_model = new EventModel();
// Define the common where condition
$where = ['event_id' => (int)$id, 'isactive' => 1];
// Check if the event exists based on the where condition
$existingEvent = $event_model->where($where)->first();
if ($existingEvent) {
// Log info about deactivating the event
$this->logger->Info("Event: Going to Inactive ID = " . $id);
// Data to update the event (mark as inactive)
$data = ['isactive' => 0, 'updated_by' => $session_uid];
// Update the event as inactive
$result = $event_model->where('event_id', $id)->where('isactive', 1)->set($data)->update();
$last_query = $event_model->getLastQuery();
// dd($last_query);
// Check if the event was updated
if ($result) {
// Log success info
$this->logger->Info("Event: has been Inactived successfully. Inactived ID = " . $id);
// Set success flashdata
session()->setFlashdata('success', 'Event deactivated successfully.');
} else {
// Log error if update fails
$this->logger->error("Event: Not able to Inactive ID = " . $id);
throw new \Exception("Failed to deactivate the event.");
}
} else {
// Log error if no matching event is found
$this->logger->error("Event: No event found to deactivate with ID = " . $id);
session()->setFlashdata('error', 'Event not found or already inactive.');
}
} catch (\Exception $e) {
// Log error details
$this->logger->error("Event: Error Occurred = " . $e->getMessage() . " File = " . $e->getFile() . " Line = " . $e->getLine());
// Set error flashdata
session()->setFlashdata('error', 'Error: ' . $e->getMessage());
}
// Redirect to the event list page
return redirect()->route('event_list');
}
}

View File

@ -112,7 +112,7 @@ class Invoice extends BaseController
// Get customer names for the dropdown, events details, and subscription books details
$data['customers'] = $model->getData('customers', $where);
$data['events'] = $model->getData('events', $where);
$data['events'] = $model->getData('events', array_merge($where, ['isactive' => 1]));
$data['books'] = $model->getCategoryBooks(2); // Invocie type = 2 (subscription)
$data['invoice_number_formatting'] = $model->getData('invoice_number_formatting', $where);
if ($id === '0') {
@ -411,8 +411,15 @@ class Invoice extends BaseController
// Send notification if invoice is approved
$this->logger->info($msg_flag_name . ": ID = " . $invoice_id . ", Status =" . $invoice_status);
if ($invoice_status == 'Approved' && $invoice_id != "") {
if(null!=($this->request->getPost('contact_method_mail'))){
$contact_method['msg_mail'] = 1;
}
if(null!=($this->request->getPost('contact_method_whatsapp'))){
$contact_method['msg_whatsapp'] = 1;
}
$this->logger->info($msg_flag_name . ": in " . $invoice_status . ". ID = " . $invoice_id);
$this->approve_notifications((int)$invoice_id);
$this->approve_notifications((int)$invoice_id,isset($contact_method)?$contact_method:null);
}
// Redirect to the appropriate route based on the invoice type
@ -467,6 +474,7 @@ public function create_or_update_invoice($invoice_id, $msg_flag_name)
public function prepare_invoice_data($invoice_id, $msg_flag_name)
{
$invdate = $this->request->getVar('invoice_date');
$duedate = $this->request->getVar('due_date');
$invoice_status = $this->request->getPost('status');
@ -774,9 +782,9 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
return $now . " " . $result;
}
public function approve_notifications($invoice_id)
public function approve_notifications($invoice_id,$contact_method = null)
{
$this->logger->info("Approve Notifications : ID " . $invoice_id);
log_message('info',"Approve Notifications : ID " . $invoice_id);
$model = new InvoiceModel();
$where = ['I.business_id' => (int)get_business_id(), 'I.invoice_id' => $invoice_id, 'I.isactive' => 1];
$details = $model->getDetailForApproveNotifications($where);
@ -800,7 +808,7 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
$business_email = "";
$business_mobile_no = "";
if (isset($details)) {
$this->logger->info("Invoice: approve notification Request data type = " . gettype($details));
log_message('info',"Invoice: approve notification Request data type = " . gettype($details));
}
helper('notification');
$notification = new NotificationHelper();
@ -883,17 +891,23 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
// print_r($records['description']);die;
$url = base_url("download_invoice_pdf/" . md5($invoice_id));
$encodedUrl = urlencode($url);
$template = "Dear " . $recipient_name . ",\r\r\n\nYour Invoice has been generated.\n\nDetails:\r\n- Invoice Date: " . $invoiceDate . "\r\n- Invoice Number: " . $invoice_serial_number . "\r\n- Click here to download the Invoice: " . $url;
if(isset($contact_method['msg_whatsapp'])){
$template = "Dear " . $recipient_name . ",\r\r\n\nYour Invoice has been generated.\n\nDetails:\r\n- Invoice Date: " . $invoiceDate . "\r\n- Invoice Number: " . $invoice_serial_number . "\r\n- Click here to download the Invoice: " . $url;
$params = (object) Null;
$params->number = (int)'91' . $recipient_mobile;
$params->type = "text";
$params->message = $template;
$params->instance_id = $_ENV['WAAI_INSTANCE'];
$params->access_token = $_ENV['WAAI_TOKEN'];
$this->logger->info("Approve notification Email Request data = " . json_encode($records));
$email_result = $notification->sendEmail($records);
$this->logger->info("Approve notification Email Response = " . json_encode($email_result));
$params = (object) Null;
$params->number = (int)'91' . $recipient_mobile;
$params->type = "text";
$params->message = $template;
$params->instance_id = $_ENV['WAAI_INSTANCE'];
$params->access_token = $_ENV['WAAI_TOKEN'];
}
if(isset($contact_method['msg_mail'])){
log_message('info',"Approve notification Email Request data = " . json_encode($records));
$email_result = $notification->sendEmail($records);
log_message('info',"Approve notification Email Response = " . json_encode($email_result));
}
// $this->logger->info("Approve notification Whatsapp Request data = " . json_encode($params));
// $whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
// $this->logger->info("Approve notification Whatsapp Response = " . json_encode($whatsapp_result));
@ -1629,5 +1643,10 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
return $this->response->setJSON($response);
}
public function getActiveMembers(){
$Invoice_Model = new InvoiceModel();
$response['data'] = $Invoice_Model->getActiveMembers();
// log_message('error',json_encode($response));die();
return $this->response->setJSON($response);
}
}

View File

@ -246,7 +246,10 @@ public function payment_success() {
'to_subscription' =>$tsubscription,
];
$db->table('invoiceitems')->insert($requestData);
$db->table('invoiceitems')->insert($requestData);
$invoice = new Invoice();
$contact_method['msg_mail'] = 1;
$invoice->approve_notifications((int)$invoice_id['invoice_id'],$contact_method);
$model3 = new SubscriptionModel();
$invoiceController = new Invoice();
$membership_id = $invoiceController->generate_membership_id(6);

View File

@ -49,6 +49,18 @@ class EventModel extends Model
return ["info"=>"","err"=>'Database operation failed: ' . $e->getMessage()];
}
}
public function getData($table, $where = null, $whereIn = null)
{
$query = $this->db->table($table);
if ($where) {
$query->where($where);
}
if ($whereIn) {
// $query->whereIn($column_name,$missingValues)
$query->whereIn($whereIn[0], $whereIn[1]);
}
return $query->get()->getResult();
}
}

View File

@ -597,6 +597,21 @@ $result = $query
// Fetch results as an associative array
return $result->getResultArray();
}
public function getActiveMembers(){
$result =
$this->db->table('subscription as S')
->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription,
C.first_name, C.last_name, C.email, C.mobile_no,
S.scheme_id, B.short_code, S.membership_id')
->join('customers as C', 'C.customer_id = S.customer_id', 'left')
->join('books as B', 'B.book_id = S.scheme_id', 'left')
->where('S.isactive', 1)
->where('S.status',1)
->orderBy('S.to_subscription', 'ASC')
->get();
return $result->getResultArray();
}
public function itemwise_report_data_with_publish_code($f_date = null, $t_date = null)
{
@ -811,5 +826,6 @@ public function getActiveSchemes(){
}

View File

@ -43,12 +43,18 @@
<?php foreach ($invoiceData as $value): ?>
<div class="label-container">
<table width="100%" style="border-collapse: collapse;">
<tr>
<td width="30%" style="text-align: left;font-size: 11px;"><strong>From:</strong></td>
<td width="70%" style="text-align: right;font-size: 11px;">
<?php $label = $value->invoice_number == $value->wp_api_order_id ? "Order Number :" : "Invoice Number :"; ?>
<td width = "40%"><img src="<?= base_url() . 'public/uploads/Vijayabharatham_logo_1.png' ?>" alt="" height="55"></td>
<td width="60%" style="text-align: right;font-size: 11px;">
<?php $label = $value->invoice_number == $value->wp_api_order_id ? "Order Number :" : "Invoice Number :"; ?>
<b><?= $label; ?></b> <?= $value->invoice_number; ?>
</td>
</td>
</tr><tr>
<td></td>
</tr>
<tr>
<td style="text-align: left;font-size: 11px;"><strong>From:</strong></td>
</tr>
</table>
<!-- From Address on the left -->

View File

@ -137,8 +137,8 @@
<div class="form-group col-md-3">
<label for="bcountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<select class="form-control" id="bcountry" name="bcountry[]" required>
<option value="">Choose your Country</option>
<?php foreach ($country_details as $value) { ?>
<option selected value="India">India</option>
<?php foreach ($country_details as $value) { ?>
<option value="<?php echo $value['country_short_name']; ?>">
<?php echo $value['country_name']; ?>
</option>
@ -149,14 +149,14 @@
<div class="form-group col-md-3">
<div id="billinput" style="display: block">
<label for="bistate" class="col-form-label">State</label>
<input type="text" class="form-control" id="bistate" name="bistate[]" placeholder="State" />
<input type="text" class="form-control" id="bistate" name="bistate[]" value="Tamil Nadu" />
</div>
<div id="billdropdown" style="display: none">
<label for="bdstate" class="col-form-label">State</label>
<select class="form-control" id="bdstate" name="bdstate[]">
<option value="">Choose your State</option>
<?php foreach ($state_details as $value) { ?>
<option selected value="Tamil Nadu">Tamil Nadu</option>
<?php foreach ($state_details as $value) { ?>
<option value="<?php echo $value['state_short_name']; ?>">
<?php echo $value['state_name']; ?>
</option>
@ -210,7 +210,7 @@
<label for="scountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<input type="hidden" id="counter" value=<?= 0; ?> readonly />
<select class="form-control" id="scountry0" name="scountry[]" onchange="changeFields(this)" required>
<option value="">Choose your Country</option>
<option selected value="India">India</option>
<?php foreach ($country_details as $value) { ?>
<option value="<?php echo $value['country_short_name']; ?>">
<?php echo $value['country_name']; ?>
@ -221,10 +221,10 @@
</div>
<div class="form-group col-md-3">
<label for="" class="col-form-label">State</label>
<input type="text" class="form-control" id="sistate0" name="sistate[]" placeholder="State" style="display: block" />
<input type="text" class="form-control" id="sistate0" name="sistate[]" value="Tamil Nadu" style="display: block" />
<select class="form-control" id="sdstate0" name="sdstate[]" style="display: none">
<option value="">Choose your State</option>
<?php foreach ($state_details as $value) { ?>
<option selected value="Tamil Nadu">Tamil Nadu</option>
<?php foreach ($state_details as $value) { ?>
<option value="<?php echo $value['state_short_name']; ?>">
<?php echo $value['state_name']; ?>
</option>

View File

@ -23,7 +23,7 @@
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<div class="table-responsive">
@ -46,7 +46,10 @@
<input type="radio" class="custom-control-input" name="is_the_default" value="<?= $value['event_id'] ?>" id="<?= $value['event_id'] ?>" <?= $value['is_the_default'] ? "checked" : ""; ?> >
<label class="custom-control-label" for="<?= $value['event_id']; ?>"></label>
<a href="<?= "new_event/" . $value['event_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
<a href="<?= base_url() . "delete_event/" . $value['event_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
</div>
</td>
</tr>
<?php endforeach; ?>

View File

@ -552,7 +552,16 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<option value="upi">UPI</option>
<option value="banktransfer">Bank Transfer</option>
<!-- Add more options as needed -->
</select>
</select><br>
<label>Contact Method:</label><br>
<div class="form-check form-check-inline">
<input checked type="checkbox" class="form-check-input" id="email" name="contact_method_mail" value="Email">
<label class="form-check-label" for="email">Email</label>
</div>
<div class="form-check form-check-inline">
<input checked type="checkbox" class="form-check-input" id="whatsapp" name="contact_method_whatsapp" value="WhatsApp">
<label class="form-check-label" for="whatsapp">WhatsApp</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

View File

@ -368,9 +368,12 @@
<?php endif; ?>
<tr>
<td colspan="6" style="width: 60%; vertical-align: top;">
<?php if ($value->status != 'Approved') : ?>
<div>
<h4>Bank Details</h4>
<?php echo nl2br($business['terms']); ?>
<?php endif?>
</div>
</td>
<td colspan="6" style="width: 40%; vertical-align: bottom;">

View File

@ -77,7 +77,7 @@
buttons: [{
extend: 'print',
title: 'Expired Invoice Report',
title: '<?= $page_name.' ' .$selected_data ?>',
text: 'Print',
customize: function(win) {
// Exclude the first and last columns
@ -87,7 +87,7 @@
{
extend: 'csv',
text: 'CSV',
title: 'Membership Invoice Report',
title: '<?= $page_name.' ' .$selected_data ?>',
exportOptions: {
columns: ':not(:first-child)'
}

View File

@ -148,14 +148,14 @@
buttons: [
{
extend: 'print',
title: 'Itemwise Report',
title: '<?= $page_name.' ' .$selected_data ?>',
text: 'Print',
customize: function (win) { }
},
{
extend: 'csv',
text: 'CSV',
title: 'Itemwise Report',
title: '<?= $page_name.' ' .$selected_data ?>',
exportOptions: {}
}
]

View File

@ -124,7 +124,7 @@
buttons: [{
extend: 'print',
text: 'Print',
title: 'General Invoice Report',
title: '<?= $page_name.' ' .$selected_data ?>',
customize: function(win) {
// Exclude the first and last columns
$(win.document.body).find('table').find('th:first-child, td:first-child').remove();
@ -133,7 +133,7 @@
{
extend: 'csv',
text: 'CSV',
title: 'General Invoice Report',
title: '<?= $page_name.' ' .$selected_data ?>',
exportOptions: {
columns: ':not(:first-child)'
}

View File

@ -64,7 +64,7 @@
</div><!-- end col-->
</div>
<!-- end row -->
Sri Kasi, 12, M.V. Naidu Street, Chetpet,Chennai -
<script>
$(document).ready(function() {
var table = $('#datatable-buttons').DataTable({
@ -75,21 +75,28 @@
buttons: [
{
extend: 'print',
title: 'Expired Invoice Report',
title: '<?= $page_name ?>',
text: 'Print',
customize: function(win) {
// Exclude the first and last columns
$(win.document.body).find('table').find('th:first-child, td:first-child').remove();
}
},
{
extend: 'csv',
text: 'CSV',
title: 'Membership Invoice Report',
title: '<?= $page_name?>',
exportOptions: {
columns: ':not(:first-child)'
}
}
},
{
text: 'Active Members',
action: function (e, dt, node, config) {
getActiveMembers(); // Call the custom function
}
}
],
columnDefs: [
{
@ -132,6 +139,50 @@
L: 'DD/MM/YYYY',
}
});
let isFirstClick = true;
function getActiveMembers() {
if(isFirstClick){
$.ajax({
type: 'POST',
url: "<?= base_url('getActiveMembers') ?>",
success: function(response) {
// Assuming the response contains an array of active member data
var data = response.data;
var table = $('#datatable-buttons').DataTable();
table.clear();
data.forEach(function(item) {
var from_subscription = new Date(item.from_subscription);
var from_subscription_formatted = ('0' + from_subscription.getDate()).slice(-2) + '/' +
('0' + (from_subscription.getMonth() + 1)).slice(-2) + '/' +
from_subscription.getFullYear();
var to_subscription = new Date(item.to_subscription);
var to_subscription_formatted = ('0' + to_subscription.getDate()).slice(-2) + '/' +
('0' + (to_subscription.getMonth() + 1)).slice(-2) + '/' +
to_subscription.getFullYear();
table.row.add([
item.first_name+' '+item.last_name,
item.membership_id,
from_subscription_formatted,
to_subscription_formatted,
item.mobile_no,
item.email,
item.short_code,
]);
});
// Redraw the table with the new data
table.draw();
},
error: function(xhr, status, error) {
console.error("Error fetching active members:", error);
alert("An error occurred while fetching active members.");
}
});
}else{
location.reload();
}
isFirstClick = !isFirstClick;
}
$(document).ready(function() {
var $select_data = '<?php echo $selected_data; ?>';

View File

@ -158,7 +158,7 @@
buttons: [{
extend: 'print',
text: 'Print',
title: 'General Invoice Report',
title: '<?= $page_name.' ' .$selected_data ?>',
customize: function(win) {
// Exclude the first and last columns
$(win.document.body).find('table').find('th:first-child, td:first-child').remove();
@ -167,7 +167,7 @@
{
extend: 'csv',
text: 'CSV',
title: 'General Invoice Report',
title: '<?= $page_name.' ' .$selected_data?>',
exportOptions: {
columns: ':not(:first-child)'
}

View File

@ -100,14 +100,14 @@
buttons: [
{
extend: 'print',
title: 'Itemwise Report',
title: '<?= $page_name.' ' .$selected_data ?>',
text: 'Print',
customize: function (win) { }
},
{
extend: 'csv',
text: 'CSV',
title: 'Itemwise Report',
title: '<?= $page_name.' ' .$selected_data ?>',
exportOptions: {}
}
]

View File

@ -74,14 +74,14 @@
buttons: [
{
extend: 'print',
title: 'Itemwise Report',
title: '<?= $page_name.' ' .$selected_data ?>',
text: 'Print',
customize: function (win) { }
},
{
extend: 'csv',
text: 'CSV',
title: 'Itemwise Report',
title: '<?= $page_name.' ' .$selected_data ?>',
exportOptions: {}
}
]

View File

@ -47,7 +47,7 @@
<td hidden><?= $row['category_name']; ?></td>
<td>
<a href="<?= base_url() . "new_scheme/" . $row['book_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
<!-- <a href="<?= base_url() . "delete_scheme/" . $row['book_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a> -->
<a href="<?= base_url() . "delete_scheme/" . $row['book_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
</td>
</tr>
<?php endforeach; ?>