1282 lines
81 KiB
PHP
1282 lines
81 KiB
PHP
<!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" />
|
|
</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> -->
|
|
<button type="button" class="btn btn-primary btn-xs" id="add-camp-btn">Add
|
|
Plan</button>
|
|
@else
|
|
<a href="{{ url()->previous() }}" class="float-end pt-1">Back</a>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
|
|
@php
|
|
$history = Formhelper::getMultiformData(
|
|
$form->partition,
|
|
$form->form_id,
|
|
$form->user_id,
|
|
);
|
|
|
|
// echo "<pre>";
|
|
// print_r($history);
|
|
|
|
@endphp
|
|
|
|
@php
|
|
$plannedBrandData = [
|
|
[
|
|
'brand' => 'EMBREMMA',
|
|
'slug' => 'patient_tracker_planned_embremma_units',
|
|
'pseudoId' => 'patient_tracker_planned_embremma_values',
|
|
'total_slug' => 'patient_tracker_planned_embremma_total_units',
|
|
'total_slug_value' => 'patient_tracker_planned_embremma_total_values',
|
|
],
|
|
[
|
|
'brand' => 'SOMALINX-LAR',
|
|
'slug' => 'patient_tracker_planned_somalinx_lar_units',
|
|
'pseudoId' => 'patient_tracker_planned_somalinx_lar_values',
|
|
'total_slug' => 'patient_tracker_planned_somalinx_lar_total_units',
|
|
'total_slug_value' => 'patient_tracker_planned_somalinx_lar_total_values',
|
|
],
|
|
[
|
|
'brand' => 'Enzuta 40mg',
|
|
'slug' => 'patient_tracker_planned_enzuta_40mg_units',
|
|
'pseudoId' => 'patient_tracker_planned_enzuta_40mg_values',
|
|
'total_slug' => 'patient_tracker_planned_enzuta_40mg_total_units',
|
|
'total_slug_value' => 'patient_tracker_planned_enzuta_40mg_total_values',
|
|
],
|
|
];
|
|
|
|
$executionBrandData = [
|
|
[
|
|
'brand' => 'EMBREMMA',
|
|
'slug' => 'patient_tracker_execution_embremma_units',
|
|
'pseudoId' => 'patient_tracker_execution_embremma_values',
|
|
'total_slug' => 'patient_tracker_execution_embremma_total_units',
|
|
'total_slug_value' => 'patient_tracker_execution_embremma_total_values',
|
|
],
|
|
[
|
|
'brand' => 'SOMALINX-LAR',
|
|
'slug' => 'patient_tracker_execution_somalinx_lar_units',
|
|
'pseudoId' => 'patient_tracker_execution_somalinx_lar_values',
|
|
'total_slug' => 'patient_tracker_execution_somalinx_lar_total_units',
|
|
'total_slug_value' => 'patient_tracker_execution_somalinx_lar_total_values',
|
|
],
|
|
[
|
|
'brand' => 'Enzuta 40mg',
|
|
'slug' => 'patient_tracker_execution_enzuta_40mg_units',
|
|
'pseudoId' => 'patient_tracker_execution_enzuta_40mg_values',
|
|
'total_slug' => 'patient_tracker_execution_enzuta_40mg_total_units',
|
|
'total_slug_value' => 'patient_tracker_execution_enzuta_40mg_total_values',
|
|
],
|
|
];
|
|
|
|
$weeks = [1, 2, 3, 4];
|
|
@endphp
|
|
|
|
@php
|
|
usort($history->data->submissions, function ($a, $b) {
|
|
$dateA = isset($a->formdata->plan_date)
|
|
? \Carbon\Carbon::createFromFormat('Y-m-d', $a->formdata->plan_date)->timestamp
|
|
: 0;
|
|
$dateB = isset($b->formdata->plan_date)
|
|
? \Carbon\Carbon::createFromFormat('Y-m-d', $b->formdata->plan_date)->timestamp
|
|
: 0;
|
|
return $dateB <=> $dateA; // descending
|
|
});
|
|
@endphp
|
|
|
|
<div class="col-md-12" id="table-wrapper">
|
|
<div class="card">
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table
|
|
class="table table-striped table-hover table-nowrap table-centered m-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
<th>Execution Done</th>
|
|
<th>Plan Date</th>
|
|
<th>Execution Date</th>
|
|
<th>Institute Name</th>
|
|
<th>City</th>
|
|
|
|
{{-- <th>Planned Values for the week selected</th>
|
|
|
|
<th>Actual Values for the week selected</th> --}}
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($history->data->submissions as $sub)
|
|
@php
|
|
$sub->formdata->id = $sub->id;
|
|
@endphp
|
|
<tr>
|
|
<td>{{ $sub->workflow_status }}</td>
|
|
<td>
|
|
@if ($sub->workflow_status == 'approved')
|
|
<button type="button"
|
|
class="btn btn-xs btn-info edit-btn"
|
|
plan_details="{{ json_encode($sub->formdata) }}">
|
|
<i class="mdi mdi-pencil"></i> Execute
|
|
</button>
|
|
{{-- @elseif (
|
|
$sub->workflow_status == 'approved' ||
|
|
$sub->workflow_status == 'unapproved' ||
|
|
!empty($sub->formdata->patient_tracker_execution_date)) --}}
|
|
@elseif ($sub->workflow_status == 'rejected')
|
|
<button type="button"
|
|
class="btn btn-xs btn-info edit-plan-btn"
|
|
plan_details="{{ json_encode($sub->formdata) }}">
|
|
<i class="mdi mdi-pencil"></i> Edit Plan
|
|
</button>
|
|
@endif
|
|
|
|
</td>
|
|
<td>{{ isset($sub->formdata->patient_tracker_execution_date) && $sub->formdata->patient_tracker_execution_date > 0 ? 'Yes' : 'No' }}
|
|
</td>
|
|
<td>{{ $sub->formdata->plan_date }}</td>
|
|
<td>{{ isset($sub->formdata->patient_tracker_execution_date) ? $sub->formdata->patient_tracker_execution_date : '' }}
|
|
</td>
|
|
<td>{{ isset($sub->formdata->hospital_name) ? $sub->formdata->hospital_name : '' }}
|
|
</td>
|
|
<td>{{ isset($sub->formdata->city) ? $sub->formdata->city : '' }}
|
|
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="form-wrapper">
|
|
<form method="POST" action="/form/submit" id="report-form">
|
|
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
|
|
|
@csrf
|
|
@foreach ($questions as $question)
|
|
@if (in_array($question->code, ['execution_date', 'exe_values_for_the_week_selected']))
|
|
@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')
|
|
@if ($question->code == 'contact_id')
|
|
<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 ($option->contact->type == 'doctor')
|
|
<option value="{{ $option->value }}"
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
|
uid="{{ isset($option->contact->uid) ? $option->contact->uid : '' }}"
|
|
speciality="{{ isset($option->contact->speciality) ? $option->contact->speciality : '' }}">
|
|
{{ $option->display }}
|
|
</option>
|
|
@endif
|
|
@endforeach
|
|
</select>
|
|
@elseif($question->code == 'hospital_name')
|
|
<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 (isset($option->contact->type) && $option->contact->type == 'hospital')
|
|
<option value="{{ $option->value }}" {{-- dd={{print_r($option)}} --}}
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
|
city="{{ isset($option->contact->city) ? $option->contact->city : '' }}">
|
|
{{ $option->display }}</option>
|
|
@endif
|
|
@endforeach
|
|
</select>
|
|
@else
|
|
<select class="form-control" id="field-{{ $question->code }}"
|
|
name="{{ $question->code }}"
|
|
{{ $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 }}[]" 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('multitextbox')
|
|
<div class="row">
|
|
<div
|
|
style="width: auto; overflow-y: auto; overflow-x: auto; border: 1px solid #0d6efd; border-radius: 3px; padding: 10px; margin-bottom: 10px;">
|
|
<table class="table tableclass">
|
|
<thead id="heading">
|
|
<tr>
|
|
<th>Brand Name</th>
|
|
@foreach ($weeks as $week)
|
|
<th class="text-center">W{{ $week }}
|
|
New Patient Planned*</th>
|
|
{{-- <th class="text-center">W{{ $week }}
|
|
Patient
|
|
Planned
|
|
Value</th> --}}
|
|
@endforeach
|
|
<th>Total Week New Patient Planned</th>
|
|
{{-- <th>Total Week Patient Planned Values</th> --}}
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($plannedBrandData as $brand)
|
|
<tr>
|
|
|
|
<td>{{ $brand['brand'] }}</td>
|
|
@foreach ($weeks as $week)
|
|
<td>
|
|
<input type="number"
|
|
id="field-{{ $brand['slug'] }}_w{{ $week }}"
|
|
name="{{ $brand['slug'] }}_w{{ $week }}"
|
|
class="form-control form-control-large"
|
|
style="width:73px;"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['slug']}) ? $formdata->{$brand['slug']} : 0 }}"
|
|
required min="0">
|
|
</td>
|
|
{{-- <td>
|
|
<input type="number"
|
|
id="field-{{ $brand['pseudoId'] }}_w{{ $week }}"
|
|
name="{{ $brand['pseudoId'] }}_w{{ $week }}"
|
|
class="form-control form-control-large"
|
|
style="width:100px;"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['pseudoId']}) ? $formdata->{$brand['pseudoId']} : 0 }}"
|
|
required>
|
|
</td> --}}
|
|
@endforeach
|
|
<td class="text-center fw-bold total-cell"
|
|
id="total-{{ $brand['slug'] }}">
|
|
<input type="number"
|
|
id="field-{{ $brand['total_slug'] }}"
|
|
name="{{ $brand['total_slug'] }}"
|
|
class="form-control form-control-large"
|
|
style="width:100px;"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['total_slug']}) ? $formdata->{$brand['total_slug']} : 0 }}"
|
|
required>
|
|
</td>
|
|
{{-- <td class="text-center fw-bold total-cell"
|
|
id="total-{{ $brand['slug'] }}">
|
|
<input type="number"
|
|
id="field-{{ $brand['total_slug_value'] }}"
|
|
name="{{ $brand['total_slug_value'] }}"
|
|
class="form-control form-control-large"
|
|
style="width:100px;"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['total_slug_value']}) ? $formdata->{$brand['total_slug_value']} : 0 }}"
|
|
required>
|
|
</td> --}}
|
|
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
@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>
|
|
|
|
|
|
<div id="execution-form-wrapper">
|
|
<form method="POST" action="/form/submit" id="execution-form"
|
|
enctype="multipart/form-data">
|
|
<input type="hidden" name="form_id" value="{{ $form_id }}">
|
|
|
|
<input type="hidden" id="field-proxy_submission_id" name="proxy_submission_id" value="">
|
|
<input type="hidden" id="field-is_edit" name="is_edit" value="">
|
|
|
|
@csrf
|
|
<input type="hidden" name="id" value="" id="execution-id">
|
|
@foreach ($questions as $question)
|
|
<div class="col-md-12 mb-2">
|
|
<label for="execution-{{ $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="execution-{{ $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="execution-{{ $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="execution-{{ $question->code }}"
|
|
name="{{ $question->code }}" class="form-control"
|
|
{{ $question->required == 'yes' ? 'required' : '' }}
|
|
value="{{ isset($question->value) ? $question->value : 0 }}">
|
|
@break
|
|
|
|
@case('textarea')
|
|
<textarea id="execution-{{ $question->code }}" name="{{ $question->code }}" 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="execution-{{ $question->code }}"
|
|
name="{{ $question->code }}"
|
|
{{ $question->required == 'yes' ? 'required' : '' }}>
|
|
<option value=""> -- Select -- </option>
|
|
@foreach ($question->options as $option)
|
|
@if ($option->contact->type == 'doctor')
|
|
<option value="{{ $option->value }}"
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
|
uid="{{ isset($option->contact->uid) ? $option->contact->uid : '' }}"
|
|
speciality="{{ isset($option->contact->speciality) ? $option->contact->speciality : '' }}">
|
|
{{ $option->display }}
|
|
</option>
|
|
@endif
|
|
@endforeach
|
|
</select>
|
|
@elseif($question->code == 'hospital_name')
|
|
<select class="form-control" id="execution-{{ $question->code }}"
|
|
name="{{ $question->code }}"
|
|
{{ $question->required == 'yes' ? 'required' : '' }}>
|
|
<option value=""> -- Select -- </option>
|
|
@foreach ($question->options as $option)
|
|
@if (isset($option->contact->type) && $option->contact->type == 'hospital')
|
|
<option value="{{ $option->value }}"
|
|
{{-- dd={{print_r($option)}} --}}
|
|
{{ isset($question->value) && $question->value == $option->value ? 'selected' : '' }}
|
|
city="{{ isset($option->contact->city) ? $option->contact->city : '' }}">
|
|
{{ $option->display }}</option>
|
|
@endif
|
|
@endforeach
|
|
</select>
|
|
@else
|
|
<select class="form-control" id="execution-{{ $question->code }}"
|
|
name="{{ $question->code }}"
|
|
{{ $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="execution-{{ $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="execution-{{ $question->code }}-{{ $option->value }}">{{ $option->display }}</label>
|
|
</div>
|
|
@endforeach
|
|
@break
|
|
|
|
@case('file')
|
|
<input type="file" id="execution-{{ $question->code }}"
|
|
name="{{ $question->code }}" class="form-control" value=""
|
|
accept="image/jpg, image/jpeg, image/png">
|
|
@break
|
|
|
|
@case('multitextbox')
|
|
{{-- @php echo "<pre>"; print_r($question->code); @endphp --}}
|
|
@if ($question->code == 'values_for_the_week_selected')
|
|
<div class="row">
|
|
<div
|
|
style="width: auto; overflow-y: auto; overflow-x: auto; border: 1px solid #0d6efd; border-radius: 3px; padding: 10px; margin-bottom: 10px;">
|
|
<table class="table tableclass">
|
|
<thead id="heading">
|
|
<tr>
|
|
<th>Brand Name</th>
|
|
@foreach ($weeks as $week)
|
|
<th class="text-center">W{{ $week }}
|
|
New Patient Planned*</th>
|
|
{{-- <th class="text-center">W{{ $week }}
|
|
Patient
|
|
Planned
|
|
Value</th> --}}
|
|
@endforeach
|
|
<th>Total Week New Patient Planned</th>
|
|
{{-- <th>Total Week Patient Planned Values</th> --}}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($plannedBrandData as $brand)
|
|
<tr>
|
|
|
|
<td>{{ $brand['brand'] }}</td>
|
|
@foreach ($weeks as $week)
|
|
<td>
|
|
<input type="number"
|
|
id="execution-{{ $brand['slug'] }}_w{{ $week }}"
|
|
name="{{ $brand['slug'] }}_w{{ $week }}"
|
|
class="form-control form-control-large"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['slug']}) ? $formdata->{$brand['slug']} : 0 }}"
|
|
style="width:73px;" required
|
|
min="0">
|
|
</td>
|
|
{{-- <td>
|
|
<input type="number"
|
|
id="execution-{{ $brand['pseudoId'] }}_w{{ $week }}"
|
|
name="{{ $brand['pseudoId'] }}_w{{ $week }}"
|
|
class="form-control form-control-large"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['pseudoId']}) ? $formdata->{$brand['pseudoId']} : 0 }}"
|
|
style="width:100px;" required
|
|
min="1">
|
|
</td> --}}
|
|
@endforeach
|
|
<td class="text-center fw-bold total-cell"
|
|
id="total-{{ $brand['total_slug'] }}">
|
|
<input type="number"
|
|
id="execution-{{ $brand['total_slug'] }}"
|
|
name="{{ $brand['total_slug'] }}"
|
|
class="form-control form-control-large"
|
|
style="width:100px;"
|
|
test="{{ isset($formdata) ? print_r($formdata) : '' }}"
|
|
value="{{ isset($formdata) && isset($formdata->patient_tracker_planned_encicarb_1k_total_units) ? $formdata->patient_tracker_planned_encicarb_1k_total_units : 0 }}"
|
|
required>
|
|
</td>
|
|
{{-- <td class="text-center fw-bold total-cell"
|
|
id="total-{{ $brand['total_slug'] }}">
|
|
<input type="number"
|
|
id="execution-{{ $brand['total_slug_value'] }}"
|
|
name="{{ $brand['total_slug_value'] }}"
|
|
class="form-control form-control-large"
|
|
style="width:100px;"
|
|
value="{{ isset($formdata) && isset($formdata->patient_tracker_planned_encicarb_1k_total_values) ? $formdata->patient_tracker_planned_encicarb_1k_total_values : 0 }}"
|
|
required>
|
|
</td> --}}
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
@elseif($question->code == 'exe_values_for_the_week_selected')
|
|
<div class="row" id="execution-row">
|
|
<div
|
|
style="width: auto; overflow-y: auto; overflow-x: auto; border: 1px solid #0d6efd; border-radius: 3px; padding: 10px; margin-bottom: 10px;">
|
|
<table class="table tableclass">
|
|
<thead id="heading">
|
|
<tr>
|
|
<th>Brand Name</th>
|
|
@foreach ($weeks as $week)
|
|
<th class="text-center">W{{ $week }}
|
|
Actual New Patient*</th>
|
|
{{-- <th class="text-center">W{{ $week }}
|
|
Actual
|
|
Patient
|
|
Value</th> --}}
|
|
@endforeach
|
|
<th>Total Week Actual New Patient</th>
|
|
{{-- <th>Total Week Actual Patient Values</th> --}}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($executionBrandData as $brand)
|
|
<tr>
|
|
<td>{{ $brand['brand'] }}</td>
|
|
@foreach ($weeks as $week)
|
|
<td>
|
|
<input type="number"
|
|
id="execution-{{ $brand['slug'] }}_w{{ $week }}"
|
|
name="{{ $brand['slug'] }}_w{{ $week }}"
|
|
class="form-control form-control-large"
|
|
style="width:73px;"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['slug']}) ? $formdata->{$brand['slug']} : 0 }}"
|
|
required min="0">
|
|
</td>
|
|
{{-- <td>
|
|
<input type="number"
|
|
id="execution-{{ $brand['pseudoId'] }}_w{{ $week }}"
|
|
name="{{ $brand['pseudoId'] }}_w{{ $week }}"
|
|
class="form-control form-control-large"
|
|
style="width:100px;"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['pseudoId']}) ? $formdata->{$brand['pseudoId']} : 0 }}"
|
|
required>
|
|
</td> --}}
|
|
@endforeach
|
|
<td class="text-center fw-bold total-cell"
|
|
id="total-{{ $brand['slug'] }}">
|
|
<input type="number"
|
|
id="execution-{{ $brand['total_slug'] }}"
|
|
name="{{ $brand['total_slug'] }}"
|
|
class="form-control form-control-large"
|
|
style="width:100px;"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['total_slug']}) ? $formdata->{$brand['total_slug']} : 0 }}"
|
|
required>
|
|
</td>
|
|
{{-- <td class="text-center fw-bold total-cell"
|
|
id="total-{{ $brand['slug'] }}">
|
|
<input type="number"
|
|
id="execution-{{ $brand['total_slug_value'] }}"
|
|
name="{{ $brand['total_slug_value'] }}"
|
|
class="form-control form-control-large"
|
|
style="width:100px;"
|
|
value="{{ $id && isset($formdata) && isset($formdata->{$brand['total_slug_value']}) ? $formdata->{$brand['total_slug_value']} : 0 }}"
|
|
required>
|
|
</td> --}}
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
@endif
|
|
@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>
|
|
|
|
|
|
</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 type="text/javascript">
|
|
$('#form-wrapper').hide()
|
|
$('#execution-form-wrapper').hide()
|
|
$('[id*="_values_w"]').prop('readonly', true);
|
|
|
|
$('#field-uid').prop("readonly", true);
|
|
$('#field-speciality').prop("readonly", true);
|
|
|
|
$('#field-plan_date').on('change', function() {
|
|
let dateVal = $(this).val();
|
|
if (dateVal) {
|
|
let dateObj = new Date(dateVal);
|
|
let monthName = dateObj.toLocaleString('default', {
|
|
month: 'long'
|
|
});
|
|
let year = dateObj.getFullYear();
|
|
|
|
$('#field-month').val(monthName);
|
|
} else {
|
|
$('#field-month').val('');
|
|
}
|
|
});
|
|
|
|
$('#field-contact_id').change(function() {
|
|
$('#field-uid').val($('option:selected', this).attr('uid'))
|
|
});
|
|
|
|
$('#field-contact_id').change(function() {
|
|
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
|
});
|
|
|
|
|
|
|
|
const disableplanbrands = ['patient_tracker_planned_encicarb_1k_units', 'patient_tracker_planned_embremma_units',
|
|
'patient_tracker_planned_somalinx_lar_units', 'patient_tracker_planned_enzuta_40_units'
|
|
];
|
|
disableplanbrands.forEach(function(brand) {
|
|
$(`#field-${brand}_w1, #field-${brand}_w2, #field-${brand}_w3, #field-${brand}_w4`).on('input',
|
|
function() {
|
|
$(`#total-${brand} #field-patient_tracker_planned_total_units`).prop('readonly', true);
|
|
});
|
|
});
|
|
|
|
const disableexebrands = ['patient_tracker_execution_encicarb_1k_units', 'patient_tracker_execution_embremma_units',
|
|
'patient_tracker_execution_somalinx_lar_units', 'patient_tracker_execution_enzuta_40_units'
|
|
];
|
|
disableexebrands.forEach(function(brand) {
|
|
$(`#execution-${brand}_w1, #execution-${brand}_w2, #execution-${brand}_w3, #execution-${brand}_w4`).on(
|
|
'input',
|
|
function() {
|
|
$(`#total-${brand} #execution-patient_tracker_execution_total_units`).prop('readonly',
|
|
true);
|
|
});
|
|
});
|
|
|
|
const baseValues = {
|
|
encicarb_1k: 2140,
|
|
embremma: 7000,
|
|
somalinx_lar: 9350,
|
|
enzuta_40mg: 10800
|
|
};
|
|
|
|
$(document).ready(function() {
|
|
$('label[for="field-values_for_the_week_selected"]').hide();
|
|
$('label[for="execution-values_for_the_week_selected"]').hide();
|
|
});
|
|
|
|
|
|
$('#add-camp-btn').click(function() {
|
|
$('#form-wrapper').show()
|
|
$('#table-wrapper').hide()
|
|
$('#execution-form-wrapper').hide()
|
|
$('#field-other_activity').closest('.col-md-12').hide();
|
|
|
|
$('#field-uid').prop("readonly", true);
|
|
$('#field-speciality').prop("readonly", true);
|
|
$('#field-city').prop("readonly", true);
|
|
|
|
|
|
$('#field-plan_date').on('change', function() {
|
|
let dateVal = $(this).val();
|
|
if (dateVal) {
|
|
let dateObj = new Date(dateVal);
|
|
let monthName = dateObj.toLocaleString('default', {
|
|
month: 'long'
|
|
});
|
|
let year = dateObj.getFullYear();
|
|
|
|
$('#field-month').val(monthName);
|
|
} else {
|
|
$('#field-month').val('');
|
|
}
|
|
});
|
|
|
|
$('#field-contact_id').change(function() {
|
|
$('#field-uid').val($('option:selected', this).attr('uid'))
|
|
});
|
|
|
|
$('#field-contact_id').change(function() {
|
|
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
|
});
|
|
|
|
$('#field-hospital_name').change(function() {
|
|
$('#field-city').val($('option:selected', this).attr('city'))
|
|
});
|
|
|
|
const brands = [
|
|
'patient_tracker_planned_encicarb_1k_units',
|
|
'patient_tracker_planned_embremma_units',
|
|
'patient_tracker_planned_somalinx_lar_units',
|
|
'patient_tracker_planned_enzuta_40mg_units'
|
|
];
|
|
|
|
brands.forEach(function(brand) {
|
|
$(`#field-${brand}_w1, #field-${brand}_w2, #field-${brand}_w3, #field-${brand}_w4`).on(
|
|
'input',
|
|
function() {
|
|
let total = 0;
|
|
for (let i = 1; i <= 4; i++) {
|
|
total += parseFloat($(`#field-${brand}_w${i}`).val()) || 0;
|
|
}
|
|
$(`#total-${brand} #field-patient_tracker_planned_total_units`).val(total);
|
|
});
|
|
});
|
|
|
|
$('input[id*="_units_w"]').on('input', function() {
|
|
const id = $(this).attr('id');
|
|
const brand = id.split('_units_')[0].replace('field-patient_tracker_planned_', '');
|
|
const week = id.split('_units_')[1];
|
|
const units = parseFloat($(this).val()) || 0;
|
|
|
|
const valueField1 = $(`#field-patient_tracker_planned_${brand}_values_${week}`);
|
|
const valueField2 = $(`#field-patient_tracker_planned_${brand}_units_values_${week}`);
|
|
if (baseValues[brand]) {
|
|
const calc = units * baseValues[brand];
|
|
if (valueField1.length) {
|
|
valueField1.val(calc);
|
|
} else if (valueField2.length) {
|
|
valueField2.val(calc);
|
|
}
|
|
}
|
|
|
|
let totalUnits = 0;
|
|
let totalValues = 0;
|
|
|
|
for (let i = 1; i <= 4; i++) {
|
|
const unitVal = parseFloat($(`#field-patient_tracker_planned_${brand}_units_w${i}`)
|
|
.val()) || 0;
|
|
const valueVal = parseFloat($(`#field-patient_tracker_planned_${brand}_values_w${i}`)
|
|
.val()) || 0;
|
|
totalUnits += unitVal;
|
|
totalValues += valueVal;
|
|
}
|
|
|
|
const totalUnitsField = $(`#field-patient_tracker_planned_${brand}_total_units`);
|
|
const totalValuesField = $(`#field-patient_tracker_planned_${brand}_total_values`);
|
|
|
|
if (totalUnitsField.length) totalUnitsField.val(totalUnits);
|
|
if (totalValuesField.length) totalValuesField.val(totalValues);
|
|
});
|
|
|
|
$('input[id*="_total_units"], input[id*="_total_values"]').prop('readonly', true);
|
|
|
|
});
|
|
|
|
$('.edit-btn').click(function() {
|
|
|
|
$('#execution-plan_date, #execution-month, #execution-patient_tracker_planned_brand_1_units, #execution-patient_tracker_planned_brand_2_units, #execution-patient_tracker_planned_brand_3_units, #execution-patient_tracker_planned_brand_4_units, #execution-patient_tracker_planned_brand_1_values, #execution-patient_tracker_planned_brand_2_values, #execution-patient_tracker_planned_brand_3_values, #execution-patient_tracker_planned_brand_4_values, #execution-city')
|
|
.prop('readonly', true);
|
|
|
|
$('#execution-uid').prop("readonly", true);
|
|
$('#execution-speciality').prop("readonly", true);
|
|
|
|
$('#execution-contact_id, #execution-hospital_name, #execution-record_week')
|
|
.on('mousedown keydown', function(e) {
|
|
e.preventDefault();
|
|
});
|
|
|
|
$('input[id^="execution-patient_tracker_planned_"]').prop('readonly', true);
|
|
|
|
let selected = JSON.parse($(this).attr('plan_details'))
|
|
for (let k of Object.keys(selected)) {
|
|
if (selected[k] != '') {
|
|
$('#execution-' + k).val(selected[k]);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
let is_edit = (selected.hasOwnProperty('proxy_submission_id') && selected['proxy_submission_id'] !== '') ? 'yes' : 'no';
|
|
$('#field-is_edit').val(is_edit);
|
|
|
|
if(is_edit == 'yes'){
|
|
$('#field-proxy_submission_id').val(selected['proxy_submission_id']);
|
|
}
|
|
|
|
|
|
console.log(is_edit)
|
|
|
|
let instid = $('#execution-hospital_name option').map(function() {
|
|
if ($(this).text().trim() == selected['hospital_name']) return this;
|
|
}).attr('value')
|
|
|
|
$('#execution-hospital_name').val(instid)
|
|
|
|
let docid = $('#execution-contact_id option').map(function() {
|
|
if ($(this).text().trim() == selected['contact_id']) return this;
|
|
}).attr('value')
|
|
|
|
$('#execution-contact_id').val(docid)
|
|
$('#execution-id').val(selected['id'])
|
|
$('#form-wrapper').hide()
|
|
$('#execution-form-wrapper').show()
|
|
$('#table-wrapper').hide()
|
|
|
|
$('input[id*="_units_w"]').on('input', function() {
|
|
const id = $(this).attr('id');
|
|
const brand = id.split('_units_')[0].replace('execution-patient_tracker_execution_', '');
|
|
const week = id.split('_units_')[1];
|
|
const units = parseFloat($(this).val()) || 0;
|
|
const valueField1 = $(`#execution-patient_tracker_execution_${brand}_values_${week}`);
|
|
const valueField2 = $(`#execution-patient_tracker_execution_${brand}_units_values_${week}`);
|
|
|
|
if (baseValues[brand]) {
|
|
const calc = units * baseValues[brand];
|
|
console.log(`→ calculated: ${calc}`);
|
|
|
|
if (valueField1.length) {
|
|
valueField1.val(calc);
|
|
} else if (valueField2.length) {
|
|
|
|
valueField2.val(calc);
|
|
} else {
|
|
console.warn("⚠ No matching value field found for:", brand, week);
|
|
}
|
|
} else {
|
|
console.warn("⚠ No base value found for brand:", brand);
|
|
}
|
|
});
|
|
|
|
$('input[id*="_units_w"]').on('input', function() {
|
|
const id = $(this).attr('id');
|
|
const brand = id.split('_units_')[0].replace('execution-patient_tracker_execution_', '');
|
|
const week = id.split('_units_')[1];
|
|
const units = parseFloat($(this).val()) || 0;
|
|
|
|
const valueField1 = $(`#execution-patient_tracker_execution_${brand}_values_${week}`);
|
|
const valueField2 = $(`#execution-patient_tracker_execution_${brand}_units_values_${week}`);
|
|
if (baseValues[brand]) {
|
|
const calc = units * baseValues[brand];
|
|
if (valueField1.length) {
|
|
valueField1.val(calc);
|
|
} else if (valueField2.length) {
|
|
valueField2.val(calc);
|
|
}
|
|
}
|
|
|
|
let totalUnits = 0;
|
|
let totalValues = 0;
|
|
|
|
for (let i = 1; i <= 4; i++) {
|
|
const unitVal = parseFloat($(
|
|
`#execution-patient_tracker_execution_${brand}_units_w${i}`).val()) || 0;
|
|
const valueVal = parseFloat($(
|
|
`#execution-patient_tracker_execution_${brand}_values_w${i}`).val()) || 0;
|
|
totalUnits += unitVal;
|
|
totalValues += valueVal;
|
|
}
|
|
|
|
const totalUnitsField = $(`#execution-patient_tracker_execution_${brand}_total_units`);
|
|
const totalValuesField = $(`#execution-patient_tracker_execution_${brand}_total_values`);
|
|
|
|
if (totalUnitsField.length) totalUnitsField.val(totalUnits);
|
|
if (totalValuesField.length) totalValuesField.val(totalValues);
|
|
});
|
|
|
|
$('input[id*="_total_units"], input[id*="_total_values"]').prop('readonly', true);
|
|
})
|
|
|
|
$('.edit-plan-btn').click(function() {
|
|
|
|
|
|
|
|
$('#execution-plan_date').on('change', function() {
|
|
let dateVal = $(this).val();
|
|
if (dateVal) {
|
|
let dateObj = new Date(dateVal);
|
|
let monthName = dateObj.toLocaleString('default', {
|
|
month: 'long'
|
|
});
|
|
let year = dateObj.getFullYear();
|
|
|
|
$('#execution-month').val(monthName);
|
|
} else {
|
|
$('#execution-month').val('');
|
|
}
|
|
});
|
|
|
|
$('#execution-contact_id').change(function() {
|
|
$('#execution-uid').val($('option:selected', this).attr('uid'))
|
|
});
|
|
|
|
$('#execution-contact_id').change(function() {
|
|
$('#execution-speciality').val($('option:selected', this).attr('speciality'))
|
|
});
|
|
|
|
|
|
|
|
$('#execution-hospital_name').change(function() {
|
|
$('#execution-city').val($('option:selected', this).attr('city'))
|
|
});
|
|
|
|
$('#execution-city').prop("readonly", true);
|
|
$('#execution-uid').prop("readonly", true);
|
|
$('#execution-speciality').prop("readonly", true);
|
|
|
|
$('#execution-form-wrapper').show(100, () => {
|
|
$('#add-camp-btn').hide(0);
|
|
})
|
|
|
|
$('#table-wrapper').hide();
|
|
$('#execution-row').prev('label').hide();
|
|
$('#execution-row').hide();
|
|
$('#execution-execution_date').hide();
|
|
$('#execution-execution_date').prev('label').hide();
|
|
$('#execution-execution_date').prop("required", false);
|
|
|
|
let selected = JSON.parse($(this).attr('plan_details'));
|
|
if (selected['contact_id']) {
|
|
selected['contact_id'] = selected['contact_id'].trim();
|
|
}
|
|
|
|
if (selected['activity'] === 'OTHERS') {
|
|
console.log(selected['activity'])
|
|
$('#execution-other_activity').parent().show();
|
|
$('#execution-other_activity').attr("required", true);
|
|
} else {
|
|
$('#execution-other_activity').parent().hide();
|
|
$('#execution-other_activity').attr("required", false);
|
|
}
|
|
|
|
for (let k of Object.keys(selected)) {
|
|
if (selected[k] != '') {
|
|
if (k == 'contact_id') {
|
|
$('#execution-contact_id').val($("#execution-contact_id option:contains(" +
|
|
selected[k] + ")").attr('value'));
|
|
} else if (k == 'hospital_name') {
|
|
let instid = $('#execution-hospital_name option').filter(function() {
|
|
return $(this).text().trim() === selected[k];
|
|
}).val();
|
|
console.log("selected['hospital_name']", selected[k]);
|
|
console.log('instid', instid);
|
|
$('#execution-hospital_name').val(instid);
|
|
} else {
|
|
$('#execution-' + k).val(selected[k]);
|
|
}
|
|
}
|
|
}
|
|
|
|
let docid = $('#execution-contact_id option').map(function() {
|
|
if ($(this).text().trim() == selected['contact_id']) return this;
|
|
}).attr('value')
|
|
|
|
$('#execution-contact_id').val(docid)
|
|
$('#execution-id').val(selected['id'])
|
|
|
|
let is_edit = (selected.hasOwnProperty('proxy_submission_id') && selected['proxy_submission_id'] !== '') ? 'yes' : 'no';
|
|
$('#field-is_edit').val(is_edit);
|
|
|
|
if(is_edit == 'yes'){
|
|
$('#field-proxy_submission_id').val(selected['proxy_submission_id']);
|
|
}
|
|
|
|
$('input[id*="_units_w"]').on('input', function() {
|
|
const id = $(this).attr('id');
|
|
const brand = id.split('_units_')[0].replace('execution-patient_tracker_planned_', '');
|
|
const week = id.split('_units_')[1];
|
|
const units = parseFloat($(this).val()) || 0;
|
|
const valueField1 = $(`#execution-patient_tracker_planned_${brand}_values_${week}`);
|
|
const valueField2 = $(`#execution-patient_tracker_planned_${brand}_units_values_${week}`);
|
|
if (baseValues[brand]) {
|
|
const calc = units * baseValues[brand];
|
|
if (valueField1.length) {
|
|
valueField1.val(calc);
|
|
} else if (valueField2.length) {
|
|
valueField2.val(calc);
|
|
} else {
|
|
console.log("⚠ No matching value field found for:", brand, week);
|
|
}
|
|
} else {
|
|
console.log("⚠ No base value found for brand:", brand);
|
|
}
|
|
});
|
|
|
|
$('input[id*="_units_w"]').on('input', function() {
|
|
const id = $(this).attr('id');
|
|
const brand = id.split('_units_')[0].replace('execution-patient_tracker_planned_', '');
|
|
const week = id.split('_units_')[1];
|
|
const units = parseFloat($(this).val()) || 0;
|
|
|
|
const valueField1 = $(`#execution-patient_tracker_planned_${brand}_values_${week}`);
|
|
const valueField2 = $(`#execution-patient_tracker_planned_${brand}_units_values_${week}`);
|
|
if (baseValues[brand]) {
|
|
const calc = units * baseValues[brand];
|
|
if (valueField1.length) {
|
|
valueField1.val(calc);
|
|
} else if (valueField2.length) {
|
|
valueField2.val(calc);
|
|
}
|
|
}
|
|
|
|
let totalUnits = 0;
|
|
let totalValues = 0;
|
|
|
|
for (let i = 1; i <= 4; i++) {
|
|
const unitVal = parseFloat($(`#execution-patient_tracker_planned_${brand}_units_w${i}`)
|
|
.val()) || 0;
|
|
const valueVal = parseFloat($(
|
|
`#execution-patient_tracker_planned_${brand}_values_w${i}`).val()) || 0;
|
|
totalUnits += unitVal;
|
|
totalValues += valueVal;
|
|
}
|
|
|
|
const totalUnitsField = $(`#execution-patient_tracker_planned_${brand}_total_units`);
|
|
const totalValuesField = $(`#execution-patient_tracker_planned_${brand}_total_values`);
|
|
|
|
if (totalUnitsField.length) totalUnitsField.val(totalUnits);
|
|
if (totalValuesField.length) totalValuesField.val(totalValues);
|
|
});
|
|
|
|
$('input[id*="_total_units"], input[id*="_total_values"]').prop('readonly', true);
|
|
})
|
|
|
|
|
|
function validateWeeklyInputs() {
|
|
console.log('validateWeeklyInputs')
|
|
const brands = [
|
|
'embremma',
|
|
'somalinx_lar',
|
|
'enzuta_40mg'
|
|
];
|
|
let anyBrandPlanned = false;
|
|
|
|
for (const brand of brands) {
|
|
const weeks = ['w1', 'w2', 'w3', 'w4'];
|
|
const values = weeks.map(week =>
|
|
parseFloat($(`#field-patient_tracker_planned_${brand}_units_${week}`).val()) || 0
|
|
);
|
|
|
|
const hasAnyPlanned = values.some(v => v >= 1);
|
|
const allPlanned = values.every(v => v >= 1);
|
|
|
|
if (hasAnyPlanned) {
|
|
anyBrandPlanned = true;
|
|
|
|
if (!allPlanned) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Incomplete Plan',
|
|
text: `Please enter values for all 4 weeks of ${brand.replace(/_/g, ' ').toUpperCase()}`,
|
|
confirmButtonColor: '#3085d6'
|
|
});
|
|
|
|
const missingWeek = weeks[values.findIndex(v => v < 1)];
|
|
$(`#field-patient_tracker_planned_${brand}_units_${missingWeek}`).focus();
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!anyBrandPlanned) {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'No Data Entered',
|
|
text: 'Please enter planned units for at least one brand before submitting.',
|
|
confirmButtonColor: '#d33'
|
|
});
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
$(document).on('input', 'input[type="number"]', function() {
|
|
this.value = this.value.replace(/\..*$/, '');
|
|
});
|
|
|
|
jQuery(document).ready(function($) {
|
|
|
|
$('#field-month').prop("readonly", true);
|
|
|
|
$('#field-contact_id').change(function() {
|
|
$('#field-speciality').val($('option:selected', this).attr('speciality'))
|
|
})
|
|
|
|
$('#field-contact_id').change(function() {
|
|
$('#field-sbu_code').val($('option:selected', this).attr('sbucode'))
|
|
})
|
|
|
|
|
|
|
|
$('#report-form').on('submit', function(event) {
|
|
event.preventDefault();
|
|
|
|
if (!validateWeeklyInputs()) {
|
|
return false;
|
|
}
|
|
|
|
$("#pageloader").fadeIn();
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/form/ajaxsubmit',
|
|
data: new FormData($('#report-form')[0]),
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(data) {
|
|
$("#pageloader").fadeOut();
|
|
if (data.status == 'success') {
|
|
Swal.fire({
|
|
title: 'Great!',
|
|
text: 'Your data is successfully submitted!',
|
|
icon: 'success'
|
|
})
|
|
window.location.reload();
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: 'Something went wrong, please try again after some time!'
|
|
})
|
|
}
|
|
},
|
|
});
|
|
});
|
|
|
|
$('#execution-form').on('submit', function(event) {
|
|
event.preventDefault();
|
|
$("#pageloader").fadeIn();
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/form/ajaxsubmit',
|
|
data: new FormData($('#execution-form')[0]),
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(data) {
|
|
$("#pageloader").fadeOut();
|
|
if (data.status == 'success') {
|
|
Swal.fire({
|
|
title: 'Great!',
|
|
text: 'Your data is successfully submitted!',
|
|
icon: 'success'
|
|
})
|
|
window.location.reload();
|
|
//$('#report-form').trigger("reset");
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Data not submitted',
|
|
text: 'Something went wrong, please try again after some time!'
|
|
})
|
|
}
|
|
},
|
|
});
|
|
});
|
|
|
|
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 recordDateField = document.getElementById('field-plan_date');
|
|
recordDateField.setAttribute('min', today);
|
|
|
|
var executionDateField = document.getElementById('execution-plan_date');
|
|
executionDateField.setAttribute('min', today);
|
|
|
|
$('.edit-btn').click(function() {
|
|
var executionexeField = document.getElementById('execution-execution_date');
|
|
executionexeField.setAttribute('min', executionDateField.value);
|
|
});
|
|
|
|
executionDateField.addEventListener('change', function() {
|
|
var executionexeField = document.getElementById('execution-record_date');
|
|
executionexeField.setAttribute('min', executionDateField.value);
|
|
});
|
|
|
|
});
|
|
</script>
|