|
@@ -34,6 +34,7 @@ use Illuminate\Support\Facades\Http;
|
|
use PDF;
|
|
use PDF;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use App\Models\AdminPatient;
|
|
use App\Models\AdminPatient;
|
|
|
|
+use App\Models\Survey;
|
|
use App\Models\SupplyOrderView;
|
|
use App\Models\SupplyOrderView;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
|
|
@@ -830,4 +831,56 @@ class AdminController extends Controller
|
|
return view('app.admin.patients-notes-points-filter', compact('records', 'filters'));
|
|
return view('app.admin.patients-notes-points-filter', compact('records', 'filters'));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function surveys(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $entityTypes = Survey::ALLOWED_ENTITIES;
|
|
|
|
+ $surveyFormsPath = resource_path(Survey::FORM_PATH);
|
|
|
|
+ $filesInFolder = File::allFiles($surveyFormsPath);
|
|
|
|
+ $forms = [];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ foreach ($filesInFolder as $path) {
|
|
|
|
+ $file = pathinfo($path);
|
|
|
|
+ $fileName = $file['filename'];
|
|
|
|
+ $internalName = explode('.', $fileName)[0];
|
|
|
|
+ $forms[] = $internalName;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $records = Survey::paginate(5);
|
|
|
|
+ return view('app.admin.surveys.list', compact('forms', 'records', 'entityTypes'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function getEntityRecords(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $term = $request->get('term');
|
|
|
|
+ $type = $request->get('type');
|
|
|
|
+ if(!in_array($type, Survey::ALLOWED_ENTITIES)){
|
|
|
|
+ return $this->fail('Invalid entity type');
|
|
|
|
+ }
|
|
|
|
+ $records = [];
|
|
|
|
+ if($type === 'client'){
|
|
|
|
+ $clients = Client::query();
|
|
|
|
+ $clients = $clients->where('is_active', true);
|
|
|
|
+
|
|
|
|
+ $clients = $clients->where(function ($q) use ($term) {
|
|
|
|
+ $q->orWhereRaw('LOWER(name_first::text) LIKE ?', ['%' . $term . '%'])
|
|
|
|
+ ->orWhereRaw('LOWER(name_last::text) LIKE ?', ['%' . $term . '%'])
|
|
|
|
+ ->orWhereRaw('LOWER(email_address::text) LIKE ?', ['%' . $term . '%'])
|
|
|
|
+ ->orWhereRaw('cell_number LIKE ?', ['%' . $term . '%']);
|
|
|
|
+ });
|
|
|
|
+ $clients = $clients->orderBy('name_first', 'ASC')->limit(10)->get();
|
|
|
|
+ $clientsData = $clients->map(function($client) {
|
|
|
|
+ return [
|
|
|
|
+ "uid" => $client->uid,
|
|
|
|
+ "id" => $client->id,
|
|
|
|
+ "text" => $client->displayName(),
|
|
|
|
+ ];
|
|
|
|
+ });
|
|
|
|
+ return json_encode([
|
|
|
|
+ "results" => $clientsData
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $this->pass($records);
|
|
|
|
+ }
|
|
}
|
|
}
|