Merge branch 'main' of http://192.168.1.200:3000/Stratawiz/Rapport-Laravel
Specific Folder FTP Upload / ftp-deploy (push) Successful in 30s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 30s
Details
This commit is contained in:
commit
d7e11dfacc
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use App\Http\Requests\LambdaRequest;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
|
@ -58,4 +60,89 @@ class TgicsHelper
|
||||||
return ['counts' => array_fill_keys($ids, 0), 'total' => 0];
|
return ['counts' => array_fill_keys($ids, 0), 'total' => 0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a Rapport contact access token for a domain (e.g. lifemankind).
|
||||||
|
*/
|
||||||
|
public static function resolveContactAccessToken(string $domain): string
|
||||||
|
{
|
||||||
|
$domain = trim($domain);
|
||||||
|
if ($domain === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tokenRows = DB::table('users')
|
||||||
|
->select('access_token')
|
||||||
|
->where('domain', $domain)
|
||||||
|
->where('permissions', 'like', '%contact_create%')
|
||||||
|
->orderBy('updated_at', 'desc')
|
||||||
|
->skip(0)
|
||||||
|
->take(1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($tokenRows->isEmpty() || empty($tokenRows[0]->access_token)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (string) $tokenRows[0]->access_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isWhatsappValidatedFlag($value): bool
|
||||||
|
{
|
||||||
|
if ($value === true || $value === 1 || $value === '1') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return strtolower(trim((string) $value)) === 'yes';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map contact_id => whether WhatsApp is validated for TGICS.
|
||||||
|
*
|
||||||
|
* @param array<int, string> $contactIds
|
||||||
|
* @return array<string, bool>
|
||||||
|
*/
|
||||||
|
public static function getWhatsappValidationStatus(array $contactIds, string $domain = 'lifemankind'): array
|
||||||
|
{
|
||||||
|
$ids = array_values(array_unique(array_filter(array_map(static function ($id) {
|
||||||
|
return trim((string) $id);
|
||||||
|
}, $contactIds))));
|
||||||
|
|
||||||
|
if (count($ids) === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$accessToken = self::resolveContactAccessToken($domain);
|
||||||
|
if ($accessToken === '') {
|
||||||
|
Log::warning('TGICS WhatsApp validation: no contact access token for domain '.$domain);
|
||||||
|
return array_fill_keys($ids, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = array_fill_keys($ids, false);
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
try {
|
||||||
|
$resp = LambdaRequest::getrequest('contact', 'contact/get_one', ['id' => $id], $accessToken);
|
||||||
|
$item = $resp->data->item ?? null;
|
||||||
|
if ($item && self::isWhatsappValidatedFlag($item->tgics_whatsapp_validated ?? '')) {
|
||||||
|
$status[$id] = true;
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning('TGICS WhatsApp validation lookup failed for '.$id.': '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single-contact validation check for poll endpoint.
|
||||||
|
*/
|
||||||
|
public static function isContactWhatsappValidated(string $contactId, string $domain = 'lifemankind'): bool
|
||||||
|
{
|
||||||
|
$contactId = trim($contactId);
|
||||||
|
if ($contactId === '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$map = self::getWhatsappValidationStatus([$contactId], $domain);
|
||||||
|
return !empty($map[$contactId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -995,47 +995,62 @@ class FormController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create contact only on new enrolments (not edits)
|
$doctorName = trim((string) ($post['contact_id'] ?? ($post['doctor_name'] ?? '')));
|
||||||
|
if ($doctorName === '') {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Doctor name is required.',
|
||||||
|
'description' => 'Please enter the name of the practitioner.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$avgPatients = preg_replace('/\D+/', '', (string) ($post['average_no_of_patients'] ?? ''));
|
||||||
|
$post['average_no_of_patients'] = $avgPatients;
|
||||||
|
if ($avgPatients === '') {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Average No. of Patients is required.',
|
||||||
|
'description' => 'Please enter a valid number for Average No. of Patients.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$contactdata = [
|
||||||
|
'domain' => $domain,
|
||||||
|
'application' => $application,
|
||||||
|
'user_id' => $post['user_id'] ?? $formdata->user_id,
|
||||||
|
'name' => $doctorName,
|
||||||
|
'msl_code' => $wfsaCode,
|
||||||
|
'phone' => $post['whatsapp_mobile_number'] ?? '',
|
||||||
|
'email' => $post['email_id'] ?? '',
|
||||||
|
'type' => 'doctor',
|
||||||
|
'tgics_enrolled_doctor' => 'Yes',
|
||||||
|
];
|
||||||
|
if (!empty($post['age'])) {
|
||||||
|
$contactdata['age'] = $post['age'];
|
||||||
|
}
|
||||||
|
if (!empty($post['city_town'])) {
|
||||||
|
$contactdata['city'] = $post['city_town'];
|
||||||
|
}
|
||||||
|
if (!empty($post['state'])) {
|
||||||
|
$contactdata['state'] = $post['state'];
|
||||||
|
}
|
||||||
|
if (!empty($post['qualification'])) {
|
||||||
|
$contactdata['qualification'] = $post['qualification'];
|
||||||
|
}
|
||||||
|
if (!empty($post['other_qualification'])) {
|
||||||
|
$contactdata['other_qualification'] = $post['other_qualification'];
|
||||||
|
}
|
||||||
|
if (!empty($post['years_of_practice'])) {
|
||||||
|
$contactdata['years_of_practice'] = $post['years_of_practice'];
|
||||||
|
}
|
||||||
|
if (!empty($post['type_of_practice'])) {
|
||||||
|
$contactdata['type_of_practice'] = $post['type_of_practice'];
|
||||||
|
}
|
||||||
|
$contactdata['average_no_of_patients'] = $avgPatients;
|
||||||
|
|
||||||
|
// Create contact on new enrolments; update linked contact on edits
|
||||||
if ($currentSubmissionId === '') {
|
if ($currentSubmissionId === '') {
|
||||||
$doctorName = trim((string) ($post['contact_id'] ?? ($post['doctor_name'] ?? '')));
|
$contactdata['tgics_whatsapp_validated'] = 'No';
|
||||||
if ($doctorName === '') {
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'error',
|
|
||||||
'message' => 'Doctor name is required.',
|
|
||||||
'description' => 'Please enter the name of the practitioner.',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$contactdata = [
|
|
||||||
'domain' => $domain,
|
|
||||||
'application' => $application,
|
|
||||||
'user_id' => $post['user_id'] ?? $formdata->user_id,
|
|
||||||
'name' => $doctorName,
|
|
||||||
'msl_code' => $wfsaCode,
|
|
||||||
'phone' => $post['whatsapp_mobile_number'] ?? '',
|
|
||||||
'email' => $post['email_id'] ?? '',
|
|
||||||
'type' => 'doctor',
|
|
||||||
'tgics_enrolled_doctor' => 'Yes',
|
|
||||||
];
|
|
||||||
if (!empty($post['age'])) {
|
|
||||||
$contactdata['age'] = $post['age'];
|
|
||||||
}
|
|
||||||
if (!empty($post['city_town'])) {
|
|
||||||
$contactdata['city'] = $post['city_town'];
|
|
||||||
}
|
|
||||||
if (!empty($post['state'])) {
|
|
||||||
$contactdata['state'] = $post['state'];
|
|
||||||
}
|
|
||||||
if (!empty($post['qualification'])) {
|
|
||||||
$contactdata['qualification'] = $post['qualification'];
|
|
||||||
}
|
|
||||||
if (!empty($post['years_of_practice'])) {
|
|
||||||
$contactdata['years_of_practice'] = $post['years_of_practice'];
|
|
||||||
}
|
|
||||||
if (!empty($post['type_of_practice'])) {
|
|
||||||
$contactdata['type_of_practice'] = $post['type_of_practice'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$cont = LambdaRequest::postrequest('contact', 'contact/create', $contactdata, $accessToken);
|
$cont = LambdaRequest::postrequest('contact', 'contact/create', $contactdata, $accessToken);
|
||||||
if (!isset($cont->status) || $cont->status !== 'success' || empty($cont->data->item->id)) {
|
if (!isset($cont->status) || $cont->status !== 'success' || empty($cont->data->item->id)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|
@ -1045,6 +1060,32 @@ class FormController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$post['tgics_contact_id'] = $cont->data->item->id;
|
$post['tgics_contact_id'] = $cont->data->item->id;
|
||||||
|
} elseif ($linkedContactId !== '') {
|
||||||
|
$contactdata['id'] = $linkedContactId;
|
||||||
|
$existingContact = LambdaRequest::getrequest('contact', 'contact/get_one', ['id' => $linkedContactId], $accessToken);
|
||||||
|
$existingItem = $existingContact->data->item ?? null;
|
||||||
|
$existingPhone = '';
|
||||||
|
if ($existingItem && !empty($existingItem->phone)) {
|
||||||
|
$existingPhone = preg_replace('/\D+/', '', (string) $existingItem->phone);
|
||||||
|
if (strlen($existingPhone) > 10) {
|
||||||
|
$existingPhone = substr($existingPhone, -10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($existingPhone !== '' && $existingPhone !== $whatsapp) {
|
||||||
|
$contactdata['tgics_whatsapp_validated'] = 'No';
|
||||||
|
} elseif ($existingItem && isset($existingItem->tgics_whatsapp_validated)) {
|
||||||
|
$contactdata['tgics_whatsapp_validated'] = $existingItem->tgics_whatsapp_validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cont = LambdaRequest::postrequest('contact', 'contact/update', $contactdata, $accessToken);
|
||||||
|
if (!isset($cont->status) || $cont->status !== 'success') {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Unable to update doctor contact.',
|
||||||
|
'description' => $cont->message ?? 'Please try again after some time.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$post['tgics_contact_id'] = $linkedContactId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -13488,4 +13529,35 @@ class FormController extends Controller
|
||||||
return $labels;
|
return $labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Poll endpoint: TGICS WhatsApp validation status for a contact.
|
||||||
|
*/
|
||||||
|
public function tgicsWhatsappStatus(Request $request)
|
||||||
|
{
|
||||||
|
$contactId = trim((string) $request->input('contact_id', ''));
|
||||||
|
$partition = trim((string) $request->input('partition', 'rapport-lifemankind'));
|
||||||
|
$domain = 'lifemankind';
|
||||||
|
if (strpos($partition, '-') !== false) {
|
||||||
|
$parts = explode('-', $partition, 2);
|
||||||
|
$domain = $parts[1] ?? $domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($contactId === '') {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'contact_id is required.',
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = \App\Helpers\TgicsHelper::isContactWhatsappValidated($contactId, $domain);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'data' => [
|
||||||
|
'contact_id' => $contactId,
|
||||||
|
'validated' => $validated,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1415,9 +1415,11 @@ class NeblogisticreportController extends Controller
|
||||||
'current_status' => $record->status,
|
'current_status' => $record->status,
|
||||||
'allowed_statuses' => $allowedStatuses
|
'allowed_statuses' => $allowedStatuses
|
||||||
]);
|
]);
|
||||||
|
$hoMessage = $this->napHoFinalStatusMessage($record->status);
|
||||||
return view('neblogisticreport.abmapprovereject')->with([
|
return view('neblogisticreport.abmapprovereject')->with([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Current status "' . $record->status . '" does not allow approval or rejection',
|
'message' => $hoMessage
|
||||||
|
?: ('Current status "' . $record->status . '" does not allow approval or rejection'),
|
||||||
'submission_id' => $submission_id,
|
'submission_id' => $submission_id,
|
||||||
'record' => $record
|
'record' => $record
|
||||||
]);
|
]);
|
||||||
|
|
@ -1505,9 +1507,11 @@ class NeblogisticreportController extends Controller
|
||||||
'current_status' => $record->status,
|
'current_status' => $record->status,
|
||||||
'allowed_statuses' => $allowedStatuses
|
'allowed_statuses' => $allowedStatuses
|
||||||
]);
|
]);
|
||||||
|
$hoMessage = $this->napHoFinalStatusMessage($record->status);
|
||||||
return view('neblogisticreport.napapprovalstatus')->with([
|
return view('neblogisticreport.napapprovalstatus')->with([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Current status "' . $record->status . '" does not allow approval or rejection',
|
'message' => $hoMessage
|
||||||
|
?: ('Current status "' . $record->status . '" does not allow approval or rejection'),
|
||||||
'submission_id' => $submission_id,
|
'submission_id' => $submission_id,
|
||||||
'record' => $record
|
'record' => $record
|
||||||
]);
|
]);
|
||||||
|
|
@ -1566,7 +1570,12 @@ class NeblogisticreportController extends Controller
|
||||||
$allowedStatuses = ['Requested', 'L1 Approved'];
|
$allowedStatuses = ['Requested', 'L1 Approved'];
|
||||||
if (!in_array($record->status, $allowedStatuses)) {
|
if (!in_array($record->status, $allowedStatuses)) {
|
||||||
Log::warning('ABM approval/rejection AJAX failed: Invalid status', [ 'submission_id' => $submission_id, 'current_status' => $record->status, 'allowed_statuses' => $allowedStatuses ]);
|
Log::warning('ABM approval/rejection AJAX failed: Invalid status', [ 'submission_id' => $submission_id, 'current_status' => $record->status, 'allowed_statuses' => $allowedStatuses ]);
|
||||||
return response()->json([ 'success' => false, 'message' => 'Current status "' . $record->status . '" does not allow approval or rejection' ], 400);
|
$hoMessage = $this->napHoFinalStatusMessage($record->status);
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => $hoMessage
|
||||||
|
?: ('Current status "' . $record->status . '" does not allow approval or rejection'),
|
||||||
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action === 'approve') {
|
if ($action === 'approve') {
|
||||||
|
|
@ -1592,9 +1601,14 @@ class NeblogisticreportController extends Controller
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'response' => $response,
|
'response' => $response,
|
||||||
]);
|
]);
|
||||||
|
$apiMessage = is_string($response->message ?? null) ? $response->message : null;
|
||||||
|
if (!$apiMessage && is_string($response->data ?? null)) {
|
||||||
|
$apiMessage = $response->data;
|
||||||
|
}
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Form approval failed. MySQL status was not updated. Please try again.',
|
'message' => $apiMessage
|
||||||
|
?: 'Form approval failed. MySQL status was not updated. Please try again.',
|
||||||
], 502);
|
], 502);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1670,9 +1684,14 @@ class NeblogisticreportController extends Controller
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'response' => $response,
|
'response' => $response,
|
||||||
]);
|
]);
|
||||||
|
$apiMessage = is_string($response->message ?? null) ? $response->message : null;
|
||||||
|
if (!$apiMessage && is_string($response->data ?? null)) {
|
||||||
|
$apiMessage = $response->data;
|
||||||
|
}
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Form rejection failed. MySQL status was not updated. Please try again.',
|
'message' => $apiMessage
|
||||||
|
?: 'Form rejection failed. MySQL status was not updated. Please try again.',
|
||||||
], 502);
|
], 502);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2064,8 +2083,19 @@ class NeblogisticreportController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Neblogistic NAP approval: resolve acting approver when email link has vacant/missing user_id.
|
* NAP email approve/reject: message when HO has already finalized Approved/Rejected.
|
||||||
*/
|
*/
|
||||||
|
protected function napHoFinalStatusMessage(?string $status): ?string
|
||||||
|
{
|
||||||
|
if ($status === 'Approved') {
|
||||||
|
return 'This request has already been approved by HO';
|
||||||
|
}
|
||||||
|
if ($status === 'Rejected') {
|
||||||
|
return 'This request has already been rejected by HO';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected function isFormApiSuccess($response): bool
|
protected function isFormApiSuccess($response): bool
|
||||||
{
|
{
|
||||||
return is_object($response) && ($response->status ?? '') === 'success';
|
return is_object($response) && ($response->status ?? '') === 'success';
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,580 @@
|
||||||
|
window.TGICS_INDIA_GEO = {
|
||||||
|
"Andaman and Nicobar Islands": [
|
||||||
|
"Port Blair",
|
||||||
|
"Diglipur",
|
||||||
|
"Mayabunder"
|
||||||
|
],
|
||||||
|
"Andhra Pradesh": [
|
||||||
|
"Visakhapatnam",
|
||||||
|
"Vijayawada",
|
||||||
|
"Guntur",
|
||||||
|
"Nellore",
|
||||||
|
"Kurnool",
|
||||||
|
"Rajahmundry",
|
||||||
|
"Tirupati",
|
||||||
|
"Kakinada",
|
||||||
|
"Anantapur",
|
||||||
|
"Eluru",
|
||||||
|
"Ongole",
|
||||||
|
"Chittoor",
|
||||||
|
"Kadapa",
|
||||||
|
"Srikakulam",
|
||||||
|
"Vizianagaram",
|
||||||
|
"Machilipatnam",
|
||||||
|
"Proddatur",
|
||||||
|
"Hindupur",
|
||||||
|
"Madanapalle",
|
||||||
|
"Nandyal"
|
||||||
|
],
|
||||||
|
"Arunachal Pradesh": [
|
||||||
|
"Itanagar",
|
||||||
|
"Naharlagun",
|
||||||
|
"Pasighat",
|
||||||
|
"Tawang",
|
||||||
|
"Ziro",
|
||||||
|
"Bomdila",
|
||||||
|
"Tezu",
|
||||||
|
"Along"
|
||||||
|
],
|
||||||
|
"Assam": [
|
||||||
|
"Guwahati",
|
||||||
|
"Silchar",
|
||||||
|
"Dibrugarh",
|
||||||
|
"Jorhat",
|
||||||
|
"Nagaon",
|
||||||
|
"Tinsukia",
|
||||||
|
"Tezpur",
|
||||||
|
"Bongaigaon",
|
||||||
|
"Dhubri",
|
||||||
|
"Sivasagar",
|
||||||
|
"Goalpara",
|
||||||
|
"Barpeta",
|
||||||
|
"Karimganj",
|
||||||
|
"Diphu",
|
||||||
|
"North Lakhimpur"
|
||||||
|
],
|
||||||
|
"Bihar": [
|
||||||
|
"Patna",
|
||||||
|
"Gaya",
|
||||||
|
"Bhagalpur",
|
||||||
|
"Muzaffarpur",
|
||||||
|
"Purnia",
|
||||||
|
"Darbhanga",
|
||||||
|
"Bihar Sharif",
|
||||||
|
"Arrah",
|
||||||
|
"Begusarai",
|
||||||
|
"Katihar",
|
||||||
|
"Munger",
|
||||||
|
"Chhapra",
|
||||||
|
"Sasaram",
|
||||||
|
"Hajipur",
|
||||||
|
"Samastipur",
|
||||||
|
"Bettiah",
|
||||||
|
"Motihari",
|
||||||
|
"Siwan",
|
||||||
|
"Saharsa",
|
||||||
|
"Dehri"
|
||||||
|
],
|
||||||
|
"Chandigarh": [
|
||||||
|
"Chandigarh"
|
||||||
|
],
|
||||||
|
"Chhattisgarh": [
|
||||||
|
"Raipur",
|
||||||
|
"Bhilai",
|
||||||
|
"Bilaspur",
|
||||||
|
"Korba",
|
||||||
|
"Durg",
|
||||||
|
"Rajnandgaon",
|
||||||
|
"Raigarh",
|
||||||
|
"Jagdalpur",
|
||||||
|
"Ambikapur",
|
||||||
|
"Dhamtari",
|
||||||
|
"Mahasamund",
|
||||||
|
"Kanker"
|
||||||
|
],
|
||||||
|
"Dadra and Nagar Haveli and Daman and Diu": [
|
||||||
|
"Silvassa",
|
||||||
|
"Daman",
|
||||||
|
"Diu"
|
||||||
|
],
|
||||||
|
"Delhi": [
|
||||||
|
"New Delhi",
|
||||||
|
"Central Delhi",
|
||||||
|
"East Delhi",
|
||||||
|
"North Delhi",
|
||||||
|
"North East Delhi",
|
||||||
|
"North West Delhi",
|
||||||
|
"Shahdara",
|
||||||
|
"South Delhi",
|
||||||
|
"South East Delhi",
|
||||||
|
"South West Delhi",
|
||||||
|
"West Delhi"
|
||||||
|
],
|
||||||
|
"Goa": [
|
||||||
|
"Panaji",
|
||||||
|
"Margao",
|
||||||
|
"Vasco da Gama",
|
||||||
|
"Mapusa",
|
||||||
|
"Ponda",
|
||||||
|
"Bicholim",
|
||||||
|
"Curchorem"
|
||||||
|
],
|
||||||
|
"Gujarat": [
|
||||||
|
"Ahmedabad",
|
||||||
|
"Surat",
|
||||||
|
"Vadodara",
|
||||||
|
"Rajkot",
|
||||||
|
"Bhavnagar",
|
||||||
|
"Jamnagar",
|
||||||
|
"Junagadh",
|
||||||
|
"Gandhinagar",
|
||||||
|
"Anand",
|
||||||
|
"Morbi",
|
||||||
|
"Nadiad",
|
||||||
|
"Surendranagar",
|
||||||
|
"Gandhidham",
|
||||||
|
"Bharuch",
|
||||||
|
"Mehsana",
|
||||||
|
"Bhuj",
|
||||||
|
"Porbandar",
|
||||||
|
"Palanpur",
|
||||||
|
"Valsad",
|
||||||
|
"Vapi",
|
||||||
|
"Navsari",
|
||||||
|
"Godhra",
|
||||||
|
"Patan",
|
||||||
|
"Veraval"
|
||||||
|
],
|
||||||
|
"Haryana": [
|
||||||
|
"Gurugram",
|
||||||
|
"Faridabad",
|
||||||
|
"Panipat",
|
||||||
|
"Ambala",
|
||||||
|
"Yamunanagar",
|
||||||
|
"Rohtak",
|
||||||
|
"Hisar",
|
||||||
|
"Karnal",
|
||||||
|
"Sonipat",
|
||||||
|
"Panchkula",
|
||||||
|
"Bhiwani",
|
||||||
|
"Sirsa",
|
||||||
|
"Bahadurgarh",
|
||||||
|
"Jind",
|
||||||
|
"Thanesar",
|
||||||
|
"Kaithal",
|
||||||
|
"Rewari",
|
||||||
|
"Palwal",
|
||||||
|
"Fatehabad"
|
||||||
|
],
|
||||||
|
"Himachal Pradesh": [
|
||||||
|
"Shimla",
|
||||||
|
"Dharamshala",
|
||||||
|
"Solan",
|
||||||
|
"Mandi",
|
||||||
|
"Palampur",
|
||||||
|
"Baddi",
|
||||||
|
"Nahan",
|
||||||
|
"Kullu",
|
||||||
|
"Hamirpur",
|
||||||
|
"Una",
|
||||||
|
"Bilaspur",
|
||||||
|
"Chamba",
|
||||||
|
"Kangra"
|
||||||
|
],
|
||||||
|
"Jammu and Kashmir": [
|
||||||
|
"Srinagar",
|
||||||
|
"Jammu",
|
||||||
|
"Anantnag",
|
||||||
|
"Baramulla",
|
||||||
|
"Sopore",
|
||||||
|
"Kathua",
|
||||||
|
"Udhampur",
|
||||||
|
"Pulwama",
|
||||||
|
"Rajouri",
|
||||||
|
"Poonch",
|
||||||
|
"Kupwara",
|
||||||
|
"Budgam"
|
||||||
|
],
|
||||||
|
"Jharkhand": [
|
||||||
|
"Ranchi",
|
||||||
|
"Jamshedpur",
|
||||||
|
"Dhanbad",
|
||||||
|
"Bokaro",
|
||||||
|
"Deoghar",
|
||||||
|
"Hazaribagh",
|
||||||
|
"Giridih",
|
||||||
|
"Ramgarh",
|
||||||
|
"Phusro",
|
||||||
|
"Medininagar",
|
||||||
|
"Chaibasa",
|
||||||
|
"Dumka",
|
||||||
|
"Godda"
|
||||||
|
],
|
||||||
|
"Karnataka": [
|
||||||
|
"Bengaluru",
|
||||||
|
"Mysuru",
|
||||||
|
"Hubballi",
|
||||||
|
"Mangaluru",
|
||||||
|
"Belagavi",
|
||||||
|
"Kalaburagi",
|
||||||
|
"Davangere",
|
||||||
|
"Ballari",
|
||||||
|
"Vijayapura",
|
||||||
|
"Shivamogga",
|
||||||
|
"Tumakuru",
|
||||||
|
"Raichur",
|
||||||
|
"Bidar",
|
||||||
|
"Hospet",
|
||||||
|
"Gadag",
|
||||||
|
"Udupi",
|
||||||
|
"Chikkamagaluru",
|
||||||
|
"Hassan",
|
||||||
|
"Chitradurga",
|
||||||
|
"Kolar",
|
||||||
|
"Mandya",
|
||||||
|
"Bagalkot"
|
||||||
|
],
|
||||||
|
"Kerala": [
|
||||||
|
"Thiruvananthapuram",
|
||||||
|
"Kochi",
|
||||||
|
"Kozhikode",
|
||||||
|
"Thrissur",
|
||||||
|
"Kollam",
|
||||||
|
"Kannur",
|
||||||
|
"Alappuzha",
|
||||||
|
"Kottayam",
|
||||||
|
"Palakkad",
|
||||||
|
"Malappuram",
|
||||||
|
"Pathanamthitta",
|
||||||
|
"Idukki",
|
||||||
|
"Kasaragod",
|
||||||
|
"Waynad"
|
||||||
|
],
|
||||||
|
"Ladakh": [
|
||||||
|
"Leh",
|
||||||
|
"Kargil"
|
||||||
|
],
|
||||||
|
"Lakshadweep": [
|
||||||
|
"Kavaratti",
|
||||||
|
"Agatti",
|
||||||
|
"Minicoy"
|
||||||
|
],
|
||||||
|
"Madhya Pradesh": [
|
||||||
|
"Bhopal",
|
||||||
|
"Indore",
|
||||||
|
"Jabalpur",
|
||||||
|
"Gwalior",
|
||||||
|
"Ujjain",
|
||||||
|
"Sagar",
|
||||||
|
"Dewas",
|
||||||
|
"Satna",
|
||||||
|
"Ratlam",
|
||||||
|
"Rewa",
|
||||||
|
"Murwara",
|
||||||
|
"Singrauli",
|
||||||
|
"Burhanpur",
|
||||||
|
"Khandwa",
|
||||||
|
"Bhind",
|
||||||
|
"Chhindwara",
|
||||||
|
"Guna",
|
||||||
|
"Shivpuri",
|
||||||
|
"Vidisha",
|
||||||
|
"Damoh",
|
||||||
|
"Mandsaur",
|
||||||
|
"Neemuch",
|
||||||
|
"Hoshangabad"
|
||||||
|
],
|
||||||
|
"Maharashtra": [
|
||||||
|
"Mumbai",
|
||||||
|
"Pune",
|
||||||
|
"Nagpur",
|
||||||
|
"Thane",
|
||||||
|
"Nashik",
|
||||||
|
"Aurangabad",
|
||||||
|
"Solapur",
|
||||||
|
"Amravati",
|
||||||
|
"Kolhapur",
|
||||||
|
"Navi Mumbai",
|
||||||
|
"Sangli",
|
||||||
|
"Malegaon",
|
||||||
|
"Jalgaon",
|
||||||
|
"Akola",
|
||||||
|
"Latur",
|
||||||
|
"Dhule",
|
||||||
|
"Ahmednagar",
|
||||||
|
"Chandrapur",
|
||||||
|
"Parbhani",
|
||||||
|
"Ichalkaranji",
|
||||||
|
"Jalna",
|
||||||
|
"Bhusawal",
|
||||||
|
"Nanded",
|
||||||
|
"Satara",
|
||||||
|
"Beed",
|
||||||
|
"Yavatmal",
|
||||||
|
"Kamptee",
|
||||||
|
"Gondia",
|
||||||
|
"Barshi",
|
||||||
|
"Achalpur",
|
||||||
|
"Osmanabad",
|
||||||
|
"Nandurbar",
|
||||||
|
"Wardha",
|
||||||
|
"Udgir",
|
||||||
|
"Hinganghat"
|
||||||
|
],
|
||||||
|
"Manipur": [
|
||||||
|
"Imphal",
|
||||||
|
"Thoubal",
|
||||||
|
"Bishnupur",
|
||||||
|
"Churachandpur",
|
||||||
|
"Ukhrul",
|
||||||
|
"Kakching",
|
||||||
|
"Senapati"
|
||||||
|
],
|
||||||
|
"Meghalaya": [
|
||||||
|
"Shillong",
|
||||||
|
"Tura",
|
||||||
|
"Nongpoh",
|
||||||
|
"Jowai",
|
||||||
|
"Baghmara",
|
||||||
|
"Williamnagar"
|
||||||
|
],
|
||||||
|
"Mizoram": [
|
||||||
|
"Aizawl",
|
||||||
|
"Lunglei",
|
||||||
|
"Champhai",
|
||||||
|
"Serchhip",
|
||||||
|
"Kolasib",
|
||||||
|
"Saiha"
|
||||||
|
],
|
||||||
|
"Nagaland": [
|
||||||
|
"Kohima",
|
||||||
|
"Dimapur",
|
||||||
|
"Mokokchung",
|
||||||
|
"Tuensang",
|
||||||
|
"Wokha",
|
||||||
|
"Zunheboto",
|
||||||
|
"Mon"
|
||||||
|
],
|
||||||
|
"Odisha": [
|
||||||
|
"Bhubaneswar",
|
||||||
|
"Cuttack",
|
||||||
|
"Rourkela",
|
||||||
|
"Berhampur",
|
||||||
|
"Sambalpur",
|
||||||
|
"Puri",
|
||||||
|
"Balasore",
|
||||||
|
"Bhadrak",
|
||||||
|
"Baripada",
|
||||||
|
"Jharsuguda",
|
||||||
|
"Jeypore",
|
||||||
|
"Bargarh",
|
||||||
|
"Rayagada",
|
||||||
|
"Angul",
|
||||||
|
"Dhenkanal",
|
||||||
|
"Kendujhar"
|
||||||
|
],
|
||||||
|
"Puducherry": [
|
||||||
|
"Puducherry",
|
||||||
|
"Karaikal",
|
||||||
|
"Mahe",
|
||||||
|
"Yanam"
|
||||||
|
],
|
||||||
|
"Punjab": [
|
||||||
|
"Ludhiana",
|
||||||
|
"Amritsar",
|
||||||
|
"Jalandhar",
|
||||||
|
"Patiala",
|
||||||
|
"Bathinda",
|
||||||
|
"Mohali",
|
||||||
|
"Hoshiarpur",
|
||||||
|
"Batala",
|
||||||
|
"Pathankot",
|
||||||
|
"Moga",
|
||||||
|
"Abohar",
|
||||||
|
"Malerkotla",
|
||||||
|
"Khanna",
|
||||||
|
"Phagwara",
|
||||||
|
"Firozpur",
|
||||||
|
"Kapurthala",
|
||||||
|
"Muktsar",
|
||||||
|
"Rajpura"
|
||||||
|
],
|
||||||
|
"Rajasthan": [
|
||||||
|
"Jaipur",
|
||||||
|
"Jodhpur",
|
||||||
|
"Kota",
|
||||||
|
"Bikaner",
|
||||||
|
"Ajmer",
|
||||||
|
"Udaipur",
|
||||||
|
"Bhilwara",
|
||||||
|
"Alwar",
|
||||||
|
"Bharatpur",
|
||||||
|
"Sikar",
|
||||||
|
"Pali",
|
||||||
|
"Sri Ganganagar",
|
||||||
|
"Kishangarh",
|
||||||
|
"Beawar",
|
||||||
|
"Hanumangarh",
|
||||||
|
"Dausa",
|
||||||
|
"Tonk",
|
||||||
|
"Churu",
|
||||||
|
"Jhunjhunu",
|
||||||
|
"Banswara",
|
||||||
|
"Barmer",
|
||||||
|
"Nagaur"
|
||||||
|
],
|
||||||
|
"Sikkim": [
|
||||||
|
"Gangtok",
|
||||||
|
"Namchi",
|
||||||
|
"Gyalshing",
|
||||||
|
"Mangan",
|
||||||
|
"Rangpo"
|
||||||
|
],
|
||||||
|
"Tamil Nadu": [
|
||||||
|
"Chennai",
|
||||||
|
"Coimbatore",
|
||||||
|
"Madurai",
|
||||||
|
"Tiruchirappalli",
|
||||||
|
"Salem",
|
||||||
|
"Tirunelveli",
|
||||||
|
"Tiruppur",
|
||||||
|
"Erode",
|
||||||
|
"Vellore",
|
||||||
|
"Thoothukudi",
|
||||||
|
"Dindigul",
|
||||||
|
"Thanjavur",
|
||||||
|
"Ranipet",
|
||||||
|
"Sivakasi",
|
||||||
|
"Karur",
|
||||||
|
"Udhagamandalam",
|
||||||
|
"Hosur",
|
||||||
|
"Nagercoil",
|
||||||
|
"Kanchipuram",
|
||||||
|
"Kumarapalayam",
|
||||||
|
"Karaikudi",
|
||||||
|
"Neyveli",
|
||||||
|
"Cuddalore",
|
||||||
|
"Kumbakonam",
|
||||||
|
"Tiruvannamalai",
|
||||||
|
"Pollachi",
|
||||||
|
"Rajapalayam",
|
||||||
|
"Gudiyatham"
|
||||||
|
],
|
||||||
|
"Telangana": [
|
||||||
|
"Hyderabad",
|
||||||
|
"Warangal",
|
||||||
|
"Nizamabad",
|
||||||
|
"Khammam",
|
||||||
|
"Karimnagar",
|
||||||
|
"Ramagundam",
|
||||||
|
"Mahbubnagar",
|
||||||
|
"Nalgonda",
|
||||||
|
"Adilabad",
|
||||||
|
"Suryapet",
|
||||||
|
"Miryalaguda",
|
||||||
|
"Siddipet",
|
||||||
|
"Jagtial"
|
||||||
|
],
|
||||||
|
"Tripura": [
|
||||||
|
"Agartala",
|
||||||
|
"Udaipur",
|
||||||
|
"Dharmanagar",
|
||||||
|
"Kailashahar",
|
||||||
|
"Belonia",
|
||||||
|
"Ambassa"
|
||||||
|
],
|
||||||
|
"Uttar Pradesh": [
|
||||||
|
"Lucknow",
|
||||||
|
"Kanpur",
|
||||||
|
"Ghaziabad",
|
||||||
|
"Agra",
|
||||||
|
"Varanasi",
|
||||||
|
"Meerut",
|
||||||
|
"Prayagraj",
|
||||||
|
"Bareilly",
|
||||||
|
"Aligarh",
|
||||||
|
"Moradabad",
|
||||||
|
"Saharanpur",
|
||||||
|
"Gorakhpur",
|
||||||
|
"Noida",
|
||||||
|
"Firozabad",
|
||||||
|
"Jhansi",
|
||||||
|
"Muzaffarnagar",
|
||||||
|
"Mathura",
|
||||||
|
"Ayodhya",
|
||||||
|
"Shahjahanpur",
|
||||||
|
"Rampur",
|
||||||
|
"Modinagar",
|
||||||
|
"Hapur",
|
||||||
|
"Etawah",
|
||||||
|
"Mirzapur",
|
||||||
|
"Bulandshahr",
|
||||||
|
"Sambhal",
|
||||||
|
"Amroha",
|
||||||
|
"Hardoi",
|
||||||
|
"Fatehpur",
|
||||||
|
"Raebareli",
|
||||||
|
"Orai",
|
||||||
|
"Sitapur",
|
||||||
|
"Bahraich",
|
||||||
|
"Unnao",
|
||||||
|
"Jaunpur",
|
||||||
|
"Lakhimpur",
|
||||||
|
"Hathras",
|
||||||
|
"Banda",
|
||||||
|
"Pilibhit",
|
||||||
|
"Barabanki",
|
||||||
|
"Khurja",
|
||||||
|
"Gonda",
|
||||||
|
"Mainpuri",
|
||||||
|
"Lalitpur",
|
||||||
|
"Etah",
|
||||||
|
"Deoria",
|
||||||
|
"Azamgarh",
|
||||||
|
"Ghazipur",
|
||||||
|
"Sultanpur"
|
||||||
|
],
|
||||||
|
"Uttarakhand": [
|
||||||
|
"Dehradun",
|
||||||
|
"Haridwar",
|
||||||
|
"Roorkee",
|
||||||
|
"Haldwani",
|
||||||
|
"Rudrapur",
|
||||||
|
"Kashipur",
|
||||||
|
"Rishikesh",
|
||||||
|
"Kotdwar",
|
||||||
|
"Pithoragarh",
|
||||||
|
"Almora",
|
||||||
|
"Nainital",
|
||||||
|
"Mussoorie"
|
||||||
|
],
|
||||||
|
"West Bengal": [
|
||||||
|
"Kolkata",
|
||||||
|
"Howrah",
|
||||||
|
"Durgapur",
|
||||||
|
"Asansol",
|
||||||
|
"Siliguri",
|
||||||
|
"Bardhaman",
|
||||||
|
"Malda",
|
||||||
|
"Baharampur",
|
||||||
|
"Habra",
|
||||||
|
"Kharagpur",
|
||||||
|
"Shantipur",
|
||||||
|
"Dankuni",
|
||||||
|
"Dhulian",
|
||||||
|
"Ranaghat",
|
||||||
|
"Haldia",
|
||||||
|
"Raiganj",
|
||||||
|
"Krishnanagar",
|
||||||
|
"Naihati",
|
||||||
|
"Bhatpara",
|
||||||
|
"Medinipur",
|
||||||
|
"Jalpaiguri",
|
||||||
|
"Balurghat",
|
||||||
|
"Bankura",
|
||||||
|
"Cooch Behar",
|
||||||
|
"Purulia",
|
||||||
|
"Alipurduar",
|
||||||
|
"Darjeeling"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
@ -84,9 +84,10 @@
|
||||||
<option value=""> -- Select -- </option>
|
<option value=""> -- Select -- </option>
|
||||||
@foreach ($question->options as $option)
|
@foreach ($question->options as $option)
|
||||||
|
|
||||||
{{-- @if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' ) --}}
|
{{-- @if($question->code == 'contact_id' && ((isset($option->contact->type) && $option->contact->type == 'doctor') || !isset($option->contact))) --}}
|
||||||
@if($question->code == 'contact_id' && ((isset($option->contact->type) && $option->contact->type == 'doctor') || !isset($option->contact)))
|
|
||||||
<option value="{{ $option->value }}"
|
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||||
|
<option value="{{ $option->value }}"
|
||||||
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||||
@if($question->code == 'contact_id')
|
@if($question->code == 'contact_id')
|
||||||
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
msl_code="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||||
|
|
|
||||||
|
|
@ -378,8 +378,8 @@
|
||||||
|
|
||||||
var plandateField = document.getElementById('field-record_date');
|
var plandateField = document.getElementById('field-record_date');
|
||||||
|
|
||||||
plandateField.setAttribute('min', today);
|
plandateField.setAttribute('min',"2026-04-01");
|
||||||
plandateField.setAttribute('max',maxDate);
|
plandateField.setAttribute('max',today);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,10 @@
|
||||||
$tgicsSurveyData = \App\Helpers\TgicsHelper::getSurveyCounts($tgicsContactIds);
|
$tgicsSurveyData = \App\Helpers\TgicsHelper::getSurveyCounts($tgicsContactIds);
|
||||||
$tgicsSurveyCounts = $tgicsSurveyData['counts'] ?? [];
|
$tgicsSurveyCounts = $tgicsSurveyData['counts'] ?? [];
|
||||||
$totalSurveysDone = (int) ($tgicsSurveyData['total'] ?? 0);
|
$totalSurveysDone = (int) ($tgicsSurveyData['total'] ?? 0);
|
||||||
|
$tgicsWhatsappValidated = \App\Helpers\TgicsHelper::getWhatsappValidationStatus(
|
||||||
|
$tgicsContactIds,
|
||||||
|
'lifemankind'
|
||||||
|
);
|
||||||
|
|
||||||
$tgicsCommonUserId = trim((string) ($form->user_id ?? ''));
|
$tgicsCommonUserId = trim((string) ($form->user_id ?? ''));
|
||||||
$tgicsCommonLink = $tgicsCommonUserId !== ''
|
$tgicsCommonLink = $tgicsCommonUserId !== ''
|
||||||
|
|
@ -135,23 +139,41 @@
|
||||||
$surveysDone = $tgicsContactId !== ''
|
$surveysDone = $tgicsContactId !== ''
|
||||||
? (int) ($tgicsSurveyCounts[$tgicsContactId] ?? 0)
|
? (int) ($tgicsSurveyCounts[$tgicsContactId] ?? 0)
|
||||||
: 0;
|
: 0;
|
||||||
|
$whatsappValidated = $tgicsContactId !== ''
|
||||||
|
&& !empty($tgicsWhatsappValidated[$tgicsContactId]);
|
||||||
$whatsappText = "Dear Doctor" . ($doctorName !== '' ? ' ' . $doctorName : '') . ",\nThank you for participating in TGICS (The Great Indian Cough Study).\nPlease open the link and enter your WhatsApp mobile number to continue:\n" . $doctorLink;
|
$whatsappText = "Dear Doctor" . ($doctorName !== '' ? ' ' . $doctorName : '') . ",\nThank you for participating in TGICS (The Great Indian Cough Study).\nPlease open the link and enter your WhatsApp mobile number to continue:\n" . $doctorLink;
|
||||||
$whatsappLink = ($whatsappDigits !== '' && $doctorLink !== '')
|
$whatsappLink = ($whatsappDigits !== '' && $doctorLink !== '')
|
||||||
? 'https://api.whatsapp.com/send?phone=' . $whatsappDigits . '&text=' . rawurlencode($whatsappText)
|
? 'https://api.whatsapp.com/send?phone=' . $whatsappDigits . '&text=' . rawurlencode($whatsappText)
|
||||||
: '';
|
: '';
|
||||||
|
$validateToken = $tgicsContactId !== ''
|
||||||
|
? 'CREST_VERIFY_TGICS_' . $tgicsContactId
|
||||||
|
: '';
|
||||||
|
$validateWaUrl = $validateToken !== ''
|
||||||
|
? 'https://wa.me/918142061298?text=' . rawurlencode($validateToken)
|
||||||
|
: '';
|
||||||
@endphp
|
@endphp
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@if ($isApproved)
|
@if ($isApproved)
|
||||||
@if ($whatsappLink !== '')
|
@if ($doctorLink === '')
|
||||||
|
<span class="text-muted">Link unavailable</span>
|
||||||
|
@elseif ($whatsappDigits === '')
|
||||||
|
<span class="text-muted">No WhatsApp number</span>
|
||||||
|
@elseif ($whatsappValidated && $whatsappLink !== '')
|
||||||
<a href="{{ $whatsappLink }}" target="_blank" rel="noopener noreferrer"
|
<a href="{{ $whatsappLink }}" target="_blank" rel="noopener noreferrer"
|
||||||
class="btn btn-xs btn-success">
|
class="btn btn-xs btn-success">
|
||||||
<i class="mdi mdi-whatsapp"></i> Send WhatsApp
|
<i class="mdi mdi-whatsapp"></i> Send
|
||||||
</a>
|
</a>
|
||||||
@elseif ($doctorLink === '')
|
@elseif ($validateWaUrl !== '')
|
||||||
<span class="text-muted">Link unavailable</span>
|
<button type="button"
|
||||||
|
class="btn btn-xs btn-warning tgics-validate-wa-btn"
|
||||||
|
data-contact-id="{{ $tgicsContactId }}"
|
||||||
|
data-validate-url="{{ $validateWaUrl }}"
|
||||||
|
data-doctor-name="{{ $doctorName }}">
|
||||||
|
<i class="mdi mdi-qrcode"></i> Validate
|
||||||
|
</button>
|
||||||
@else
|
@else
|
||||||
<span class="text-muted">No WhatsApp number</span>
|
<span class="text-muted">Validation unavailable</span>
|
||||||
@endif
|
@endif
|
||||||
@else
|
@else
|
||||||
<button type="button" class="btn btn-xs btn-info edit-btn"
|
<button type="button" class="btn btn-xs btn-info edit-btn"
|
||||||
|
|
@ -399,6 +421,30 @@
|
||||||
<!-- end container -->
|
<!-- end container -->
|
||||||
</div>
|
</div>
|
||||||
<!-- end page -->
|
<!-- end page -->
|
||||||
|
|
||||||
|
<div class="modal fade" id="tgics-validate-wa-modal" tabindex="-1" role="dialog" aria-labelledby="tgics-validate-wa-title" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="tgics-validate-wa-title">Validate WhatsApp</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body text-center">
|
||||||
|
<p class="mb-2" id="tgics-validate-wa-doctor"></p>
|
||||||
|
<p class="text-muted small">Ask the doctor to scan this QR with the enrolled WhatsApp number and send the pre-filled message without changing it.</p>
|
||||||
|
<div id="tgics-validate-wa-qr" class="d-flex justify-content-center my-3"></div>
|
||||||
|
<p class="small mb-1" id="tgics-validate-wa-status">Waiting for validation…</p>
|
||||||
|
<a href="#" id="tgics-validate-wa-open" target="_blank" rel="noopener noreferrer" class="btn btn-sm btn-outline-success">
|
||||||
|
Open link instead
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#pageloader {
|
#pageloader {
|
||||||
background: rgba(255, 255, 255, 0.8);
|
background: rgba(255, 255, 255, 0.8);
|
||||||
|
|
@ -416,14 +462,116 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#tgics-validate-wa-qr canvas,
|
||||||
|
#tgics-validate-wa-qr img {
|
||||||
|
max-width: 220px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tgics-validate-wa-modal {
|
||||||
|
z-index: 1055;
|
||||||
|
}
|
||||||
|
.tgics-validate-backdrop {
|
||||||
|
z-index: 1050;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@include('layouts.shared/footer-script')
|
@include('layouts.shared/footer-script')
|
||||||
<script src="{{ asset('assets/libs/sweetalert2/sweetalert2.min.js') }}"></script>
|
<script src="{{ asset('assets/libs/sweetalert2/sweetalert2.min.js') }}"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
|
||||||
|
<script src="{{ asset('js/tgics-india-geo.js') }}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
$('#form-wrapper').hide()
|
$('#form-wrapper').hide()
|
||||||
$('#execution-form-wrapper').hide()
|
$('#execution-form-wrapper').hide()
|
||||||
|
|
||||||
|
var indiaGeo = window.TGICS_INDIA_GEO || {};
|
||||||
|
var indiaStates = Object.keys(indiaGeo).sort();
|
||||||
|
|
||||||
|
function fillSelectOptions($sel, values, selected, placeholder) {
|
||||||
|
$sel.empty();
|
||||||
|
$sel.append($('<option></option>').attr('value', '').text(placeholder || ' -- Select -- '));
|
||||||
|
(values || []).forEach(function(v) {
|
||||||
|
var $opt = $('<option></option>').attr('value', v).text(v);
|
||||||
|
if (selected && String(selected) === String(v)) {
|
||||||
|
$opt.prop('selected', true);
|
||||||
|
}
|
||||||
|
$sel.append($opt);
|
||||||
|
});
|
||||||
|
if (selected && values && values.indexOf(selected) === -1 && String(selected).trim() !== '') {
|
||||||
|
$sel.append(
|
||||||
|
$('<option></option>').attr('value', selected).text(selected + ' (current)').prop('selected', true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureAvgPatientsField(prefix) {
|
||||||
|
if ($('#' + prefix + '-average_no_of_patients').length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var $years = $('#' + prefix + '-years_of_practice').closest('.col-md-12.mb-2');
|
||||||
|
if (!$years.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var html =
|
||||||
|
'<div class="col-md-12 mb-2">' +
|
||||||
|
'<label for="' + prefix + '-average_no_of_patients" class="form-label">' +
|
||||||
|
'Average No. of Patients <span class="text-danger">*</span></label>' +
|
||||||
|
'<input type="number" min="0" max="999999" step="1" id="' + prefix +
|
||||||
|
'-average_no_of_patients" name="average_no_of_patients" class="form-control" required value="">' +
|
||||||
|
'</div>';
|
||||||
|
$years.after(html);
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertTextToSelect(prefix, code, values, placeholder) {
|
||||||
|
var $input = $('#' + prefix + '-' + code);
|
||||||
|
if (!$input.length || $input.is('select')) {
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
var current = $input.val() || '';
|
||||||
|
var required = $input.prop('required');
|
||||||
|
var $sel = $('<select></select>')
|
||||||
|
.attr('id', prefix + '-' + code)
|
||||||
|
.attr('name', code)
|
||||||
|
.addClass('form-control');
|
||||||
|
if (required) {
|
||||||
|
$sel.prop('required', true);
|
||||||
|
}
|
||||||
|
fillSelectOptions($sel, values, current, placeholder);
|
||||||
|
$input.replaceWith($sel);
|
||||||
|
return $sel;
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshCityOptions(prefix, keepCity) {
|
||||||
|
var state = $('#' + prefix + '-state').val() || '';
|
||||||
|
var cities = indiaGeo[state] || [];
|
||||||
|
var $city = $('#' + prefix + '-city_town');
|
||||||
|
if (!$city.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var current = keepCity != null ? keepCity : ($city.val() || '');
|
||||||
|
if (!$city.is('select')) {
|
||||||
|
$city = convertTextToSelect(prefix, 'city_town', cities, ' -- Select City -- ');
|
||||||
|
}
|
||||||
|
fillSelectOptions($city, cities, current, ' -- Select City -- ');
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupGeoFields(prefix) {
|
||||||
|
ensureAvgPatientsField(prefix);
|
||||||
|
convertTextToSelect(prefix, 'state', indiaStates, ' -- Select State -- ');
|
||||||
|
convertTextToSelect(prefix, 'city_town', [], ' -- Select City -- ');
|
||||||
|
refreshCityOptions(prefix);
|
||||||
|
$('#' + prefix + '-state').off('change.tgicsGeo').on('change.tgicsGeo', function() {
|
||||||
|
refreshCityOptions(prefix, '');
|
||||||
|
});
|
||||||
|
$('#' + prefix + '-average_no_of_patients').off('input.tgicsAvg').on('input.tgicsAvg', function() {
|
||||||
|
this.value = String(this.value || '').replace(/[^0-9]/g, '');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setupGeoFields('field');
|
||||||
|
setupGeoFields('execution');
|
||||||
|
|
||||||
function copyTgicsLink(text) {
|
function copyTgicsLink(text) {
|
||||||
function fallbackCopy() {
|
function fallbackCopy() {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
|
|
@ -522,7 +670,7 @@
|
||||||
// console.log($("#execution-contact_id option:contains(" + selected[k] + ")").attr('value'))
|
// console.log($("#execution-contact_id option:contains(" + selected[k] + ")").attr('value'))
|
||||||
$('#execution-contact_id').val($("#execution-contact_id option:contains(" +
|
$('#execution-contact_id').val($("#execution-contact_id option:contains(" +
|
||||||
selected[k] + ")").attr('value'));
|
selected[k] + ")").attr('value'));
|
||||||
} else if (k == 'upload_photo_1' || k == 'upload_photo_2') {
|
} else if (k == 'upload_photo_1' || k == 'upload_photo_2' || k == 'city_town' || k == 'state') {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
$('#execution-' + k).val(selected[k]);
|
$('#execution-' + k).val(selected[k]);
|
||||||
|
|
@ -532,6 +680,20 @@
|
||||||
// $('#execution-'+k).val(selected[k]);
|
// $('#execution-'+k).val(selected[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selected['state']) {
|
||||||
|
$('#execution-state').val(selected['state']);
|
||||||
|
if (!$('#execution-state').val() && selected['state']) {
|
||||||
|
$('#execution-state').append(
|
||||||
|
$('<option></option>').attr('value', selected['state'])
|
||||||
|
.text(selected['state'] + ' (current)').prop('selected', true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refreshCityOptions('execution', selected['city_town'] || '');
|
||||||
|
if (selected['average_no_of_patients'] != null && selected['average_no_of_patients'] !== '') {
|
||||||
|
$('#execution-average_no_of_patients').val(selected['average_no_of_patients']);
|
||||||
|
}
|
||||||
|
|
||||||
/* let docid = $('#execution-contact_id option').map(function() {
|
/* let docid = $('#execution-contact_id option').map(function() {
|
||||||
if ($(this).text().trim() == selected['contact_id'] || $(this).val().trim() == selected['cont_id']) return this;
|
if ($(this).text().trim() == selected['contact_id'] || $(this).val().trim() == selected['cont_id']) return this;
|
||||||
}).attr('value')
|
}).attr('value')
|
||||||
|
|
@ -611,7 +773,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#field-contact_id,#field-city_town,#field-state,#field-other_qualification').on('input', function () {
|
$('#field-contact_id,#field-other_qualification').on('input', function () {
|
||||||
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -660,6 +822,140 @@
|
||||||
$('#field-contact_id').trigger('change');
|
$('#field-contact_id').trigger('change');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var tgicsWaPollTimer = null;
|
||||||
|
var tgicsWaPollStartedAt = 0;
|
||||||
|
|
||||||
|
function stopTgicsWaPoll() {
|
||||||
|
if (tgicsWaPollTimer) {
|
||||||
|
clearInterval(tgicsWaPollTimer);
|
||||||
|
tgicsWaPollTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideTgicsValidateModal() {
|
||||||
|
stopTgicsWaPoll();
|
||||||
|
var $modal = $('#tgics-validate-wa-modal');
|
||||||
|
if ($.fn.modal && typeof $modal.modal === 'function') {
|
||||||
|
$modal.modal('hide');
|
||||||
|
} else if (window.bootstrap && bootstrap.Modal) {
|
||||||
|
var inst = bootstrap.Modal.getInstance($modal[0]);
|
||||||
|
if (inst) {
|
||||||
|
inst.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$modal.removeClass('show').css('display', 'none').attr('aria-hidden', 'true');
|
||||||
|
$('.tgics-validate-backdrop').remove();
|
||||||
|
$('body').removeClass('modal-open').css('overflow', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showTgicsValidateModal() {
|
||||||
|
var $modal = $('#tgics-validate-wa-modal');
|
||||||
|
if ($.fn.modal && typeof $modal.modal === 'function') {
|
||||||
|
$modal.modal('show');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (window.bootstrap && bootstrap.Modal) {
|
||||||
|
bootstrap.Modal.getOrCreateInstance($modal[0]).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Manual fallback when Bootstrap modal JS is unavailable
|
||||||
|
$modal.addClass('show').css('display', 'block').attr('aria-hidden', 'false');
|
||||||
|
if (!$('.tgics-validate-backdrop').length) {
|
||||||
|
$('body').append('<div class="modal-backdrop fade show tgics-validate-backdrop"></div>');
|
||||||
|
}
|
||||||
|
$('body').addClass('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function startTgicsWaPoll(contactId) {
|
||||||
|
stopTgicsWaPoll();
|
||||||
|
tgicsWaPollStartedAt = Date.now();
|
||||||
|
$('#tgics-validate-wa-status').text('Waiting for validation…');
|
||||||
|
|
||||||
|
tgicsWaPollTimer = setInterval(function() {
|
||||||
|
if (Date.now() - tgicsWaPollStartedAt > 120000) {
|
||||||
|
stopTgicsWaPoll();
|
||||||
|
$('#tgics-validate-wa-status').text('Still waiting. Close and try Validate again after the doctor sends the message.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: '/form/tgicswhatsappstatus',
|
||||||
|
data: {
|
||||||
|
contact_id: contactId,
|
||||||
|
partition: 'rapport-lifemankind'
|
||||||
|
},
|
||||||
|
success: function(res) {
|
||||||
|
if (res && res.status === 'success' && res.data && res.data.validated) {
|
||||||
|
stopTgicsWaPoll();
|
||||||
|
$('#tgics-validate-wa-status').text('Validated!');
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'success',
|
||||||
|
title: 'WhatsApp validated',
|
||||||
|
text: 'You can now send the survey link to this doctor.',
|
||||||
|
timer: 1800,
|
||||||
|
showConfirmButton: false
|
||||||
|
}).then(function() {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on('click', '.tgics-validate-wa-btn', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
var contactId = $(this).attr('data-contact-id') || '';
|
||||||
|
var validateUrl = $(this).attr('data-validate-url') || '';
|
||||||
|
var doctorName = $(this).attr('data-doctor-name') || 'Doctor';
|
||||||
|
if (!contactId || !validateUrl) {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Validation unavailable',
|
||||||
|
text: 'Missing doctor contact link. Please re-enrol or contact support.'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#tgics-validate-wa-doctor').text(doctorName);
|
||||||
|
$('#tgics-validate-wa-open').attr('href', validateUrl);
|
||||||
|
$('#tgics-validate-wa-qr').empty();
|
||||||
|
try {
|
||||||
|
if (typeof QRCode !== 'undefined') {
|
||||||
|
new QRCode(document.getElementById('tgics-validate-wa-qr'), {
|
||||||
|
text: validateUrl,
|
||||||
|
width: 200,
|
||||||
|
height: 200
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#tgics-validate-wa-qr').html(
|
||||||
|
'<p class="text-muted small mb-2">QR library unavailable. Use the button below.</p>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (qrErr) {
|
||||||
|
console.error(qrErr);
|
||||||
|
$('#tgics-validate-wa-qr').html(
|
||||||
|
'<p class="text-muted small mb-2">Unable to render QR. Use the button below.</p>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
showTgicsValidateModal();
|
||||||
|
startTgicsWaPoll(contactId);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '#tgics-validate-wa-modal [data-bs-dismiss="modal"], #tgics-validate-wa-modal .btn-close, #tgics-validate-wa-modal .btn-secondary', function() {
|
||||||
|
hideTgicsValidateModal();
|
||||||
|
});
|
||||||
|
$(document).on('click', '.tgics-validate-backdrop', function() {
|
||||||
|
hideTgicsValidateModal();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#tgics-validate-wa-modal').on('hidden.bs.modal hide.bs.modal', function() {
|
||||||
|
stopTgicsWaPoll();
|
||||||
|
$('.tgics-validate-backdrop').remove();
|
||||||
|
});
|
||||||
|
|
||||||
$('#execution-form').on('submit', function(event) {
|
$('#execution-form').on('submit', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("#pageloader").fadeIn();
|
$("#pageloader").fadeIn();
|
||||||
|
|
@ -706,28 +1002,27 @@
|
||||||
today = yyyy + '-' + mm + '-' + dd;
|
today = yyyy + '-' + mm + '-' + dd;
|
||||||
|
|
||||||
var recordDateField = document.getElementById('field-plan_date');
|
var recordDateField = document.getElementById('field-plan_date');
|
||||||
recordDateField.setAttribute('min', today);
|
if (recordDateField) {
|
||||||
|
recordDateField.setAttribute('min', today);
|
||||||
|
}
|
||||||
|
|
||||||
var executionDateField = document.getElementById('execution-plan_date');
|
var executionDateField = document.getElementById('execution-plan_date');
|
||||||
//executionDateField.setAttribute('min', today);
|
|
||||||
|
|
||||||
// $('.edit-btn').click(function() {
|
|
||||||
// var executionexeField = document.getElementById('execution-record_date');
|
|
||||||
// executionexeField.setAttribute('min', executionDateField.value);
|
|
||||||
// });
|
|
||||||
|
|
||||||
$('.edit-btn').click(function() {
|
$('.edit-btn').click(function() {
|
||||||
var executionexeField = document.getElementById('execution-execution_date');
|
var executionexeField = document.getElementById('execution-execution_date');
|
||||||
executionexeField.setAttribute('min', executionDateField.value);
|
if (executionexeField && executionDateField && executionDateField.value) {
|
||||||
|
executionexeField.setAttribute('min', executionDateField.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (executionDateField) {
|
||||||
|
executionDateField.addEventListener('change', function() {
|
||||||
executionDateField.addEventListener('change', function() {
|
var executionexeField = document.getElementById('execution-record_date');
|
||||||
console.log('gg');
|
if (executionexeField) {
|
||||||
var executionexeField = document.getElementById('execution-record_date');
|
executionexeField.setAttribute('min', executionDateField.value);
|
||||||
executionexeField.setAttribute('min', executionDateField.value);
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,767 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
@include('layouts.shared/title-meta', ['title' => "Form"])
|
||||||
|
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||||
|
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||||
|
<style>
|
||||||
|
|
||||||
|
/* =========================
|
||||||
|
SELECT2 CUSTOM HIGHLIGHT
|
||||||
|
========================= */
|
||||||
|
|
||||||
|
.select2-container .select2-selection--single{
|
||||||
|
height: 38px !important;
|
||||||
|
border: 1px solid #ced4da !important;
|
||||||
|
border-radius: 6px !important;
|
||||||
|
padding-top: 4px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||||
|
line-height: 28px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||||
|
height: 36px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dropdown option hover */
|
||||||
|
.select2-results__option--highlighted{
|
||||||
|
background-color: #0d6efd !important;
|
||||||
|
color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Selected option */
|
||||||
|
.select2-results__option[aria-selected=true]{
|
||||||
|
background-color: #dbe9ff !important;
|
||||||
|
color: black !important;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Search box */
|
||||||
|
.select2-search__field{
|
||||||
|
border-radius: 5px !important;
|
||||||
|
padding: 6px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<div id="pageloader">
|
||||||
|
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<body class="loading">
|
||||||
|
<div class="account-pages">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
|
||||||
|
<div class="card bg-pattern">
|
||||||
|
<div class="card-body p-3 row">
|
||||||
|
|
||||||
|
@if(Session::has('error'))<div class="alert alert-danger">{{Session::get('error')}}</div>
|
||||||
|
<br>@endif
|
||||||
|
@if(session('success'))<div class=" alert alert-success">{{ session('success') }}
|
||||||
|
</div>
|
||||||
|
<br>@endif
|
||||||
|
<div class="col-8">
|
||||||
|
<h4 class="page-title">{{$form->title}}</h4>
|
||||||
|
</div>
|
||||||
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'
|
||||||
|
) )
|
||||||
|
<div class="col-4">
|
||||||
|
@if($form->link_type == 'form')
|
||||||
|
<a href="/form/history" class="float-end pt-1">View History</a>
|
||||||
|
@else
|
||||||
|
<a href="{{url()->previous()}}" class="float-end pt-1">Back</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if(isset($form->user_info))
|
||||||
|
<div class="col-12">
|
||||||
|
<h6>Submitted By: {{$form->user_info->name}}</h6>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@php
|
||||||
|
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||||
|
$submissions = $submissions->data->submissions;
|
||||||
|
|
||||||
|
|
||||||
|
@endphp
|
||||||
|
@if(count($submissions)===0 || $id)
|
||||||
|
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||||
|
@csrf
|
||||||
|
@if($id)
|
||||||
|
<input type="hidden" name="id[0]" value="{{$id}}">
|
||||||
|
@endif
|
||||||
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||||
|
<div class="col-md-12 mb-2">
|
||||||
|
<label for="field-user_id" class="form-label"> Select User / Territory <span class="text-danger">*</span> </label>
|
||||||
|
<select class="form-control" id="field-user_id" name="user_id" required>
|
||||||
|
<option value=""> -- Select -- </option>
|
||||||
|
@foreach($form->users as $option)
|
||||||
|
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@foreach($questions as $question)
|
||||||
|
@if( !in_array($question->code,
|
||||||
|
["record_date","select_rxber_type"] ) )
|
||||||
|
@continue;
|
||||||
|
@endif
|
||||||
|
<div class="col-md-12 mb-2">
|
||||||
|
<label for="field-{{$question->code}}" class="form-label">{{$question->question}}
|
||||||
|
{!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!}
|
||||||
|
</label>
|
||||||
|
@switch($question->type)
|
||||||
|
@case('hidden')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||||
|
name="{{$question->code}}"
|
||||||
|
value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('text')
|
||||||
|
@case('email')
|
||||||
|
@case('tel')
|
||||||
|
@case('date')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||||
|
name="{{$question->code}}" class="form-control"
|
||||||
|
{{$question->required == 'yes'?'required':'' }}
|
||||||
|
value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('number')
|
||||||
|
<input type="{{$question->type}}" min="0" max="9999999999" step="1"
|
||||||
|
id="field-{{$question->code}}" name="{{$question->code}}" class="form-control"
|
||||||
|
{{$question->required == 'yes'?'required':'' }}
|
||||||
|
value="{{isset($question->value)?$question->value:0}}">
|
||||||
|
@break
|
||||||
|
@case('textarea')
|
||||||
|
<textarea id="field-{{$question->code}}" name="{{$question->code}}"
|
||||||
|
class="form-control"
|
||||||
|
{{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||||
|
@break
|
||||||
|
@case('dropdown')
|
||||||
|
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||||
|
<option value=""> -- Select -- </option>
|
||||||
|
@foreach ($question->options as $option)
|
||||||
|
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||||
|
<option value="{{ $option->value }}"
|
||||||
|
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||||
|
@if($question->code == 'contact_id')
|
||||||
|
msl_code="{{ (isset($option->contact->legacy_code) ? $option->contact->legacy_code : '') }}"
|
||||||
|
pcode="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||||
|
|
||||||
|
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||||
|
@endif
|
||||||
|
>
|
||||||
|
{{ $option->display }}
|
||||||
|
</option>
|
||||||
|
@elseif($question->code != 'contact_id')
|
||||||
|
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||||
|
{{ $option->display }}
|
||||||
|
</option>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@break
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@endswitch
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
<div class="doctor-wrapper">
|
||||||
|
|
||||||
|
@foreach($questions as $question)
|
||||||
|
@if( in_array($question->code,
|
||||||
|
["record_date","select_rxber_type"] ) )
|
||||||
|
@continue;
|
||||||
|
@endif
|
||||||
|
<div class="col-md-12 mb-2">
|
||||||
|
<label for="field-{{$question->code}}"
|
||||||
|
class="form-label">{{$question->question}} {!!$question->required == 'yes' ?
|
||||||
|
'<span class="text-danger">*</span>':''!!} </label>
|
||||||
|
@switch($question->type)
|
||||||
|
@case('hidden')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||||
|
name="{{$question->code}}[0]"
|
||||||
|
value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('text')
|
||||||
|
@case('email')
|
||||||
|
@case('tel')
|
||||||
|
@case('date')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}"
|
||||||
|
name="{{$question->code}}[0]" class="form-control"
|
||||||
|
{{$question->required == 'yes'?'required':'' }}
|
||||||
|
value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('number')
|
||||||
|
<input type="{{$question->type}}" min="0" max="9999999999" step="1"
|
||||||
|
id="field-{{$question->code}}" name="{{$question->code}}[0]"
|
||||||
|
class="form-control" {{$question->required == 'yes'?'required':'' }}
|
||||||
|
value="{{isset($question->value)?$question->value:0}}">
|
||||||
|
@break
|
||||||
|
@case('textarea')
|
||||||
|
<textarea id="field-{{$question->code}}" name="{{$question->code}}[0]"
|
||||||
|
class="form-control"
|
||||||
|
{{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||||
|
@break
|
||||||
|
@case('dropdown')
|
||||||
|
@if ($question->code == 'contact_id')
|
||||||
|
<select class="form-control" id="field-{{ $question->code }}"
|
||||||
|
name="{{ $question->code }}[0]"
|
||||||
|
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||||
|
<option value=""> -- Select -- </option>
|
||||||
|
@foreach ($question->options as $option)
|
||||||
|
|
||||||
|
|
||||||
|
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||||
|
<option value="{{ $option->value }}"
|
||||||
|
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||||
|
@if($question->code == 'contact_id')
|
||||||
|
msl_code="{{ (isset($option->contact->legacy_code) ? $option->contact->legacy_code : '') }}"
|
||||||
|
pcode="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||||
|
|
||||||
|
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||||
|
@endif
|
||||||
|
>
|
||||||
|
{{ $option->display }}
|
||||||
|
</option>
|
||||||
|
@elseif($question->code != 'contact_id')
|
||||||
|
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||||
|
{{ $option->display }}
|
||||||
|
</option>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@else
|
||||||
|
<select class="form-control" id="execution-{{ $question->code }}"
|
||||||
|
name="{{ $question->code }}[0]"
|
||||||
|
{{ $question->required == 'yes' ? 'required' : '' }}>
|
||||||
|
<option value=""> -- Select -- </option>
|
||||||
|
@foreach ($question->options as $option)
|
||||||
|
<option value="{{ $option->value }}"
|
||||||
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}>
|
||||||
|
{{ $option->display }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@endif
|
||||||
|
@break
|
||||||
|
@case('checkbox')
|
||||||
|
@foreach($question->options as $option)
|
||||||
|
<div class="form-check mb-2 form-check-primary">
|
||||||
|
<input class="form-check-input" type="checkbox"
|
||||||
|
id="field-{{$question->code}}-{{$option->value}}"
|
||||||
|
name="{{$question->code}}[0]" value="{{$option->value}}"
|
||||||
|
{{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||||
|
<label class="form-check-label"
|
||||||
|
for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@break
|
||||||
|
@case('file')
|
||||||
|
@if(!isset($form->is_approval) || (isset($form->is_approval) &&
|
||||||
|
$form->is_approval != 'yes' ) )
|
||||||
|
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}"
|
||||||
|
class="form-control" value=""
|
||||||
|
{{$question->required == 'yes'?'required':'' }}>
|
||||||
|
@elseif(isset($question->value))
|
||||||
|
<img src="{{$question->value}}" class="img-fluid">
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@break
|
||||||
|
@case('multitextbox')
|
||||||
|
<div class="row">
|
||||||
|
@foreach($question->options as $option)
|
||||||
|
<div class="col-6">{{$option->display}}</div>
|
||||||
|
<div class="col-6 mb-1">
|
||||||
|
<input type="number" id="field-{{$option->value}}"
|
||||||
|
name="{{$option->value}}" class="form-control" required
|
||||||
|
value="{{isset($option->val)?$option->val:0}}">
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@break
|
||||||
|
@endswitch
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
<div id="doctor-group-wrapper">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval !=
|
||||||
|
'yes' ) )
|
||||||
|
<div class="text-center button-list">
|
||||||
|
@if(!$id)
|
||||||
|
<button class="btn btn-primary" type="button" id="adddoctor-btn"> Add Doctor </button>
|
||||||
|
@endif
|
||||||
|
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</form>
|
||||||
|
@elseif(!$id)
|
||||||
|
<h4>You have submitted 10 doctors</h4>
|
||||||
|
@endif
|
||||||
|
</div> <!-- end card-body -->
|
||||||
|
</div>
|
||||||
|
<!-- end card -->
|
||||||
|
|
||||||
|
<!-- end row -->
|
||||||
|
|
||||||
|
</div> <!-- end col -->
|
||||||
|
</div>
|
||||||
|
<!-- end row -->
|
||||||
|
</div>
|
||||||
|
<!-- end container -->
|
||||||
|
</div>
|
||||||
|
<!-- end page -->
|
||||||
|
<style type="text/css">
|
||||||
|
#pageloader {
|
||||||
|
background: rgba(255, 255, 255, 0.8);
|
||||||
|
display: none;
|
||||||
|
height: 100%;
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pageloader img {
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -32px;
|
||||||
|
margin-top: -32px;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.doctor-wrapper {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@include('layouts.shared/footer-script')
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||||
|
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
jQuery(document).ready(function($) {
|
||||||
|
|
||||||
|
$('#field-contact_id').on('change',function(){
|
||||||
|
$('#field-msl_code').val($(this).find(":selected").attr("msl_code"));
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-contact_id').on('change',function(){
|
||||||
|
$('#field-pcode').val($(this).find(":selected").attr("pcode"));
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-contact_id').on('change',function(){
|
||||||
|
$('#field-speciality').val($(this).find(":selected").attr("speciality"));
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-msl_code,#field-pcode,#field-speciality').attr('readonly',true);
|
||||||
|
|
||||||
|
/* $('#field-brand_name').on('input', function () {
|
||||||
|
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||||
|
}); */
|
||||||
|
|
||||||
|
|
||||||
|
$(document).on('input', 'input[id^="field-brand_name"]', function () {
|
||||||
|
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
function initializeSelect2() {
|
||||||
|
|
||||||
|
$('select[id^="field-contact_id"]').select2({
|
||||||
|
width: '100%',
|
||||||
|
placeholder: '-- Select Doctor --'
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#field-user_id').select2({
|
||||||
|
width: '100%',
|
||||||
|
placeholder: '-- Select User / Territory --'
|
||||||
|
});
|
||||||
|
|
||||||
|
$('select[id^="execution-"]').select2({
|
||||||
|
width: '100%'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeSelect2();
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* function preventDuplicateDoctors() {
|
||||||
|
|
||||||
|
let selectedValues = [];
|
||||||
|
|
||||||
|
// Get all selected doctor values
|
||||||
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
|
||||||
|
let value = $(this).val();
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
selectedValues.push(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// Apply duplicate prevention
|
||||||
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
|
||||||
|
let currentSelect = $(this);
|
||||||
|
let currentValue = currentSelect.val();
|
||||||
|
|
||||||
|
currentSelect.find('option').each(function () {
|
||||||
|
|
||||||
|
let option = $(this);
|
||||||
|
let optionValue = option.val();
|
||||||
|
|
||||||
|
if (!optionValue) return;
|
||||||
|
|
||||||
|
// Remove old text
|
||||||
|
let cleanText = option.text().replace(' (Already Added)', '');
|
||||||
|
|
||||||
|
if (
|
||||||
|
selectedValues.includes(optionValue) &&
|
||||||
|
optionValue !== currentValue
|
||||||
|
) {
|
||||||
|
|
||||||
|
option.prop('disabled', true);
|
||||||
|
option.text(cleanText + ' (Already Added)');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
option.prop('disabled', false);
|
||||||
|
option.text(cleanText);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// 🔥 IMPORTANT
|
||||||
|
currentSelect.select2('destroy');
|
||||||
|
|
||||||
|
currentSelect.select2({
|
||||||
|
width: '100%',
|
||||||
|
placeholder: '-- Select Doctor --'
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
} */
|
||||||
|
|
||||||
|
function preventDuplicateDoctors() {
|
||||||
|
|
||||||
|
let selectedValues = [];
|
||||||
|
|
||||||
|
// Collect selected values
|
||||||
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
|
||||||
|
let value = $(this).val();
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
selectedValues.push(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('select[id^="field-contact_id"]').each(function () {
|
||||||
|
|
||||||
|
let currentSelect = $(this);
|
||||||
|
let currentValue = currentSelect.val();
|
||||||
|
|
||||||
|
currentSelect.find('option').each(function () {
|
||||||
|
|
||||||
|
let option = $(this);
|
||||||
|
let optionValue = option.val();
|
||||||
|
|
||||||
|
if (!optionValue) return;
|
||||||
|
|
||||||
|
// remove previous label
|
||||||
|
let cleanText = option.text().replace(' (Already Added)', '');
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// keep currently selected option enabled
|
||||||
|
if (
|
||||||
|
selectedValues.includes(optionValue) &&
|
||||||
|
optionValue !== currentValue
|
||||||
|
) {
|
||||||
|
|
||||||
|
option.prop('disabled', true);
|
||||||
|
option.text(cleanText + ' (Already Added)');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
option.prop('disabled', false);
|
||||||
|
option.text(cleanText);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// refresh select2 safely
|
||||||
|
if (currentSelect.hasClass("select2-hidden-accessible")) {
|
||||||
|
currentSelect.select2('destroy');
|
||||||
|
}
|
||||||
|
|
||||||
|
currentSelect.select2({
|
||||||
|
width: '100%',
|
||||||
|
placeholder: '-- Select Doctor --'
|
||||||
|
});
|
||||||
|
|
||||||
|
// VERY IMPORTANT FOR EDIT MODE
|
||||||
|
currentSelect.val(currentValue).trigger('change.select2');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$(document).on('change', 'select[id^="field-contact_id"]', function () {
|
||||||
|
|
||||||
|
let selectedOption = $(this).find(':selected');
|
||||||
|
|
||||||
|
let id = $(this).attr('id').split('-').pop(); // get doctor_count dynamically
|
||||||
|
|
||||||
|
$('#field-msl_code-' + id).val(selectedOption.attr('msl_code'));
|
||||||
|
$('#field-pcode-' + id).val(selectedOption.attr('pcode'));
|
||||||
|
$('#field-speciality-' + id).val(selectedOption.attr('speciality'));
|
||||||
|
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var doctor_count = 0
|
||||||
|
let numberOfSubmission=0;
|
||||||
|
console.log("Number of Submission : ",numberOfSubmission);
|
||||||
|
$('#adddoctor-btn').click(function() {
|
||||||
|
let doctorName=$('#field-contact_id').html();
|
||||||
|
|
||||||
|
console.log("Doctor Name : ",doctorName);
|
||||||
|
doctor_count++;
|
||||||
|
numberOfSubmission=numberOfSubmission+1;
|
||||||
|
console.log("Number of Submission : ",numberOfSubmission);
|
||||||
|
|
||||||
|
let empty_doctor = `
|
||||||
|
|
||||||
|
<div class="doctor-wrapper"><button type="button" class="btn btn-danger btn-remove float-end" style="margin-top:-25px; margin-right:-25px"><i class="mdi mdi-close"></i></button>
|
||||||
|
|
||||||
|
@foreach($questions as $question)
|
||||||
|
@if( in_array($question->code,
|
||||||
|
["record_date","select_rxber_type"] ) )
|
||||||
|
@continue;
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="col-md-12 mb-2">
|
||||||
|
<label for="field-{{$question->code}}" class="form-label">{{$question->question}} {!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!} </label>
|
||||||
|
@switch($question->type)
|
||||||
|
@case('hidden')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('text')
|
||||||
|
@case('file')
|
||||||
|
@case('email')
|
||||||
|
@case('tel')
|
||||||
|
@case('date')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('number')
|
||||||
|
<input type="{{$question->type}}" min="0" max="9999999999" step="1" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||||
|
@break
|
||||||
|
@case('dropdown')
|
||||||
|
<select class="form-control" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" {{$question->required == 'yes'?'required':'' }}>
|
||||||
|
@if($question->code=='contact_id')
|
||||||
|
${doctorName}
|
||||||
|
@else
|
||||||
|
<option value=""> -- Select -- </option>
|
||||||
|
@foreach($question->options as $option)
|
||||||
|
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'msl_code= ' . $option->contact->msl_code . ' ' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||||
|
{{ $option->display }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
</select>
|
||||||
|
@break
|
||||||
|
@case('checkbox')
|
||||||
|
<div class="checkbox-group">
|
||||||
|
@if(isset($question->options) && count($question->options) > 0)
|
||||||
|
@foreach($question->options as $option)
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="field-{{$question->code}}-${doctor_count}-{{ $loop->index }}"
|
||||||
|
name="{{$question->code}}[${doctor_count}][]"
|
||||||
|
value="{{ $option->value }}"
|
||||||
|
{{ isset($question->value) && (is_array($question->value) ? in_array($option->value, $question->value) : $question->value == $option->value) ? 'checked' : '' }}>
|
||||||
|
<label class="form-check-label" for="field-{{$question->code}}-${doctor_count}-{{ $loop->index }}">
|
||||||
|
{{ $option->display }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@else
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="field-{{$question->code}}-${doctor_count}"
|
||||||
|
name="{{$question->code}}[${doctor_count}]"
|
||||||
|
value="1"
|
||||||
|
{{ isset($question->value) && $question->value ? 'checked' : '' }}>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@break
|
||||||
|
|
||||||
|
@endswitch
|
||||||
|
</div>
|
||||||
|
@endforeach </div>`;
|
||||||
|
|
||||||
|
|
||||||
|
$('#doctor-group-wrapper').append(empty_doctor)
|
||||||
|
|
||||||
|
$('#field-contact_id-'+doctor_count).select2({
|
||||||
|
|
||||||
|
width: '100%',
|
||||||
|
placeholder: '-- Select Doctor --'
|
||||||
|
});
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
|
||||||
|
|
||||||
|
$('select[id^="execution-"]').select2({
|
||||||
|
width: '100%'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
$('#field-msl_code-'+doctor_count).attr('readonly',true);
|
||||||
|
$('#field-pcode-'+doctor_count).attr('readonly',true);
|
||||||
|
$('#field-speciality-'+doctor_count).attr('readonly',true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($('.doctor-wrapper').length >= 10) {
|
||||||
|
$('#adddoctor-btn').hide();
|
||||||
|
} else {
|
||||||
|
$('#adddoctor-btn').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$('.btn-remove').unbind();
|
||||||
|
$('.btn-remove').click(function() {
|
||||||
|
$(this).closest('.doctor-wrapper').find('select').select2('destroy');
|
||||||
|
$(this).closest('.doctor-wrapper').remove();
|
||||||
|
numberOfSubmission--;
|
||||||
|
doctor_count--
|
||||||
|
preventDuplicateDoctors();
|
||||||
|
console.log("New Number of Submission : ",numberOfSubmission);
|
||||||
|
console.log("Number of doctors : ",doctor_count);
|
||||||
|
$('#adddoctor-btn').show();
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#field-user_id').change(function(){
|
||||||
|
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||||
|
$('#field-hierarchy_id').val(hierarchy)
|
||||||
|
event.preventDefault();
|
||||||
|
$('#pageloader').fadeIn();
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function( data ) {
|
||||||
|
$("#pageloader").fadeOut();
|
||||||
|
$('#field-contact_id').html('')
|
||||||
|
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||||
|
for (let itm of data) {
|
||||||
|
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display).attr("msl_code", itm.contact.msl_code).attr("speciality", itm.contact.speciality));
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#field-contact_id').change(function() {
|
||||||
|
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
$('#field-contact_id').change(function() {
|
||||||
|
$('#field-pcode').val($('option:selected', this).attr('pcode'))
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-contact_id').change(function() {
|
||||||
|
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(hierarchy)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
$('#report-form').on('submit', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (numberOfSubmission !=10) {
|
||||||
|
alert(`You must submit 10 Doctors for Ciphaler , Current Doctors : ${numberOfSubmission+1}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$("#pageloader").fadeIn();
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: '/form/ajaxsubmitmultiple',
|
||||||
|
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'
|
||||||
|
}).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!'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,324 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
@include('layouts.shared/title-meta', ['title' => "Form"])
|
||||||
|
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||||
|
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
||||||
|
</head>
|
||||||
|
<div id="pageloader">
|
||||||
|
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||||
|
</div>
|
||||||
|
<body class="loading">
|
||||||
|
<div class="account-pages">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
|
||||||
|
<div class="card bg-pattern">
|
||||||
|
<div class="card-body p-3 row">
|
||||||
|
|
||||||
|
@if(Session::has('error'))<div class="alert alert-danger">{{Session::get('error')}}</div>
|
||||||
|
<br>@endif
|
||||||
|
@if(session('success'))<div class=" alert alert-success">{{ session('success') }}
|
||||||
|
</div>
|
||||||
|
<br>@endif
|
||||||
|
<div class="col-8">
|
||||||
|
<h4 class="page-title">{{$form->title}}</h4>
|
||||||
|
</div>
|
||||||
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||||
|
<div class="col-4">
|
||||||
|
@if($form->link_type == 'form')
|
||||||
|
<a href="/form/history" class="float-end pt-1">View History</a>
|
||||||
|
@else
|
||||||
|
<a href="{{url()->previous()}}" class="float-end pt-1">Back</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if(isset($form->user_info))
|
||||||
|
<div class="col-12">
|
||||||
|
<h6>Submitted By: {{$form->user_info->name}}</h6>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||||
|
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||||
|
|
||||||
|
@csrf
|
||||||
|
@if($id)
|
||||||
|
<input type="hidden" name="id" value="{{$id}}">
|
||||||
|
@endif
|
||||||
|
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||||
|
<div class="col-md-12 mb-2">
|
||||||
|
<label for="field-user_id" class="form-label"> Select User / Territory <span class="text-danger">*</span> </label>
|
||||||
|
<select class="form-control" id="field-user_id" name="user_id" required>
|
||||||
|
<option value=""> -- Select -- </option>
|
||||||
|
@foreach($form->users as $option)
|
||||||
|
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
|
@foreach($questions as $question)
|
||||||
|
<div class="col-md-12 mb-2">
|
||||||
|
<label for="field-{{$question->code}}" class="form-label">{{$question->question}} {!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!} </label>
|
||||||
|
@switch($question->type)
|
||||||
|
@case('hidden')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('text')
|
||||||
|
@case('email')
|
||||||
|
@case('tel')
|
||||||
|
@case('date')
|
||||||
|
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
@break
|
||||||
|
@case('number')
|
||||||
|
<input type="{{$question->type}}" min="0" max="9999999999" step="1" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||||
|
@break
|
||||||
|
@case('textarea')
|
||||||
|
<textarea id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||||
|
@break
|
||||||
|
@case('dropdown')
|
||||||
|
<select class="form-control" {!!($question->code
|
||||||
|
== 'contact_id')?'data-toggle="select2"':'' !!} id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||||
|
<option value=""> -- Select -- </option>
|
||||||
|
@foreach ($question->options as $option)
|
||||||
|
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' && isset($option->contact->levoswitch_drs) && $option->contact->levoswitch_drs == 'Yes' )
|
||||||
|
<option value="{{ $option->value }}"
|
||||||
|
@if(isset($question->value) && $question->value == $option->value) selected @endif
|
||||||
|
@if($question->code == 'contact_id')
|
||||||
|
msl_code="{{ (isset($option->contact->legacy_code) ? $option->contact->legacy_code : '') }}"
|
||||||
|
pcode="{{ (isset($option->contact->msl_code) ? $option->contact->msl_code : '') }}"
|
||||||
|
|
||||||
|
speciality="{{ (isset($option->contact->speciality) ? $option->contact->speciality : '') }}"
|
||||||
|
@endif
|
||||||
|
>
|
||||||
|
{{ $option->display }}
|
||||||
|
</option>
|
||||||
|
@elseif($question->code != 'contact_id')
|
||||||
|
<option value="{{ $option->value }}" {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'pcode= ' . (isset($option->contact->pcode)?$option->contact->pcode:'') . ' ' : '' }} {{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }} {{ $question->code == 'contact_id' ? 'speciality= ' . (isset($option->contact->speciality) ? $option->contact->speciality :'') . ' ' : '' }} >
|
||||||
|
{{ $option->display }}
|
||||||
|
</option>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</select>
|
||||||
|
@break
|
||||||
|
@case('checkbox')
|
||||||
|
@foreach($question->options as $option)
|
||||||
|
<div class="form-check mb-2 form-check-primary">
|
||||||
|
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||||
|
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@break
|
||||||
|
@case('file')
|
||||||
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||||
|
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" {{$question->required == 'yes'?'required':'' }}>
|
||||||
|
@elseif(isset($question->value))
|
||||||
|
<img src="{{$question->value}}" class="img-fluid">
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@break
|
||||||
|
@case('multitextbox')
|
||||||
|
<div class="row">
|
||||||
|
@foreach($question->options as $option)
|
||||||
|
<div class="col-6">{{$option->display}}</div>
|
||||||
|
<div class="col-6 mb-1">
|
||||||
|
<input type="number" id="field-{{$option->value}}" name="{{$option->value}}" class="form-control" required value="{{isset($option->val)?$option->val:0}}">
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case('time')
|
||||||
|
<input type="time"
|
||||||
|
id="field-{{$question->code}}"
|
||||||
|
name="{{$question->code}}"
|
||||||
|
class="form-control"
|
||||||
|
{{$question->required == 'yes' ? 'required' : ''}}
|
||||||
|
value="{{isset($question->value) ? $question->value : ''}}">
|
||||||
|
@break
|
||||||
|
|
||||||
|
@endswitch
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||||
|
<div class="text-center d-grid mt-3">
|
||||||
|
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div> <!-- end card-body -->
|
||||||
|
</div>
|
||||||
|
<!-- end card -->
|
||||||
|
|
||||||
|
<!-- end row -->
|
||||||
|
|
||||||
|
</div> <!-- end col -->
|
||||||
|
</div>
|
||||||
|
<!-- end row -->
|
||||||
|
</div>
|
||||||
|
<!-- end container -->
|
||||||
|
</div>
|
||||||
|
<!-- end page -->
|
||||||
|
<style type="text/css">
|
||||||
|
#pageloader {
|
||||||
|
background: rgba( 255, 255, 255, 0.8 );
|
||||||
|
display: none;
|
||||||
|
height: 100%;
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pageloader img {
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -32px;
|
||||||
|
margin-top: -32px;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@include('layouts.shared/footer-script')
|
||||||
|
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||||
|
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
jQuery(document).ready(function($){
|
||||||
|
$('[data-toggle="select2"]').select2();
|
||||||
|
$('#field-user_id').change(function(){
|
||||||
|
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||||
|
$('#field-hierarchy_id').val(hierarchy)
|
||||||
|
event.preventDefault();
|
||||||
|
$("#pageloader").fadeIn();
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function( data ) {
|
||||||
|
$("#pageloader").fadeOut();
|
||||||
|
$('#field-contact_id').html('')
|
||||||
|
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||||
|
for (let itm of data) {
|
||||||
|
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display).attr("msl_code", itm.contact.msl_code).attr('speciality',itm.contact.speciality));
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#field-contact_id').change(function() {
|
||||||
|
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-contact_id').change(function() {
|
||||||
|
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(hierarchy)
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-contact_id').change(function() {
|
||||||
|
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-contact_id').change(function() {
|
||||||
|
$('#field-msl_code').val($('option:selected', this).attr('msl_code'))
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-contact_id').change(function() {
|
||||||
|
$('#field-pcode').val($('option:selected', this).attr('pcode'))
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#field-msl_code,#field-pcode,#field-speciality').attr('readonly',true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#field-file_upload').on('change', function () {
|
||||||
|
let file = this.files[0];
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
let allowedTypes = ['image/png', 'image/jpg', 'image/jpeg'];
|
||||||
|
let maxSize = 10 * 1024 * 1024; // 10 MB
|
||||||
|
|
||||||
|
// Type validation
|
||||||
|
if (!allowedTypes.includes(file.type)) {
|
||||||
|
alert('Only PNG, JPG, and JPEG files are allowed.');
|
||||||
|
$(this).val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Size validation
|
||||||
|
if (file.size > maxSize) {
|
||||||
|
alert('File size should not exceed 10 MB.');
|
||||||
|
$(this).val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#field-contact_id').trigger('change');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#field-brand_name_of_current_competition').on('input', function () {
|
||||||
|
this.value = this.value.replace(/[^a-zA-Z\s]/g, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('#report-form').on('submit', function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
const formData = new FormData($('#report-form')[0]);
|
||||||
|
// Log form data to console
|
||||||
|
for (let [key, value] of formData.entries()) {
|
||||||
|
console.log(key, value);
|
||||||
|
}
|
||||||
|
$("#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'
|
||||||
|
}).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!'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var today = new Date();
|
||||||
|
var dd = String(today.getDate()).padStart(2, '0');
|
||||||
|
var mm = String(today.getMonth() + 1).padStart(2, '0');
|
||||||
|
var yyyy = today.getFullYear();
|
||||||
|
today = yyyy + '-' + mm + '-' + dd;
|
||||||
|
|
||||||
|
var plandateField = document.getElementById('field-record_date');
|
||||||
|
|
||||||
|
plandateField.setAttribute('max', today);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -332,6 +332,7 @@ Route::get('/form/nebmitraverification', [FormController::class, 'nebmitraverifi
|
||||||
|
|
||||||
Route::get('/form/respidoctorsearch', [FormController::class, 'respidoctorsearch']);
|
Route::get('/form/respidoctorsearch', [FormController::class, 'respidoctorsearch']);
|
||||||
Route::get('/form/addrespidoctor', [FormController::class, 'addrespidoctor']);
|
Route::get('/form/addrespidoctor', [FormController::class, 'addrespidoctor']);
|
||||||
|
Route::get('/form/tgicswhatsappstatus', [FormController::class, 'tgicsWhatsappStatus']);
|
||||||
|
|
||||||
Route::post('/form/getformfielddata', [FormController::class, 'getformfielddata']);
|
Route::post('/form/getformfielddata', [FormController::class, 'getformfielddata']);
|
||||||
Route::post('/form/submit', [FormController::class, 'submit']);
|
Route::post('/form/submit', [FormController::class, 'submit']);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue