FIX_Issues fixes Code

This commit is contained in:
VE10-Sanjeev 2024-11-25 09:51:08 +00:00
parent 2590d153b4
commit 34938634e9
4 changed files with 24 additions and 5 deletions

View File

@ -609,10 +609,11 @@ class Notifications extends BaseController
$response .= "Started.<br> Customer expiring. till dated = ".date('d/m/Y', strtotime($newDate))." <br> There are ".count($queryResult)." persons <br>"; $response .= "Started.<br> Customer expiring. till dated = ".date('d/m/Y', strtotime($newDate))." <br> There are ".count($queryResult)." persons <br>";
if(!empty($queryResult)){ if(!empty($queryResult)){
usort($queryResult, function ($a, $b) { usort($queryResult, function ($a, $b) {
return $b['to_subscription'] <=> $a['to_subscription']; // Descending order return $a['to_subscription'] <=> $b['to_subscription']; //Asc order
}); });
} }
foreach ($queryResult as $inx => $row) { foreach ($queryResult as $inx => $row) {
$subscription_id = $row['sub_id'];
$status = $row['status']; $status = $row['status'];
$userFirstName = $row['first_name']; $userFirstName = $row['first_name'];
$userLastName = $row['last_name']; $userLastName = $row['last_name'];
@ -703,6 +704,7 @@ class Notifications extends BaseController
'customer_id' => $customerId, 'customer_id' => $customerId,
'receiving_entity' => $row['email'], 'receiving_entity' => $row['email'],
'receiving_status' => 0, 'receiving_status' => 0,
'subscription_id' => $subscription_id,
'message' => $emailContent]; 'message' => $emailContent];
# Step 5: Insertion on History Child # Step 5: Insertion on History Child
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data); $history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
@ -816,6 +818,7 @@ class Notifications extends BaseController
'customer_id' => $customerId, 'customer_id' => $customerId,
'receiving_entity' => $userMobileNumber, 'receiving_entity' => $userMobileNumber,
'receiving_status' => 0, 'receiving_status' => 0,
'subscription_id' => $subscription_id,
'message' => strip_tags(ltrim($whatsappContent))]; 'message' => strip_tags(ltrim($whatsappContent))];
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data); $history_child_id = $NotificationModel->save_notification_history_child($history_child_data);

View File

