FIX_bug fixes : ps

This commit is contained in:
VE10-Sanjeev 2024-07-02 07:25:46 +00:00
parent 4148d76e2c
commit 7faaac70a8
4 changed files with 68 additions and 22 deletions

View File

@ -1202,7 +1202,7 @@ class Invoice extends BaseController
## Invoice Line Item.. ## Invoice Line Item..
$invoice_child_id = $requestData['invoice_child_id']; $invoice_child_id = $requestData['invoice_child_id'];
$count = count($invoice_child_id); $count = count($invoice_child_id);
if ($count > 0) { if ($count > 0) {
for ($x = 0; $x < $count; $x++) { for ($x = 0; $x < $count; $x++) {
if (!empty($requestData['item_details'][$x])) { if (!empty($requestData['item_details'][$x])) {
@ -1249,7 +1249,7 @@ class Invoice extends BaseController
$subscription_where = [ $subscription_where = [
'customer_id' => $customer_id, 'customer_id' => $customer_id,
'invoice_id' => $invoice_id, 'invoice_id' => $invoice_id,
'scheme_id' => $product_id 'isactive' => 1
]; ];
} }
$subs_aff_row = $model->updateData('subscription', $subscription_data, $subscription_where); $subs_aff_row = $model->updateData('subscription', $subscription_data, $subscription_where);

View File

@ -1287,7 +1287,13 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
var fromDateValue = "<?= isset($invoice_item_details[0]['from_subscription']) ? $invoice_item_details[0]['from_subscription'] : ""; ?>"; var fromDateValue = "<?= isset($invoice_item_details[0]['from_subscription']) ? $invoice_item_details[0]['from_subscription'] : ""; ?>";
if (fromDateValue != '') { if (fromDateValue != '') {
updateToDateMinDate(fromDateValue) fromDateValue = formatDate(fromDateValue);
updateToDateMinDate(fromDateValue);
}
function formatDate(dateString) {
const dateParts = dateString.split('-');
return `${dateParts[2]}/${dateParts[1]}/${dateParts[0]}`;
} }
$("#editAddressesCheckbox").on("change", function() { $("#editAddressesCheckbox").on("change", function() {
@ -1555,14 +1561,22 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
invoiceDateInput.setAttribute("min", minDate); invoiceDateInput.setAttribute("min", minDate);
invoiceDateInput.setAttribute("max", maxDate); invoiceDateInput.setAttribute("max", maxDate);
const fromsubcriptionDateInput = document.getElementById("fromsubcription"); // const fromsubcriptionDateInput = document.getElementById("fromsubcription");
fromsubcriptionDateInput.setAttribute("max", maxDate); // fromsubcriptionDateInput.setAttribute("max", maxDate);
document.getElementById("fromsubcription").onchange = function() {
const toDateInput = document.getElementById('tosubcription');
toDateInput.value = ''; // Clear the value of the "To Subscription" field
const fromDateValue = this.value;
updateToDateMinDate(fromDateValue);
};
function updateToDateMinDate(fromDateValue) { function updateToDateMinDate(fromDateValue) {
const toDateInput = document.getElementById('tosubcription'); const toDateInput = document.getElementById('tosubcription');
toDateInput.min = fromDateValue; toDateInput.setAttribute('data-date-start-date', fromDateValue); // Optional if you're using this attribute for something else
// toDateInput.setAttribute('data-date-end-date', fromDateValue);
toDateInput.setAttribute('data-date-start-date', fromDateValue); // Update the minimum date for the datepicker
$(toDateInput).datepicker('setStartDate', fromDateValue); $(toDateInput).datepicker('setStartDate', fromDateValue);
} }
@ -1993,7 +2007,34 @@ function saveInvoiceCustomer() {
}); });
</script> </script>
<script> <script>
function validateForm() {
const fromDateInput = document.getElementById('fromsubcription');
const toDateInput = document.getElementById('tosubcription');
const invoiceDate = document.getElementById('invoiceDate');
if (invoiceDate.value.trim() === '') {
alert('Please select a invoice date.');
return false;
}
// Check if From Subscription field is empty
if (fromDateInput.value.trim() === '') {
alert('Please select a From Subscription date.');
return false;
}
// Check if To Subscription field is empty
if (toDateInput.value.trim() === '') {
alert('Please select a To Subscription date.');
return false;
}
// Additional validation logic if needed...
return true; // Form is valid
}
$('#saveButton').click(function() { $('#saveButton').click(function() {
if (validateForm()) {
var formData = $("#myForm").serialize(); var formData = $("#myForm").serialize();
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
@ -2001,10 +2042,12 @@ $('#saveButton').click(function() {
dataType: 'json', dataType: 'json',
url: '<?php echo base_url("update_approval_subscription"); ?>', url: '<?php echo base_url("update_approval_subscription"); ?>',
success: function(response) { success: function(response) {
if (response.status) { if (response.success) {
alert(response.message); alert(response.message);
console.log(response); console.log(response);
setTimeout(function(){ window.location.href = '" . base_url("subscribers_list") . "'; }, 250); setTimeout(function() {
window.location.href = "<?php echo base_url('subscribers_list'); ?>";
}, 250);
} else { } else {
alert(response.message); alert(response.message);
console.log(response); // Logging the response from backend console.log(response); // Logging the response from backend
@ -2014,7 +2057,7 @@ $('#saveButton').click(function() {
console.error(error); // Logging any errors console.error(error); // Logging any errors
} }
}); });
}); }});
</script> </script>

View File

@ -390,7 +390,7 @@
<table class="footer-table mt-3" width="100%"> <table class="footer-table mt-3" width="100%">
<tr> <tr>
<td> <td>
<center><small>WhatsApp No: 96004 78526 | Email: vijayabharatham78@gmail.com | Website: www.vijayabharatham.org</small></center> <center><small>WhatsApp No: 8939149466 | Email: contact@vijayabharathambooks.com | Website: www.vijayabharathambooks.com</small></center>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -51,28 +51,31 @@
$invoice_date = date('d/m/Y', strtotime($row['invoice_date'])); $invoice_date = date('d/m/Y', strtotime($row['invoice_date']));
$from_date = date('d/m/Y', strtotime($row['from_subscription'])); $from_date = date('d/m/Y', strtotime($row['from_subscription']));
$to_date = date('d/m/Y', strtotime($row['to_subscription'])); $to_date = date('d/m/Y', strtotime($row['to_subscription']));
// $daysRemaining = (int)$row['subscription_in_days'];
// $fromDateTime = (new DateTime($row['from_subscription']))->format('Y-m-d'); // Calculate days remaining
// $toDateTime = (new DateTime($row['to_subscription']))->format('Y-m-d'); // if ($currentDate < $fromDateTime) {
// $currentDate = (new DateTime())->format('Y-m-d'); // $interval = $fromDateTime->diff($toDateTime);
// } else {
// $interval = $currentDate->diff($toDateTime);
// }
$fromDateTime = new DateTime($row['from_subscription']); $fromDateTime = new DateTime($row['from_subscription']);
$toDateTime = new DateTime($row['to_subscription']); $toDateTime = new DateTime($row['to_subscription']);
$currentDate = new DateTime(); $currentDate = new DateTime();
$currentDate->setTime(0, 0, 0);
$toDateTime->setTime(0, 0, 0);
// Calculate days remaining // Calculate days remaining
$interval = $currentDate->diff($toDateTime); $interval = $currentDate->diff($toDateTime);
$daysRemaining = $interval->days; $daysRemaining = $interval->days;
// Adjust class and message based on remaining days
if ($currentDate > $toDateTime) { if ($daysRemaining <= 0) {
$class = 'text-danger'; $class = 'text-danger';
$message = "Expired"; $message = "Expired";
} elseif ($currentDate == $toDateTime) {
$class = 'text-danger';
$message = "Expired on Today";
} elseif ($daysRemaining == 1) { } elseif ($daysRemaining == 1) {
$class = 'text-warning'; $class = 'text-warning';
$message = "Expires in 1 day"; $message = "Expires Tomorrow";
} elseif ($daysRemaining <= 7) { } elseif ($daysRemaining <= 7) {
$class = 'text-warning'; $class = 'text-warning';
$message = "Expires in $daysRemaining days"; $message = "Expires in $daysRemaining days";