FIX_ISSUES IN REPORTS

This commit is contained in:
Srinivas-Saravanan 2024-11-28 17:06:19 +05:30
parent 4cb8a45994
commit f6759ed8b6
10 changed files with 115 additions and 65 deletions

View File

@ -219,17 +219,20 @@ public function payment_success() {
$save_invoice->update_number_formatting($update_invoice_numbering);
//get the invoice id to insert into the invoiceitems table
$invoice_id = $model->select('invoice_id')->where('invoice_number',$invoice_number)->first();
//var_dump($invoice_id['invoice_id']);die();
$previous_to_sub = $subModel->select('to_subscription')->where('customer_id',$customer_id)->where('membership_id',$past_membership_id)->first();
$new_subscription_date = $previous_to_sub['to_subscription'];
// Create a DateTime object from the existing subscription date
$date = new \DateTime($new_subscription_date);
$currentDate = date('Y-m-d');
if ($currentDate > $new_subscription_date){
$fsubscription = $currentDate; //if subscription is already expired
// Add one day
}else{
// Add one day from previous subscrption's to subscription date
$fsubscription = date('Y-m-d', strtotime('+1 day', strtotime($new_subscription_date)));
}
$date->add(new \DateInterval('P1D'));
// Format the date (optional, if you need it in a specific format)
$fsubscription = $date->format('Y-m-d');
$tsubscription = date('Y-m-d', strtotime('+1 year', strtotime($fsubscription)));
$data['item_details'] = 3;
$requestData = [

View File

@ -194,7 +194,8 @@ class HomeModel extends Model
S.to_subscription, S.from_subscription, BK.title, BK.short_code, BK.book_id, S.membership_id,
DATEDIFF(S.to_subscription, CURDATE()) as countdays,
DATE_FORMAT(S.to_subscription, "%d/%m/%Y") as to_subscription_date_format,
( NHC.sent_time ) as email_last_notify_on')
S.is_renew,
( NHC.sent_time ) as email_last_notify_on,(select is_renew from subscription as sub where S.sub_id = sub.is_renew)as renewed')
->where('S.to_subscription >=', $now)
->where('S.to_subscription <=', $last30days)
->where('S.isactive', 1)

View File

@ -135,7 +135,7 @@ public function getJoinedData($where, $orderby = [])
->join('business as B', 'B.business_id = I.business_id', 'left')
->join('users as U1', 'U1.user_id = I.created_by', 'left')
->join('users as U2', 'U2.user_id = I.updated_by', 'left')
->select('I.invoice_id,I.wp_api_order_id,I.invoice_number, I.customer_id,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name ,C.mobile_no, I.invoice_date, I.due_date, I.subtotal, I.tax, I.discount, I.total_amount,I.status, I.payment_status, I.order_number, I.payment_method,I.invoice_type, I.event_id,E.event_name, I.business_id,B.title as business_name,DATE_FORMAT(I.created_on, "%d/%m/%Y") as created_on_format,I.created_on, I.created_by,CONCAT_WS(" ", U1.first_name, U1.last_name) as created_by_name,DATE_FORMAT(I.updated_on, "%d/%m/%Y") as updated_on_format, I.updated_by,CONCAT_WS(" ", U2.first_name, U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile,I.shipping_address_id,I.shipping_address,I.billing_address_id,I.billing_address,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no,S.from_subscription,S.to_subscription,DATEDIFF(S.to_subscription, S.from_subscription) as subscription_in_days,S.scheme_id')
->select('I.invoice_id,I.wp_api_order_id,I.invoice_number, I.customer_id,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name ,C.mobile_no, I.invoice_date, I.due_date, I.subtotal, I.tax, I.discount, I.total_amount,I.status, I.payment_status, I.order_number, I.payment_method,I.invoice_type, I.event_id,E.event_name, I.business_id,B.title as business_name,DATE_FORMAT(I.created_on, "%d/%m/%Y") as created_on_format,I.created_on, I.created_by,CONCAT_WS(" ", U1.first_name, U1.last_name) as created_by_name,DATE_FORMAT(I.updated_on, "%d/%m/%Y") as updated_on_format, I.updated_by,CONCAT_WS(" ", U2.first_name, U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile,I.shipping_address_id,I.shipping_address,I.billing_address_id,I.billing_address,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no,S.from_subscription,S.to_subscription,DATEDIFF(S.to_subscription, S.from_subscription) as subscription_in_days,S.scheme_id,(SELECT is_renew FROM subscription as sub WHERE S.sub_id = sub.is_renew LIMIT 1) as renewed')
->where($where);
// if (!empty($orderby)) {
// $query->orderBy($orderby[0], $orderby[1]);
@ -293,7 +293,7 @@ public function getJoinedData($where, $orderby = [])
->join('books as BK', 'BK.book_id = S.scheme_id', 'left')
->join('book_categories as BC', 'BC.book_id = S.scheme_id', 'left')
->join('category as CM', 'CM.id = BC.category_id', 'left')
->select('S.customer_id,BK.short_code,S.membership_id ,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name, S.sub_id, S.scheme_id, DATE_FORMAT(S.from_subscription, "%d/%m/%Y") AS formatted_from_subscription, DATE_FORMAT(S.to_subscription, "%d/%m/%Y") AS formatted_to_subscription, S.from_subscription, S.to_subscription,S.isactive,S.is_renew, S.created_on, CM.name ,BK.title, BK.book_id')
->select('S.customer_id,BK.short_code,S.membership_id,S.status ,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name, S.sub_id, S.scheme_id, DATE_FORMAT(S.from_subscription, "%d/%m/%Y") AS formatted_from_subscription, DATE_FORMAT(S.to_subscription, "%d/%m/%Y") AS formatted_to_subscription, S.from_subscription, S.to_subscription,S.isactive,S.is_renew, S.created_on, CM.name ,BK.title, BK.book_id')
->where('LOWER(CM.name)', strtolower($category))
->where('S.customer_id', $id)
->orderBy('S.to_subscription', 'ASC')

View File

@ -15,7 +15,7 @@ public function getAllSubscribersWithNames($where)
{
$builder = $this->db->table('subscription');
$builder->select('subscription.*, books.title,books.short_code, books.isactive, CONCAT_WS(" ", customers.first_name, customers.last_name) as customer_name');
$builder->select('subscription.*, books.title,books.short_code, books.isactive, CONCAT_WS(" ", customers.first_name, customers.last_name) as customer_name,(SELECT is_renew FROM subscription as sub WHERE subscription.sub_id = sub.is_renew LIMIT 1)as renewed');
$builder->join('books', 'books.book_id = subscription.scheme_id');
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
$builder->where($where);

View File

@ -17,7 +17,7 @@
</div>
<?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<div id = 'errorAlert' class="alert alert-danger alert-dismissible fade show" role="alert">
<?= session('error') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
@ -59,7 +59,7 @@
</div>
<div class="form-group col-md-4">
<label for="cmail" class="col-form-label">Email<span class="text-danger"> </span></label>
<input type="text" class="form-control" id="cmail" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" onkeyup="validateEmail(this.value)" onchange="checkExisting(this.value,'email','cmail')" />
<input type="text" class="form-control" id="cmail" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" onChange="validateEmail(this.value)" onchange="checkExisting(this.value,'email','cmail')" />
<span id="emailValidationMessage"></span>
</div>
</div>
@ -411,6 +411,9 @@
$("#szip").val("").prop("readonly", false);
$("#scustomer_address_id").val("") // Hidden Field ressetted bcoz Adress history
}
var alert = $('#errorAlert').val();
console.log("The alert message is "+alert);
$('#myForm').parsley().validate();
});
$("#bcountry").on("change", function() {
var country = $("#bcountry").val();
@ -482,7 +485,6 @@
html.find('input#sistate0').attr('id', 'sistate' + j).css("display", "block").val(sarray[i]['state']);
html.find('select#sdstate0').attr('id', 'sdstate' + j).css("display", "none").val('');
}
html.find('input#szip').val(sarray[i]['postal_code']);
if (i !== 0) {
html.find(".shipping-addr-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 shipping-addr-add-more'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 shipping-addr-remove'>- Remove </a>");

View File

@ -140,24 +140,25 @@
<h4 class="header-title mt-1">Expiring Membership List in next 30 days</h4>
<div class="conversation-list" data-simplebar style="max-height: 255px !important">
<div class="table-responsive">
<table class="table table-sm table-centered mb-0 font-14">
<thead class="thead-light">
<tr>
<th style="width: 5%;">#</th>
<th style="width: 20%;">Name</th>
<th style="width: 20%;">Mobile No</th>
<th style="width: 20%;">Email</th>
<th style="width: 50%;">Scheme Name</th>
<th style="width: 25%;">Expiring In</th>
<th style="width: 25%;">Notification On</th>
<th style="display: none;">member id</th>
</tr>
</thead>
<table class="table table-sm table-centered mb-0 font-14" style="table-layout: fixed;">
<thead class="thead-light">
<tr>
<th style="width: 10%;">S.No</th>
<th style="width: 20%;">Name</th>
<th style="width: 20%;">Mobile No</th>
<th style="width: 35%;">Email</th>
<th style="width: 30%;">Scheme Name</th> <!-- Reduced width -->
<th style="width: 15%;">Expires By</th>
<th style="width: 25%; text-align:center">Notification On</th> <!-- Increased width -->
<th style="display: none;">member id</th>
</tr>
</thead>
<tbody>
<?php
$tempinx = 0;
if(!empty($expiring_membership)):
foreach ($expiring_membership as $e) :
if ($e['renewed'] == null):
$daysincount = (int)$e['countdays'];
$daysincountstring = ($daysincount == 0 ? 'Today' : ($daysincount == 1 ? 'Tomorrow' : $daysincount . ' days')); ?>
<tr>
@ -179,7 +180,7 @@
</td>
<td style="display: none;"><?= $e['membership_id']; ?></td>
</tr>
<?php endforeach;
<?php endif;endforeach;
else : ?>
<tr>
<td colspan="7"><center>No data found</center></td>

View File

@ -96,14 +96,18 @@ input[type=number] {
top:35px;
}
#customerName~.parsley-errors-list{
position: relative;
top: 70px !important;
z-index: 0;
position: absolute;
color: red;
font-size: 12px;
top: 100%; /* Below the input field */
left: 0;
}
#loadShippingDropdown~.parsley-errors-list{
position: relative;
top: 70px !important;
z-index: 0;
position: absolute;
color: red;
font-size: 12px;
top: 100%; /* Below the input field */
left: 0;
}
#fromsubcription~.parsley-errors-list{
position: absolute;
@ -215,7 +219,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="form-group col-md-5">
<label for="loadShippingDropdown">Shipping Address<span class="text-danger"> *</span></label>
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id" data-toggle="select2" onchange="get_customer_shipping_details(this.value)" required>
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id" data-toggle="select2" onchange="get_customer_shipping_details(this.value)" required>
<option value="">Select an address</option>
</select>
</div>
@ -1595,9 +1599,10 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
$(".subscribedetails").show(); // Change this line to use the class selector
let messages = "Earlier Membership : <br>";
for (let i = 0; i < cm.length; i++) {
let text1 = cm[i].is_renew == 1 ? " - Renewal" : "";
let text2 = cm[i].isactive == 1 ? " - Active" : " - Draft ";
messages += cm[i].title + "<br> ( From: " + cm[i].formatted_from_subscription + " To: " + cm[i].formatted_to_subscription + " )" + text1 + text2 + " <br>";
let text1 = cm[i].is_renew > 1 ? " - Renewed" : "";
let text2 = cm[i].isactive != 1 ? " - Draft" : "";
let text3 = cm[i].status == 0 ? ' - Expired ': " - Active";
messages += cm[i].title + "<br> ( From: " + cm[i].formatted_from_subscription + " To: " + cm[i].formatted_to_subscription + " )" + text1 + text2 + text3+ " <br>";
}
// $("#schemeName").text(message);
$('#membership_id').empty();
@ -1607,33 +1612,62 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
membership_id = cm[i].membership_id;
console.log(membership_id);
$('#membership_id').append('<option value="' + membership_id+i + '">' +cm[i].short_code + ' - '+ membership_id+' ' +cm[i].formatted_from_subscription + " To: " + cm[i].formatted_to_subscription +'</option>');
if (cm[i].is_renew>0){
$('#membership_id').append('<option value="' + membership_id+i + '">' +cm[i].short_code + ' - '+ membership_id+' ' +cm[i].formatted_from_subscription + " To: " + cm[i].formatted_to_subscription +'</option>');
}
}
$('#membership_id').on('change', function () {
var output = $('#membership_id').val();console.log(membership_choice);
var membership_choice = output.charAt(output.length-1);
var rawDate = cm[membership_choice].formatted_to_subscription;
var dateParts = rawDate.split('/');
var prev_fsubscription = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
var currentDate = new Date();
prev_fsubscription.setDate(prev_fsubscription.getDate() + 1);
var fsubscription = (prev_fsubscription.getDate()).toString().padStart(2, '0') + '/' +
(prev_fsubscription.getMonth() + 1).toString().padStart(2, '0') + '/' +
prev_fsubscription.getFullYear();
// Format current date as dd-mm-yy
var formattedDate = ('0' + currentDate.getDate()).slice(-2) + '-' +
('0' + (currentDate.getMonth() + 1)).slice(-2) + '-' +
currentDate.getFullYear().toString().slice(-2);
// Parse rawDate into a Date object
var rawDateParts = rawDate.split('/');
var rawDateObj = new Date(rawDateParts[2], rawDateParts[1] - 1, rawDateParts[0]);
var fsubscription, tsubscription;
if (currentDate > rawDateObj) {
// Start from current date
fsubscription = ('0' + currentDate.getDate()).slice(-2) + '/' +
('0' + (currentDate.getMonth() + 1)).slice(-2) + '/' +
currentDate.getFullYear();
var tsubscriptionDate = new Date(currentDate);
tsubscriptionDate.setFullYear(tsubscriptionDate.getFullYear() + 1);
tsubscription = ('0' + tsubscriptionDate.getDate()).slice(-2) + '/' +
('0' + (tsubscriptionDate.getMonth() + 1)).slice(-2) + '/' +
tsubscriptionDate.getFullYear();
} else {
// Start from rawDate + 1 day
rawDateObj.setDate(rawDateObj.getDate() + 1);
fsubscription = ('0' + rawDateObj.getDate()).slice(-2) + '/' +
('0' + (rawDateObj.getMonth() + 1)).slice(-2) + '/' +
rawDateObj.getFullYear();
rawDateObj.setFullYear(rawDateObj.getFullYear() + 1);
tsubscription = ('0' + rawDateObj.getDate()).slice(-2) + '/' +
('0' + (rawDateObj.getMonth() + 1)).slice(-2) + '/' +
rawDateObj.getFullYear();
}
// Update input fields
$('#fromsubcription').val(fsubscription).prop('readonly', true);
prev_fsubscription.setFullYear(prev_fsubscription.getFullYear() + 1);
var tsubscription = (prev_fsubscription.getDate()).toString().padStart(2, '0') + '/' +
(prev_fsubscription.getMonth() + 1).toString().padStart(2, '0') + '/' +
prev_fsubscription.getFullYear();
$('#tosubcription').val(tsubscription).prop('readonly', true);
$('#tosubcription').val(tsubscription).prop('readonly', true);
$('#myForm').parsley().validate();
$('#book0').empty();
$('#book0').append('<option value="<?= $books[1]->book_id ?>"><?= $books[1]->title; ?></option>');
$('#book0').prop('readonly',true);
var element = $('#book0')[0]; // Get the actual DOM element (not the value)
displayBookTag(element, 0);
$('#myForm').parsley().validate();
});
showAlert(messages.trim());
} else {
@ -1740,11 +1774,16 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
// When the "Save as Approved" button is clicked
document.getElementById('saveApprovedButton').addEventListener('click', function() {
// Show the payment modal
const isParsleyValid = $(myForm).parsley().validate();
// Check both browser-native validity and Parsley validation
if (isParsleyValid) {
// Show the payment modal if the form is valid
$('#paymentModal').modal('show');
// When the "Confirm Payment" button in the modal is clicked
// Get the selected mode of payment
} else {
// Focus on the first invalid field (optional for better UX)
$(myForm).find('.parsley-error').first().focus();
}
var selectedPaymentMode = document.getElementById('paymentMode').value;
// You can now use the selected payment mode as needed

View File

@ -27,6 +27,8 @@
background-color: transparent; /* Transparent container */
width: 190px; /* Card width */
height: 50px; /* Card height */
padding-left: 20px;
}
.nav {
@ -49,7 +51,7 @@
<!-- Form Section -->
<div class="col-md-5 offset-md-3">
<form action="<?php echo base_url('expired_customer_report'); ?>" method="post">
<form action="<?php echo base_url('received_payments_report'); ?>" method="post">
<div class="form-group">
<div class="row">
<div class="col-md-7">
@ -69,11 +71,12 @@
<div>
<ul class="nav">
<?php foreach ($payment_data['result2'] as $key => $amount) {
if ($key != '' && $key != null) { ?>
if ($key != '' && $key != null) {
$displayKey = str_ireplace('banktransfer', 'BANK TRANSFER', strtoupper($key));?>
<li>
<div class="card-summary">
<button id = 'payment_method_button' class="payment-button">
<?= strtoupper($key) ?> <br> ₹<?= $amount ?>
<button id = 'payment_method_button' class="payment-button" style="font-weight: 401;">
<?= $displayKey ?> <br> ₹<?= $amount ?>
</button>
</div>
</li>

View File

@ -9,7 +9,7 @@
<!-- Form Section -->
<div class="col-md-5 offset-md-3">
<form action="<?php echo base_url('expired_customer_report'); ?>" method="post">
<form action="<?php echo base_url('book_publishwise_Report'); ?>" method="post">
<div class="form-group">
<div class="row">
<div class="col-md-7">

View File

@ -71,23 +71,24 @@
if ($currentDate > $toDateTime) {
$daysRemaining = -$daysRemaining;
}
log_message('info',json_encode($row['renewed']));
if ($daysRemaining < 0) {
$class = 'text-danger';
$message = "Expired";
$message = "Expired" . ($row['renewed'] != null ? " " . '(Renewed)' : '');
} elseif ($daysRemaining == 0) {
$class = 'text-danger';
$message = "Expires Today";
$message = "Expires Today" . ($row['renewed'] != null ? " " . '(Renewed)' : '');
} elseif ($daysRemaining == 1) {
$class = 'text-warning';
$message = "Expires Tomorrow";
$message = "Expires Tomorrow" . ($row['renewed'] != null ? " " . '(Renewed)' : '');
} elseif ($daysRemaining <= 7) {
$class = 'text-warning';
$message = "Expires in $daysRemaining days";
$message = "Expires in $daysRemaining days". ($row['renewed'] != null ? " " . '(Renewed)' : '');
} else {
$class = 'text-success';
$message = "Expires in $daysRemaining days";
$message = "Expires in $daysRemaining days". ($row['renewed'] != null ? " " . '(Renewed)' : '');
}
?>
<tr>
<td hidden><?= $row['invoice_date'] ?></td>