@ -227,7 +227,7 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
$builder->select(" $builder->select("
CONCAT_WS(' ', c.first_name, c.last_name) as customer_name, CONCAT_WS(' ', c.first_name, c.last_name) as customer_name,
c.customer_id, c.mobile_no, c.email, DATEDIFF(s.to_subscription, CURDATE()) AS remaining_days, c.customer_id, c.mobile_no, c.email, DATEDIFF(s.to_subscription, CURDATE()) AS remaining_days,
s.from_subscription, s.to_subscription, s.scheme_id, bs.title, s.from_subscription, s.to_subscription, s.scheme_id, bs.title, s.membership_id,s.sub_id,
i.invoice_id, i.invoice_date, i.shipping_address_id, i.invoice_id, i.invoice_date, i.shipping_address_id,
ca.customer_address_id, ca.address_1, ca.address_2, ca.city, ca.state, ca.postal_code, ca.address_type, st.state_name, ca.customer_address_id, ca.address_1, ca.address_2, ca.city, ca.state, ca.postal_code, ca.address_type, st.state_name,
b.title as business_name, b.address as business_address, b.city as business_city, b.title as business_name, b.address as business_address, b.city as business_city,
@ -248,6 +248,10 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
$builder->orderBy('s.to_subscription', 'asc'); $builder->orderBy('s.to_subscription', 'asc');
$query = $builder->get(); $query = $builder->get();
$result = $query->getResultArray(); $result = $query->getResultArray();
$lastQuery = $this->db->getLastQuery();
$finalQueryString = $lastQuery->getQuery();
echo $finalQueryString;
die;
return $result; return $result;
} }
public function getSubscriptionDetailsBySchemeName($selectedScheme, $downloadType){ public function getSubscriptionDetailsBySchemeName($selectedScheme, $downloadType){
@ -275,12 +279,16 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
$customerDetails = []; $customerDetails = [];
$processedCustomerIDs = []; $processedCustomerIDs = [];
$subscriptionIDs = [];
// Process the results if not empty // Process the results if not empty
if (!empty($result)) { if (!empty($result)) {
foreach ($result as $row) { foreach ($result as $row) {
// Check if the customer ID has already been processed // Check if the customer ID has already been processed
if (!in_array($row['customer_id'], $processedCustomerIDs)) { // if (!in_array($row['customer_id'], $processedCustomerIDs)) { } // previous if condition
if (!in_array($row['sub_id'], $subscriptionIDs)) {
$customerDetails[] = [ $customerDetails[] = [
'customer_id' => $row['customer_id'], 'customer_id' => $row['customer_id'],
'invoice_id' => $row['invoice_id'], 'invoice_id' => $row['invoice_id'],
@ -303,6 +311,7 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
'company_city' => $row['business_city'], 'company_city' => $row['business_city'],
'company_state' => $row['business_state'], 'company_state' => $row['business_state'],
'company_postal_code' => $row['business_postal_code'], 'company_postal_code' => $row['business_postal_code'],
'membership_id' => $row['membership_id']
]; ];
// Add the customer ID to the set of processed IDs // Add the customer ID to the set of processed IDs
@ -328,11 +337,14 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
// $builder->where('LOWER(category.name)', strtolower($categoryName)); // $builder->where('LOWER(category.name)', strtolower($categoryName));
$builder = $this->db->table('books'); $builder = $this->db->table('books');
$builder->select('GROUP_CONCAT(books.book_id ORDER BY books.book_id) AS book_ids'); // $builder->select('GROUP_CONCAT(books.book_id ORDER BY books.book_id) AS book_ids');
$builder->select('GROUP_CONCAT(DISTINCT books.book_id ORDER BY books.book_id) AS book_ids');
$builder->select('books.short_code, books.title'); $builder->select('books.short_code, books.title');
$builder->join('book_categories', 'books.book_id = book_categories.book_id', 'left'); $builder->join('book_categories', 'books.book_id = book_categories.book_id', 'left');
$builder->join('category', 'category.id = book_categories.category_id', 'left'); $builder->join('category', 'category.id = book_categories.category_id', 'left');
$builder->join('invoiceitems', 'books.book_id = invoiceitems.product', 'left');
$builder->where('LOWER(category.name)', strtolower($categoryName)); $builder->where('LOWER(category.name)', strtolower($categoryName));
$builder->where('invoiceitems.product IS NOT NULL', null, false);
$builder->groupBy('books.short_code'); $builder->groupBy('books.short_code');
$query = $builder->get(); $query = $builder->get();

View File

@ -36,6 +36,8 @@
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
console.error("AJAX Error:", error); console.error("AJAX Error:", error);
$('#target-div').html("");
$("#params").val('');
} }
}); });

View File

@ -67,7 +67,9 @@
<div class="invoice"> <div class="invoice">
<div class="bill-details"> <div class="bill-details">
<!-- <div style="margin-bottom:5px;">To:</div> --> <!-- <div style="margin-bottom:5px;">To:</div> -->
<?= $customerDetails[$i]['customer_name'] ?><br> <?= $customerDetails[$i]['customer_name'] ?>
<?= isset($customerDetails[$i]['membership_id']) ? '('.$customerDetails[$i]['membership_id'].')' : "" ?>
<br>
<?= $customerDetails[$i]['address_1'] ?>,<br> <?= $customerDetails[$i]['address_1'] ?>,<br>
<?php if (!empty($customerDetails[$i]['address_2'])) : ?> <?php if (!empty($customerDetails[$i]['address_2'])) : ?>
<?= $customerDetails[$i]['address_2'] ?>,<br> <?= $customerDetails[$i]['address_2'] ?>,<br>