diff --git a/resources/views/form/rapport-lifemankind/1788596722-25ccc7d7-bf95-4fde-b6d5-6bed2d5e9eb4.blade.php b/resources/views/form/rapport-lifemankind/1788596722-25ccc7d7-bf95-4fde-b6d5-6bed2d5e9eb4.blade.php index ed84d309..02a21e5b 100644 --- a/resources/views/form/rapport-lifemankind/1788596722-25ccc7d7-bf95-4fde-b6d5-6bed2d5e9eb4.blade.php +++ b/resources/views/form/rapport-lifemankind/1788596722-25ccc7d7-bf95-4fde-b6d5-6bed2d5e9eb4.blade.php @@ -40,6 +40,15 @@ @endif
+ + + @csrf @if($id) @@ -237,34 +246,77 @@ console.log(hierarchy) }) - $('#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' - }) - $('#report-form').trigger("reset"); - } else { - Swal.fire({ - icon: 'error', - title: data.hasOwnProperty('message') ? 'You are not mapped to any position code' : 'Data not submitted', - text: data.hasOwnProperty('message') ? 'for resolution please email Position code, L1 Manager and L2 Manager details to support1@stratawiz.com':'Something went wrong, please try again after some time!' - }) - } - }, - }); - }); + $('#report-form').on('submit', function(event){ + event.preventDefault(); + + // Get selected activity + var activity = $('#field-activity_name option:selected').text().trim(); + + // Create FormData + var formData = new FormData(this); + + // Reset both metric values + formData.set('ACTUAL_GUDCEF_METRIC_CODE', '0'); + formData.set('ACTUAL_ASTHAKIND_METRIC_CODE', '0'); + + // Set selected activity metric to 1 + if (activity === 'GUDCEF MONDAY') { + + formData.set('ACTUAL_GUDCEF_METRIC_CODE', '1'); + + } else if ( + activity === 'ASTHAKIND - BEMISAAL BUDHWAAR / WINNING WEDNESDAY' + ) { + + formData.set('ACTUAL_ASTHAKIND_METRIC_CODE', '1'); + } + + // Debug + console.log('Submitting Activity:', activity); + console.log( + 'Submitting GUDCEF:', + formData.get('ACTUAL_GUDCEF_METRIC_CODE') + ); + console.log( + 'Submitting ASTHAKIND:', + formData.get('ACTUAL_ASTHAKIND_METRIC_CODE') + ); + + $("#pageloader").fadeIn(); + + $.ajax({ + type: "POST", + url: '/form/ajaxsubmit', + data: formData, + 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' + }); + + $('#report-form').trigger("reset"); + + } else { + Swal.fire({ + icon: 'error', + title: data.hasOwnProperty('message') + ? 'You are not mapped to any position code' + : 'Data not submitted', + text: data.hasOwnProperty('message') + ? 'for resolution please email Position code, L1 Manager and L2 Manager details to support1@stratawiz.com' + : 'Something went wrong, please try again after some time!' + }); + } + } + }); +}); var today = new Date(); var dd = String(today.getDate()).padStart(2, '0'); @@ -327,6 +379,12 @@ function hideActivityFields() { + $('#field-day_of_activity_for_gudcef_monday') + .closest('.col-md-12') + .hide() + .find('input, select, textarea') + .prop('required', false); + $('#field-number_of_gudcef_monday_input_distributed_to_doctors') .closest('.col-md-12') .hide() @@ -392,6 +450,12 @@ $('#field-activity_name').on('change', function () { // GUDCEF MONDAY if (activity === 'GUDCEF MONDAY') { + $('#field-day_of_activity_for_gudcef_monday') + .closest('.col-md-12') + .show() + .find('input, select, textarea') + .prop('required', true); + $('#field-number_of_gudcef_monday_input_distributed_to_doctors') .closest('.col-md-12') .show() @@ -448,6 +512,34 @@ $('#field-activity_name').on('change', function () { .prop('required', true); } + +$('#field-activity_name').on('change', function () { + + var activity = $('#field-activity_name option:selected').text().trim(); + + console.log("ACTIVITY SELECTED:", activity); + + $('#activity_gudcef_metric').val('0'); + $('#activity_asthakind_metric').val('0'); + + if (activity === 'GUDCEF MONDAY') { + + $('#activity_gudcef_metric').val('1'); + + } else if (activity === 'ASTHAKIND - BEMISAAL BUDHWAAR / WINNING WEDNESDAY') { + + $('#activity_asthakind_metric').val('1'); + } + + console.log( + "GUDCEF =", $('#activity_gudcef_metric').val() + ); + + console.log( + "ASTHAKIND =", $('#activity_asthakind_metric').val() + ); +}); + }); });