CHANGE_ALL_PLACE_DATE_FORMAT
This commit is contained in:
parent
bf1234396b
commit
56b302c855
@ -67,7 +67,7 @@
|
||||
|
||||
<td><?php echo format_indian_number($file['amount'])?></td>
|
||||
<td class="reload">
|
||||
<?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i a') ?> by <?php echo get_username($file['created_by']) ?>
|
||||
<?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd/m/Y') ?> by <?php echo get_username($file['created_by']) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($file['status'] == 'failed') { ?>
|
||||
|
||||
@ -508,7 +508,7 @@ $(document).ready(function() {
|
||||
const showExpired = $('#chk-show-expired').is(':checked');
|
||||
|
||||
var startDatePicker = flatpickr("#start_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
dateFormat: "d/m/Y",
|
||||
defaultDate: today,
|
||||
allowInput: false,
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
@ -521,7 +521,7 @@ $(document).ready(function() {
|
||||
|
||||
// Initialize Flatpickr for the start date with today's date
|
||||
var openDatePicker = flatpickr("#open_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
dateFormat: "d/m/Y",
|
||||
defaultDate: today,
|
||||
allowInput: false,
|
||||
});
|
||||
@ -532,20 +532,20 @@ $(document).ready(function() {
|
||||
closeDate.setDate(closeDate.getDate() - 1); // Set end date to last day of next year
|
||||
|
||||
var endDatePicker = flatpickr("#end_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
dateFormat: "d/m/Y",
|
||||
defaultDate: closeDate,
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
// Initialize Flatpickr for the end date with the calculated end date
|
||||
var closeDatePicker = flatpickr("#close_date", {
|
||||
dateFormat: "d-m-Y",
|
||||
dateFormat: "d/m/Y",
|
||||
defaultDate: today,
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
// var reminderDatePicker = flatpickr("#reminder_date", {
|
||||
// dateFormat: "d-m-Y",
|
||||
// dateFormat: "d/m/Y",
|
||||
// defaultDate: today,
|
||||
// allowInput: false
|
||||
// });
|
||||
@ -630,7 +630,7 @@ $(document).ready(function() {
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<!-- <td>${tpaValue}</td> -->
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
<td>${formatDisplayDate(item.policy_start_date)} - ${formatDisplayDate(item.policy_end_date)}</td>
|
||||
<!-- <td style="text-align: center;">${(enrollmentStatus)}</td> -->
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
@ -785,6 +785,14 @@ $("#policy_form").submit(function(event) {
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var formData = new FormData($('#policy_form')[0]);
|
||||
formData.set('policy_start_date', toBackendDateFormat($('#start_date').val()));
|
||||
formData.set('policy_end_date', toBackendDateFormat($('#end_date').val()));
|
||||
if ($('#open_date').val()) {
|
||||
formData.set('open_date', toBackendDateFormat($('#open_date').val()));
|
||||
}
|
||||
if ($('#close_date').val()) {
|
||||
formData.set('close_date', toBackendDateFormat($('#close_date').val()));
|
||||
}
|
||||
var policy_form_action = $('#policy_form_action').val();
|
||||
console.log(formData + 'form data');
|
||||
$.ajax({
|
||||
@ -893,7 +901,7 @@ $("#policy_form").submit(function(event) {
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<!-- <td>${tpaValue}</td> -->
|
||||
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
<td>${formatDisplayDate(item.policy_start_date)} - ${formatDisplayDate(item.policy_end_date)}</td>
|
||||
<!-- <td style="text-align: center;">${(enrollmentStatus)}</td> -->
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
@ -1352,33 +1360,89 @@ $('body').on('click', '.btnOpenEnroll', function() {
|
||||
|
||||
});
|
||||
|
||||
//for date convert to indian formate like this 'yyyy-mm-dd' to this 'dd-mm-yyyy'
|
||||
// Convert stored/API dates to d/m/Y for display and form inputs
|
||||
function rearrangeDateFormat(inputDate) {
|
||||
|
||||
console.log('inputDate', inputDate)
|
||||
// Check if inputDate is a string and not empty
|
||||
if (typeof inputDate === 'string' && inputDate.trim() !== '') {
|
||||
var dateComponents = inputDate.split("-");
|
||||
|
||||
// Check if dateComponents has the expected number of parts
|
||||
if (dateComponents.length === 3) {
|
||||
var rearrangedDate = dateComponents[2] + "-" + dateComponents[1] + "-" + dateComponents[0];
|
||||
return rearrangedDate;
|
||||
} else {
|
||||
// Handle unexpected date format
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
// Handle the case where inputDate is not a valid string
|
||||
return '';
|
||||
}
|
||||
return formatDisplayDate(inputDate);
|
||||
}
|
||||
|
||||
function formatDisplayDate(inputDate) {
|
||||
if (inputDate === null || inputDate === undefined) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var value = String(inputDate).trim();
|
||||
if (value === '' || value === 'null') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (/^\d{4}-\d{2}-\d{2}/.test(value)) {
|
||||
var ymdParts = value.split('-');
|
||||
return ymdParts[2] + '/' + ymdParts[1] + '/' + ymdParts[0];
|
||||
}
|
||||
|
||||
if (/^\d{1,2}-\d{1,2}-\d{4}$/.test(value)) {
|
||||
return value.replace(/-/g, '/');
|
||||
}
|
||||
|
||||
var parsedDate = new Date(value);
|
||||
if (!isNaN(parsedDate.getTime())) {
|
||||
var day = String(parsedDate.getDate()).padStart(2, '0');
|
||||
var month = String(parsedDate.getMonth() + 1).padStart(2, '0');
|
||||
var year = parsedDate.getFullYear();
|
||||
return day + '/' + month + '/' + year;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function toBackendDateFormat(displayDate) {
|
||||
if (!displayDate) {
|
||||
return displayDate;
|
||||
}
|
||||
|
||||
var value = String(displayDate).trim();
|
||||
if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(value)) {
|
||||
return value.replace(/\//g, '-');
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function parsePolicyDate(inputDate) {
|
||||
if (!inputDate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var value = String(inputDate).trim();
|
||||
if (/^\d{4}-\d{2}-\d{2}/.test(value)) {
|
||||
return new Date(value);
|
||||
}
|
||||
|
||||
var slashParts = value.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
||||
if (slashParts) {
|
||||
return new Date(slashParts[3], slashParts[2] - 1, slashParts[1]);
|
||||
}
|
||||
|
||||
var hyphenParts = value.match(/^(\d{1,2})-(\d{1,2})-(\d{4})$/);
|
||||
if (hyphenParts) {
|
||||
return new Date(hyphenParts[3], hyphenParts[2] - 1, hyphenParts[1]);
|
||||
}
|
||||
|
||||
var parsedDate = new Date(value);
|
||||
return isNaN(parsedDate.getTime()) ? null : parsedDate;
|
||||
}
|
||||
|
||||
function checkDateStatus(inputDate, bg = false) {
|
||||
|
||||
var givenDate = new Date(inputDate);
|
||||
var givenDate = parsePolicyDate(inputDate);
|
||||
var currentDate = new Date();
|
||||
if (!givenDate) {
|
||||
return bg ? '' : '';
|
||||
}
|
||||
|
||||
if (bg != false) {
|
||||
if (givenDate < currentDate) {
|
||||
@ -2149,7 +2213,7 @@ function getClientPolicyDataForEdit(client_policy_id) {
|
||||
$('#open_date').val(rearrangeDateFormat(res.data.open_date));
|
||||
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
|
||||
$('#close_date').val(rearrangeDateFormat(res.data.close_date));
|
||||
$('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date));
|
||||
$('#reminder_date').val(res.data.reminder_date);
|
||||
$('#disclaimer').val(res.data.disclaimer);
|
||||
$('#gst_no').val(gst);
|
||||
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
|
||||
@ -2436,7 +2500,7 @@ $(document).ready(function () {
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<! -- <td>${tpaValue}</td> -->
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
<td>${formatDisplayDate(item.policy_start_date)} - ${formatDisplayDate(item.policy_end_date)}</td>
|
||||
<!-- <td style="text-align: center;">${(enrollmentStatus)}</td> -->
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
@ -2473,7 +2537,7 @@ $(document).ready(function () {
|
||||
<td>${policy_name_data}</td>
|
||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||
<! -- <td>${tpaValue}</td> -->
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
<td>${formatDisplayDate(item.policy_start_date)} - ${formatDisplayDate(item.policy_end_date)}</td>
|
||||
<! -- <td style="text-align: center;">${(enrollmentStatus)}</td> -->
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
<!-- <td><?php echo isset($file['policy_name']) ? $file['policy_name'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?> - <?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?></td> -->
|
||||
<td><?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?></td>
|
||||
<td><?= $file['action'] == 'enrollment' ? 'Enrolment' : $file['action'] ?></td>
|
||||
<td><?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i a') . ' by <strong>' . $file['first_name'] . '</strong>' ?>
|
||||
<td><?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd/m/Y') . ' by <strong>' . $file['first_name'] . '</strong>' ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
@ -176,7 +176,7 @@ th:first-child, td:first-child {
|
||||
<td><?php echo $employee['emp_code']; ?></td>
|
||||
<td><?php echo $employee['relationship']; ?></td>
|
||||
<td><?php echo $employee['gender']; ?></td>
|
||||
<td><?php echo date('d/M/Y', strtotime($employee['dob'])); ?></td>
|
||||
<td><?php echo date('d/m/Y', strtotime($employee['dob'])); ?></td>
|
||||
<?php /*
|
||||
|
||||
<!-- <td><?php //echo isset($employee['policy_type']) ? $employee['policy_type'] : ''; ?> - <?php echo isset($employee['policy_no']) ? $employee['policy_no'] : ''; ?></td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user