diff --git a/resources/views/form/rapport-titans/1790753526-37d85bd1-442d-4226-bacf-5f12e647373d.blade.php b/resources/views/form/rapport-titans/1790753526-37d85bd1-442d-4226-bacf-5f12e647373d.blade.php
index e60d2c30..c801644c 100644
--- a/resources/views/form/rapport-titans/1790753526-37d85bd1-442d-4226-bacf-5f12e647373d.blade.php
+++ b/resources/views/form/rapport-titans/1790753526-37d85bd1-442d-4226-bacf-5f12e647373d.blade.php
@@ -169,6 +169,13 @@
enctype="multipart/form-data">
@csrf
+
+
+
+
+
+
+
@if ($id)
@endif
@@ -285,7 +292,24 @@
enctype="multipart/form-data">
@csrf
+
+
+
+
+
+
+
+
+
+
+
+
+
{{-- --}}
@foreach ($questions as $question)
@@ -421,6 +445,66 @@
$('#execution-no_of_patients_screened').closest('.col-md-12').hide();
$('#execution-no_of_patients_screened').prop('required', false);
+ // =====================================================
+ // DRIVE COUNT FUNCTIONS
+ // =====================================================
+
+ // Plan Filling
+ function setPlanDriveCount() {
+
+ const activity = ($('#field-activity').val() || '').trim().toUpperCase();
+
+ $('#drive-count-plans-lhc').val('0');
+ $('#drive-count-execution-lhc').val('0');
+ $('#drive-count-plans-novel').val('0');
+ $('#drive-count-execution-novel').val('0');
+
+ if (activity === 'LHC') {
+
+ $('#drive-count-plans-lhc').val('1');
+
+ } else if (activity === 'NOVEL') {
+
+ $('#drive-count-plans-novel').val('1');
+ }
+ }
+
+
+ // Execution
+ function setExecutionDriveCount() {
+
+ const activity = ($('#execution-activity').val() || '').trim().toUpperCase();
+
+ $('#execution-drive-count-plans-lhc').val('0');
+ $('#execution-drive-count-execution-lhc').val('0');
+ $('#execution-drive-count-plans-novel').val('0');
+ $('#execution-drive-count-execution-novel').val('0');
+
+ if (activity === 'LHC') {
+
+ $('#execution-drive-count-execution-lhc').val('1');
+
+ } else if (activity === 'NOVEL') {
+
+ $('#execution-drive-count-execution-novel').val('1');
+ }
+ }
+
+
+ // Activity change - Plan
+ $('#field-activity').on('change.driveCount', function() {
+ setPlanDriveCount();
+ });
+
+
+ // Activity change - Execution
+ $('#execution-activity').on('change.driveCount', function() {
+ setExecutionDriveCount();
+ });
+
+
+ // Initialize Plan count
+ setPlanDriveCount();
$('#add-camp-btn').click(function() {
@@ -433,6 +517,7 @@
})
$('.edit-btn').click(function() {
+ $('#execution-mode').val('yes');
$('#execution-form-wrapper').show(100, () => {
$('#add-camp-btn').hide(0);
})
@@ -498,6 +583,10 @@
$('#execution-contact_id').val(docid)
$('#execution-id').val(selected['id'])
+
+ // Set execution drive count
+ setExecutionDriveCount();
+
// Show Patients Screened only for LHC during Execution
const selectedActivity = ($('#execution-activity').val() || '').trim().toUpperCase();
@@ -625,6 +714,12 @@
// $('#execution-'+k).val(selected[k]);
}
+
+
+
+ $('#execution-activity').on('change.driveCount', function() {
+ setExecutionDriveCount();
+ });
let docid = $('#execution-contact_id option').map(function() {
@@ -731,36 +826,67 @@
})
$('#report-form').on('submit', function(event) {
-
- event.preventDefault();
- $("#pageloader").fadeIn();
- $.ajax({
- type: "POST",
- url: '/form/ajaxsubmit',
- data: new FormData($('#report-form')[0]),
- processData: false,
- contentType: false,
- success: function(data) {
- $("#pageloader").fadeOut();
- if (data.status == 'success') {
- Swal.fire({
- title: 'Great!',
- text: 'Your data is successfully submitted!',
- icon: 'success'
- })
- window.location.reload();
- //$('#report-form').trigger("reset");
- } else {
- Swal.fire({
- icon: 'error',
- title: 'Data not submitted',
- text: 'Something went wrong, please try again after some time!'
- })
- }
- },
- });
- });
+ // Get the currently selected activity
+ const activity = ($('#field-activity').val() || '').trim().toUpperCase();
+
+ // Reset all Plan/Execution counters
+ $('#count-plans-lhc').val('0');
+ $('#count-execution-lhc').val('0');
+ $('#count-plans-novel').val('0');
+ $('#count-execution-novel').val('0');
+
+ // Set Plan counter based on selected Activity
+ if (activity === 'LHC') {
+
+ $('#count-plans-lhc').val('1');
+
+ } else if (activity === 'NOVEL') {
+
+ $('#count-plans-novel').val('1');
+ }
+
+ // Debug - check before submitting
+ console.log('Plan Activity:', activity);
+ console.log('Count of Plans_LHC:', $('#count-plans-lhc').val());
+ console.log('Count of Plans_Novel:', $('#count-plans-novel').val());
+
+ event.preventDefault();
+
+ $("#pageloader").fadeIn();
+
+ $.ajax({
+ type: "POST",
+ url: '/form/ajaxsubmit',
+ data: new FormData($('#report-form')[0]),
+ processData: false,
+ contentType: false,
+
+ success: function(data) {
+
+ $("#pageloader").fadeOut();
+
+ if (data.status == 'success') {
+
+ Swal.fire({
+ title: 'Great!',
+ text: 'Your data is successfully submitted!',
+ icon: 'success'
+ });
+
+ window.location.reload();
+
+ } else {
+
+ Swal.fire({
+ icon: 'error',
+ title: 'Data not submitted',
+ text: 'Something went wrong, please try again after some time!'
+ });
+ }
+ }
+ });
+ });
$('#field-core_value').parent().hide();
@@ -783,6 +909,8 @@
$('#field-core_value').val($('option:selected', this).attr('core_value'))
})
+
+
$('#field-msl_code').prop('readonly', true);
$('#field-speciality').prop('readonly', true);
@@ -829,62 +957,134 @@
$('#execution-form').on('submit', function(event) {
- const activity = ($('#execution-activity').val() || '').trim().toUpperCase();
+ const activity = ($('#execution-activity').val() || '')
+ .trim()
+ .toUpperCase();
- if (activity === 'LHC') {
+ const executionMode = $('#execution-mode').val();
- const patientsScreened = $('#execution-no_of_patients_screened').val();
+ /*
+ * Reset all counters first
+ */
+ $('#execution-count-plans-lhc').val('0');
+ $('#execution-count-execution-lhc').val('0');
+ $('#execution-count-plans-novel').val('0');
+ $('#execution-count-execution-novel').val('0');
- if (
- patientsScreened === '' ||
- !/^\d+$/.test(patientsScreened)
- ) {
- event.preventDefault();
- Swal.fire({
- icon: 'error',
- title: 'Invalid No. of Patients Screened',
- text: 'Please enter a valid whole number. Negative numbers and decimal values are not allowed.'
- });
+ /*
+ * Only set Execution counters when
+ * this is actual Execution, NOT Edit Plan.
+ */
+ if (executionMode === 'yes') {
- $('#execution-no_of_patients_screened').focus();
+ if (activity === 'LHC') {
- return;
- }
- }
+ $('#execution-count-execution-lhc').val('1');
+
+ } else if (activity === 'NOVEL') {
+
+ $('#execution-count-execution-novel').val('1');
+ }
+ }
+
+
+ /*
+ * Patients Screened validation
+ */
+ if (activity === 'LHC') {
+
+ const patientsScreened =
+ $('#execution-no_of_patients_screened').val();
+
+ if (
+ patientsScreened === '' ||
+ !/^\d+$/.test(patientsScreened)
+ ) {
event.preventDefault();
- $("#pageloader").fadeIn();
-
- $.ajax({
- type: "POST",
- url: '/form/ajaxsubmit',
- data: new FormData($('#execution-form')[0]),
- processData: false,
- contentType: false,
- success: function(data) {
- $("#pageloader").fadeOut();
- if (data.status == 'success') {
- Swal.fire({
- title: 'Great!',
- text: 'Your data is successfully submitted!',
- icon: 'success'
- }).then(() => {
- location.reload(); // 🔥 page refresh here
- });
- $('#report-form').trigger("reset");
- } else {
- Swal.fire({
- icon: 'error',
- title: 'Data not submitted',
- text: 'Something went wrong, please try again after some time!'
- })
- }
- },
- });
+ Swal.fire({
+ icon: 'error',
+ title: 'Invalid No. of Patients Screened',
+ text: 'Please enter a valid whole number. Negative numbers and decimal values are not allowed.'
});
+ $('#execution-no_of_patients_screened').focus();
+
+ return false;
+ }
+ }
+
+
+ /*
+ * Debug before submission
+ */
+ console.log('Execution Mode:', executionMode);
+ console.log('Execution Activity:', activity);
+
+ console.log(
+ 'Count of Execution_LHC:',
+ $('#execution-count-execution-lhc').val()
+ );
+
+ console.log(
+ 'Count of Execution_Novel:',
+ $('#execution-count-execution-novel').val()
+ );
+
+
+ /*
+ * Submit
+ */
+ event.preventDefault();
+
+ $("#pageloader").fadeIn();
+
+ $.ajax({
+ type: "POST",
+ url: '/form/ajaxsubmit',
+ data: new FormData($('#execution-form')[0]),
+ processData: false,
+ contentType: false,
+
+ success: function(data) {
+
+ $("#pageloader").fadeOut();
+
+ if (data.status == 'success') {
+
+ Swal.fire({
+ title: 'Great!',
+ text: 'Your data is successfully submitted!',
+ icon: 'success'
+ }).then(() => {
+ location.reload();
+ });
+
+ } else {
+
+ Swal.fire({
+ icon: 'error',
+ title: 'Data not submitted',
+ text: 'Something went wrong, please try again after some time!'
+ });
+ }
+ },
+
+ error: function() {
+
+ $("#pageloader").fadeOut();
+
+ Swal.fire({
+ icon: 'error',
+ title: 'Data not submitted',
+ text: 'Something went wrong, please try again after some time!'
+ });
+ }
+ });
+});
+
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0');