-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
618 lines (606 loc) · 40.9 KB
/
index.php
File metadata and controls
618 lines (606 loc) · 40.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<?php
//require_once "DataEntryTriggerBuilder.php";
require_once "DETBuilder.php";
require_once "vendor/autoload.php";
/**
* Display REDCap header.
*/
require_once APP_PATH_DOCROOT . 'ProjectGeneral/header.php';
//$data_entry_trigger_builder = new BCCHR\DataEntryTriggerBuilder\DataEntryTriggerBuilder();
$data_entry_trigger_builder = new BCCHR\DETBuilder\DETBuilder();
if (!empty($_POST["json"])) {
$posted_json = $_POST["json"];
$settings = json_decode($posted_json, true);
if ($settings == null)
{
$import_err_msg = "Invalid JSON! Please check your DET settings.";
}
}
if ($settings == null)
{
$settings = json_decode($data_entry_trigger_builder->getProjectSetting("det_settings"), true);
$dest_fields = $data_entry_trigger_builder->retrieveProjectMetadata($settings["dest-project"]);
}
$data_entry_trigger_builder->loadFieldTypes(); // get field types from the fields listed in the settings
$Proj = new Project();
?>
<html>
<head>
<!-- boostrap-select css and js-->
<!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.18/dist/css/bootstrap-select.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.18/dist/js/bootstrap-select.min.js"></script>
-->
<!--
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.15/dist/css/bootstrap-select.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.15/dist/js/bootstrap-select.min.js"></script>
-->
<style>
p {
max-width: 100%;
}
.fa:hover {
color:grey;
}
.table td, .table th {
padding: .5%;
}
.table-input {
border: none;
background-color: transparent;
}
.table tr > td:first-child,
.table tr > th:first-child {
width: 40% ;
}
.table tr > td:nth-child(2),
.table tr > th:nth-child(2) {
width: 40% ;
}
.table tr > td:nth-child(3),
.table tr > td:nth-child(4),
.table tr > th:nth-child(3),
.table tr > th:nth-child(4) {
width: 10% ;
}
.error {
border: 2px solid red;
}
.error-msg {
color: red
}
.saved {
color: #007bff
}
textarea {
resize: vertical;
}
.ui-autocomplete {
position: absolute;
z-index: 20000 !important;
}
</style>
<!-- Expose CSRF token to JS for Framework v8 POSTs -->
<script>
window.redcap_csrf_token = window.redcap_csrf_token
|| (window.ExternalModules && ExternalModules.CSRF_TOKEN)
|| <?= json_encode($data_entry_trigger_builder->getCSRFToken()); ?>;
</script>
<script src="<?php print $module->getUrl("functions.js");?>" type="text/javascript"></script>
</head>
<body>
<?php if ($Proj->project['status'] > 0 || !empty($settings)): ?>
<div style="position: sticky; top: 0; width: 100%; background-color:#ff9800; padding:5px; text-align:center">
<?php if ($Proj->project['status'] > 0): ?><h6><b>This project is currently in production, be careful with your changes!</b></h6><?php endif; ?>
<?php if (!empty($settings)): ?><h6><b>WARNING: Any changes made to the REDCap project, after the DET has been created, has the potential to break it. After you’ve updated your project, please make sure to update the DET in accordance with your changes.</b></h6><?php endif; ?>
<?php
// if (!empty($settings["dest-project"])) {
// $DestProj = new Project($settings["dest-project"]);
// if ($DestProj->project['status'] > 0) {
// print "<h5><b>The destination project is currently in production.</h5><b>";
// }
// }
?>
</div>
<?php endif; ?>
<div class="container jumbotron">
<h2>Data Entry Trigger Builder</h2>
<p><b>LIMITATIONS*: This module will work will classical and longitudinal projects, but is currently incompatible with repeatable events, and multiple arms.</b></p>
<?php if (!empty($settings)): ?>
<p><b>DET was last changed on <span class="saved"><?php print $data_entry_trigger_builder->getProjectSetting("saved_timestamp");?></span> by <span class="saved"><?php print $data_entry_trigger_builder->getProjectSetting("saved_by");?></span></b></p>
<?php endif; ?>
<hr/>
<h5>Import/Export Your DET Settings</h5>
<p>
If you've created a JSON string containing your DET settings, you may import them into the module, or you may export your current DET settings (If they exist).
When importing settings for projects on a different REDCap instance that have the same structure, change the destination project id before import.
</p>
<p><b>IMPORTANT: Once you've imported your DET settings, you must still save them by clicking "Save DET" at the bottom of the page.</b></p>
<button type="button" data-toggle="modal" data-target="#upload-json-modal" class="btn btn-primary btn-sm">Import DET Settings</button>
<?php if (!empty($settings)): ?><button type="button" data-toggle="modal" data-target="#export-json-modal" class="btn btn-primary btn-sm">Export DET Settings</button><?php endif; ?>
<?php if (!empty($import_err_msg)): ?>
<p style="color:red"><b><?php print $import_err_msg; ?></b></p>
<?php endif;?>
<hr/>
<?php if (!empty($settings)): ?>
<h5>Download Release Notes</h5>
<form id="download-form" action="<?php print $module->getUrl("downloadReleaseNotes.php");?>" method="post">
<button id="download-release-notes-btn" type="submit" class="btn btn-primary" style="margin-top:20px">Download Release Notes</button>
</form>
<hr/>
<?php endif;?>
<form id="det-form" method="post">
<input type="hidden" name="redcap_csrf_token" value="<?php print $data_entry_trigger_builder->getCSRFToken();?>">
<h5>Select a Linked Project</h5>
<!-- PATCHED 2025-05-23 by Dan Evans. Bootstrap 5 change. <div class="form-group"> -->
<!-- here you are. Search and edit form elements to make them bs5 -->
<div class='mb-3'>
<!-- PATCHED 2024-08-21 by Dan Evans. Same issue as CRSURC-569. <select name="dest-project" id="destination-project-select" class="form-control selectpicker" data-live-search="true" required> -->
<select name="dest-project" id="destination-project-select" class="form-select" data-live-search="true" required>
<option value="" disabled <?php if (empty($settings)) { print "selected"; }?>>Select a project</option>
<?php
$projects = $data_entry_trigger_builder->getProjects();
foreach($projects as $project)
{
if ($project["project_id"] != $_GET["pid"]) {
if (!empty($settings["dest-project"]) && $project["project_id"] == $settings["dest-project"])
{
print "<option value='". $project["project_id"] . "' selected>" . $project["project_id"] . " - " . $project["app_title"] . "</option>";
}
else
{
print "<option value='". $project["project_id"] . "'>" . $project["project_id"] . " - " . $project["app_title"] . "</option>";
}
}
}
?>
</select>
<?php
if (!empty($settings["dest-project"])) {
$DestProj = new Project($settings["dest-project"]);
if ($DestProj->project['status'] > 0) {
print "<p><b><i>This project is currently in production.</i></p></b>";
}
}
?>
</div>
<hr>
<div id="main-form" <?php if (empty($settings)) :?> style="display:none" <?php endif;?>>
<h5>Record Linkage</h5>
<p>
Create subjects/push data to linked project using variables in source and linked project.
When at least one of the triggers are met, then records between the source and linked project will be linked via the chosen fields.
</p>
<p><b>IMPORTANT: When linking projects with anything other than the record ID fields, "Auto-numbering for records" must be turned on in the destination project.</b></p>
<div class='row link-field form-group'>
<div class='col-sm-12' style="margin-bottom:10px">
<div class='class-sm-12'><label>Link source project field</label></div>
<div class='row'>
<?php if (REDCap::isLongitudinal()): ?>
<div class='col-sm-6'>
<input id='linkSourceEvent' class="source-events-autocomplete form-control" name='linkSourceEvent' placeholder="Type to search for event" value="<?php print htmlspecialchars($settings["linkSourceEvent"], ENT_QUOTES); ?>" required>
</div>
<?php endif;?>
<div class='col-sm-6'>
<input id='linkSource' class="source-fields-autocomplete form-control" name='linkSource' placeholder="Type to search for field" value="<?php print htmlspecialchars($settings["linkSource"], ENT_QUOTES); ?>" required>
</div>
</div>
</div>
<div class='col-sm-12'>
<div class='class-sm-12' id="link-source-text"><label>To linked project field</label></div>
<div class='row'>
<div class='col-sm-6 dest-event-wrapper' <?php if(empty($settings["linkDestEvent"])) {print "style='display:none'";} ?>>
<!-- removed required attribute from this input for troubleshooting <input id='linkDestEvent' class='dest-events-autocomplete form-control' name='linkDestEvent' placeholder="Type to search for event" value="<?php print htmlspecialchars($settings["linkDestEvent"], ENT_QUOTES); ?>" required> -->
<input id='linkDestEvent' class='dest-events-autocomplete form-control' name='linkDestEvent' placeholder="Type to search for event" value="<?php print htmlspecialchars($settings["linkDestEvent"], ENT_QUOTES); ?>">
</div>
<div id="link-source-wrapper" class='col-sm-6'>
<input id='linkDest' class='dest-fields-autocomplete form-control' name='linkDest' placeholder="Type to search for field" value="<?php print htmlspecialchars($settings["linkDest"], ENT_QUOTES); ?>" required>
</div>
</div>
</div>
</div>
<hr>
<h5>Triggers (Max. 10)</h5>
<div id="trigger-instr" style="margin-bottom:20px">
<label>Push data from the source project to the linked project, when the following conditions are met:</label>
<ul>
<li>E.g., [event_name][instrument_name_complete] = "2"</li>
<li>E.g., [event_name][variable_name] = "1"</li>
</ul>
<p>Where [event_name] = only in longitudinal projects<br/>Where [instrument_name] = form copied from source to linked project<br/>Where [variable_name] = field copied from source to linked project</p>
<p><strong>NOTE:</strong> If [variable_name] is a checkbox field please use the following format: [variable_name<strong>(</strong>code<strong>)</strong>]</p>
<p>
Multiple conditions can be chained in the same trigger using AND/OR. When creating a trigger
<b>AND must be written as &&</b>, and
<b>OR must be written as ||</b>
</p>
<ul>
<li>E.g., [event_name][instrument_name_complete] = "2" && [event_name][variable_name] = "1"</li>
<li>E.g., [event_name][instrument_name_complete] = "2" || [event_name][variable_name] = "1"</li>
</ul>
<p>Remember to add spaces between all your REDCap variables, and logical quantifiers</p>
<p>The following qualifiers are of valid use within the module:</p>
<table border="1" style="margin-bottom:10px">
<colgroup>
<col align="center" class="alternates">
<col class="meaning">
<col class="example">
</colgroup>
<thead><tr>
<th align="center">Qualifier</th>
<th>Syntax Example</th>
<th>Meaning</th>
</tr></thead>
<tbody>
<tr>
<td align="center">=, ==</td>
<td>$a = $b</td>
<td>equals</td>
</tr>
<tr>
<td align="center"><>, !=</td>
<td>$a <> $b</td>
<td>not equals</td>
</tr>
<tr>
<td align="center">></td>
<td>$a > $b</td>
<td>greater than</td>
</tr>
<tr>
<td align="center"><</td>
<td>$a < $b</td>
<td>less than</td>
</tr>
<tr>
<td align="center">>=</td>
<td>$a >= $b</td>
<td>greater than or equal</td>
</tr>
<tr>
<td align="center"><=</td>
<td>$a <= $b</td>
<td>less than or equal</td>
</tr>
</tbody>
</table>
<button type="button" id="add-trigger-btn" class="btn btn-primary btn-sm">Add Trigger</button>
</div>
<?php if (!empty($settings)): foreach($settings["triggers"] as $index => $trigger): ?>
<?php
$index = htmlspecialchars($index, ENT_QUOTES);
$trigger = htmlspecialchars($trigger, ENT_QUOTES);
?>
<div class="form-group trigger-and-data-wrapper">
<div class="det-trigger">
<div class="row">
<div class="col-sm-2">
<label><h6>Trigger:</h6></label>
</div>
<div class="col-sm-9"></div>
<div class="col-sm-1" style="text-align: center;">
<span class="fa fa-trash-alt delete-trigger-btn"></span>
</div>
</div>
<textarea rows="1" name="triggers[]" class="form-control det-trigger-input" required><?php print str_replace("\"", "'", $trigger); ?></textarea>
</div>
<p>
Copy the following instruments/fields from source project to linked project when the above condition is true:
</p>
<button type="button" data-toggle="modal" data-target="#add-field-modal" class="btn btn-primary btn-xs add-field-btn">Add Field</button>
<button type="button" data-toggle="modal" data-target="#add-instr-modal" class="btn btn-primary btn-xs add-instr-btn">Add Instrument</button>
<br/><br/>
<table id="<?php print "table-$index"; ?>" class="table">
<thead>
<tr>
<th>From Source Project</th>
<th>To Linked Project</th>
<th>Edit?</th>
<th>Delete?</th>
</tr>
</thead>
<tbody>
<?php
$pipingSourceEvents = $settings["pipingSourceEvents"][$index];
$pipingDestEvents = $settings["pipingDestEvents"][$index];
$pipingSourceFields = $settings["pipingSourceFields"][$index];
$pipingDestFields = $settings["pipingDestFields"][$index];
foreach($pipingSourceFields as $i => $source)
{
$pipingSourceEvent = htmlspecialchars($pipingSourceEvents[$i], ENT_QUOTES);
$source = htmlspecialchars($source, ENT_QUOTES);
$pipingDestEvent = htmlspecialchars($pipingDestEvents[$i], ENT_QUOTES);
$dest = htmlspecialchars($pipingDestFields[$i], ENT_QUOTES);
print "<tr class='trigger-field-row'><td>";
if (!empty($pipingSourceEvent))
{
print "[" . $pipingSourceEvent . "]";
print "<input class='pipingSourceEvents' type='hidden' name='pipingSourceEvents[$index][]' value='" . $pipingSourceEvent . "'>";
}
print "[" . $source . "]";
print "<input class='pipingSourceFields' type='hidden' name='pipingSourceFields[$index][]' value='" . $source . "'></td><td>";
if (!empty($pipingDestEvents[$i]))
{
//print "[" . $pipingSourceEvent . "]";
print "[" . $pipingDestEvent . "]";
// print "<input class='pipingDestEvents' type='hidden' name='pipingDestEvents[$index][]' value='" . $pipingSourceEvent . "'>";
print "<input class='pipingDestEvents' type='hidden' name='pipingDestEvents[$index][]' value='" . $pipingDestEvent . "'>";
}
print "[" . $dest . "]";
//print "<input class='pipingDestFields' type='hidden' name='pipingDestFields[$index][]' value='" . $pipingSourceEvent . "'>";
// here you are. Fixed display issue of saved destination fields, still not working properly
print "<input class='pipingDestFields' type='hidden' name='pipingDestFields[$index][]' value='" . $dest . "'>";
print "</td><td><span class='fa fa-pencil-alt' onclick='fillPipingFieldForm(this)'></span></td>";
print "<td><span class='fa fa-trash-alt delete-trigger-field'></span></td>";
print "</tr>";
}
$setDestEvents = $settings["setDestEvents"][$index];
$setDestFields = $settings["setDestFields"][$index];
$setDestFieldsValues = $settings["setDestFieldsValues"][$index];
// REDCap::logEvent("DET builder: [debug] dest events", print_r($setDestEvents,true), null, $record, null, $project_id);
// REDCap::logEvent("DET builder: [debug] dest fields", print_r($setDestFields,true), null, $record, null, $project_id);
// REDCap::logEvent("DET builder: [debug] dest field values", print_r($setDestFieldsValues,true), null, $record, null, $project_id);
foreach($setDestFields as $i => $source)
{
$setDestFieldsValue = htmlspecialchars($setDestFieldsValues[$i], ENT_QUOTES);
$setDestEvent = htmlspecialchars($setDestEvents[$i], ENT_QUOTES);
$source = htmlspecialchars($source, ENT_QUOTES);
print "<tr class='trigger-field-row'><td>";
if (!empty($setDestFieldsValue))
{
print "'" . $setDestFieldsValue . "'";
print "<input class='setDestFieldsValues' type='hidden' name='setDestFieldsValues[$index][]' value='" . $setDestFieldsValue . "'></td><td>";
}
if (!empty($setDestEvent))
{
print "[" . $setDestEvent . "]";
print "<input class='setDestEvents' type='hidden' name='setDestEvents[$index][]' value='" . $setDestEvent . "'>";
}
print "[" . $source . "]";
print "<input class='setDestFields' type='hidden' name='setDestFields[$index][]' value='" . $source . "'>";
print "</td><td><span class='fa fa-pencil-alt' onclick='fillFieldForm(this)'></span></td>";
print "<td><span class='fa fa-trash-alt delete-trigger-field'></span></td>";
print "</tr>";
}
// $sourceInstr = $settings["sourceInstr"][$index];
// $sourceInstrEvents = $settings["sourceInstrEvents"][$index];
$sourceInstr = $settings["sourceInstr"][$index];
$sourceInstrEvents = $settings["sourceInstrEvents"][$index];
$instrDestEvents = isset($settings["instrDestEvents"][$index]) ? $settings["instrDestEvents"][$index] : [];
foreach($sourceInstr as $i => $source)
{
$sourceInstrEvent = htmlspecialchars($sourceInstrEvents[$i], ENT_QUOTES);
$source = htmlspecialchars($source, ENT_QUOTES);
$instrDestEvent = !empty($instrDestEvents[$i]) ? htmlspecialchars($instrDestEvents[$i], ENT_QUOTES) : '';
print "<tr class='trigger-field-row'><td>";
if (!empty($sourceInstrEvent))
{
print "[" . $sourceInstrEvent . "]";
print "<input class='sourceInstrEvents' type='hidden' name='sourceInstrEvents[$index][]' value='" . $sourceInstrEvent . "'>";
}
print "[" . $source . "]";
print "<input class='sourceInstr' type='hidden' name='sourceInstr[$index][]' value='" . $source . "'>";
print "</td><td>";
// Use per-row dest event if present; otherwise mirror source event
if (!empty($instrDestEvent)) {
print "[" . $instrDestEvent . "]";
print "<input class='instrDestEvents' type='hidden' name='instrDestEvents[$index][]' value='" . $instrDestEvent . "'>";
} elseif (!empty($sourceInstrEvent)) {
print "[" . $sourceInstrEvent . "]";
}
print "[" . $source . "]";
print "</td><td><span class='fa fa-pencil-alt' onclick='fillInstrForm(this)'></span></td>";
print "<td><span class='fa fa-trash-alt delete-trigger-field'></span></td>";
print "</tr>";
}
?>
</tbody>
</table>
</div>
<?php endforeach; endif;?>
<hr>
<h5>Confirm the following</h5>
<div class="row">
<div class="form-check col-6">
<div class="row"><label>Overwrite data in destination project every time data is saved. This determines<br/>whether to push blank data over to the destination project.</label></div>
<?php if (empty($settings)): ?>
<input type="radio" name="overwrite-data" class="form-check-input" value="overwrite" required><label class="form-check-label">Yes</label>
<br>
<input type="radio" name="overwrite-data" class="form-check-input" value="normal" required><label class="form-check-label">No</label>
<?php else:?>
<?php if ($settings["overwrite-data"] == "overwrite"):?>
<input type="radio" name="overwrite-data" class="form-check-input" value="overwrite" checked required><label class="form-check-label">Yes</label>
<br>
<input type="radio" name="overwrite-data" class="form-check-input" value="normal" required><label class="form-check-label">No</label>
<?php else:?>
<input type="radio" name="overwrite-data" class="form-check-input" value="overwrite" required><label class="form-check-label">Yes</label>
<br>
<input type="radio" name="overwrite-data" class="form-check-input" value="normal" checked required><label class="form-check-label">No</label>
<?php endif; ?>
<?php endif;?>
</div>
<div class="form-check col-6">
<div class="row"><label>Import data access groups (DAGs) every time data is saved. The module can only<br/>import DAGs if they have a one-to-one relationship with the destination project.</label></div>
<?php if (empty($settings)): ?>
<input type="radio" name="import-dags" class="form-check-input" value="1" required><label class="form-check-label">Yes</label>
<br>
<input type="radio" name="import-dags" class="form-check-input" value="0" required><label class="form-check-label">No</label>
<?php else:?>
<?php if ($settings["import-dags"] == "1"):?>
<input type="radio" name="import-dags" class="form-check-input" value="1" checked required><label class="form-check-label">Yes</label>
<br>
<input type="radio" name="import-dags" class="form-check-input" value="0" required><label class="form-check-label">No</label>
<?php else:?>
<input type="radio" name="import-dags" class="form-check-input" value="1" required><label class="form-check-label">Yes</label>
<br>
<input type="radio" name="import-dags" class="form-check-input" value="0" checked required><label class="form-check-label">No</label>
<?php endif; ?>
<?php endif;?>
</div>
</div>
<button id="create-det-btn" type="submit" class="btn btn-primary" style="margin-top:20px">Save DET</button>
</div>
</form>
<div class="modal fade" id="add-field-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5>Add Field</h5>
<!-- replace with bs5
<button type="button" class="close close-modal-btn" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
-->
<button type="button" class="btn-close close-modal-btn" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<input class="table-id" type="hidden">
<div class='row'>
<div class="col-sm-4"><label>Copy from source</label></div>
<div class="col-sm-1">
<!-- bs5 edit <button style="border:none; background-color: transparent" title="Switch to enter custom value, or select field" class="fas fa-exchange-alt"></button> -->
<button type="button" class="btn p-0" title="Switch to enter custom value, or select field">
<i class="fas fa-exchange-alt"></i>
</button>
</div>
</div>
<!-- bs5 update<div id="source-input" class="row ui-front" style="display:none"> -->
<div id="source-input" class="row ui-front d-none">
<div class="col-sm-6">
<input id="field-value" class='form-control' placeholder="Type the value to tranfer">
</div>
</div>
<div id="source-select" class="row">
<?php if (REDCap::isLongitudinal()): ?>
<div class='col-sm-6 ui-front'>
<input class="source-events-autocomplete form-control" id="event-select" placeholder="Type to search for event">
<!-- bs5 upgrade <input id="event-select" class="source-events-autocomplete form-control" placeholder="Type to search for event"> -->
</div>
<?php endif;?>
<div class='col-sm-6 ui-front'>
<input class="source-fields-autocomplete form-control" id="field-select" placeholder="Type to search for field">
</div>
</div>
<br/>
<div class='row'>
<div class="col-sm-5"><label>To destination</label></div>
</div>
<div class='row' style='margin-top:20px'>
<div class='col-sm-6 ui-front dest-event-wrapper'>
<input class='dest-events-autocomplete form-control' id="dest-event-select" placeholder="Type to search for event">
</div>
<div class='col-sm-6 ui-front'>
<input class='dest-fields-autocomplete form-control' id="dest-field-select" placeholder="Type to search for field">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary close-modal-btn" data-dismiss="modal">Close</button>
<button type="button" id="add-field-btn" class="btn btn-primary">Add</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="add-instr-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<input class="table-id" type="hidden">
<div class="modal-header">
<h5>Add Instrument</h5>
<button type="button" class="close close-modal-btn" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class='row'>
<div class="col-sm-12"><label>There must be a one-to-one relationship in the linked project</label></div>
</div>
<div class="row">
<?php if (REDCap::isLongitudinal()): ?>
<div class='col-sm-6 ui-front'>
<input class='source-events-autocomplete form-control' id="instr-event-select" placeholder="Type to search for Source event">
</div>
<?php endif;?>
<div class='col-sm-6 ui-front'>
<input class='source-instr-autocomplete form-control' id="instr-select" placeholder="Type to search for instrument">
</div>
</div>
<!-- Destination event (only used when destination is longitudinal) -->
<div class="row" style="margin-top:20px">
<div class="col-sm-6 ui-front instr-dest-event-wrapper" style="display:none">
<input class="dest-events-autocomplete form-control" id="instr-dest-event-select"
placeholder="Type to search for Destination event">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary close-modal-btn" data-dismiss="modal">Close</button>
<button type="button" id="add-instr-btn" class="btn btn-primary">Add</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="upload-json-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5>Import DET Settings</h5>
<button type="button" class="close close-modal-btn" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form id="upload-json-form" method="post" action="<?php print $module->getUrl("index.php");?>">
<div class="modal-body">
<div class='row'>
<div class="col-sm-12"><label>Please copy-paste your json into the editor below</label></div>
<div id="json-errors-div" class="col-sm-12" style="color:red"></div>
</div>
<div class="row">
<div class="col-sm-12"><textarea id="upload-textarea" rows="4" name="json" style="width:100%" required></textarea></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary close-modal-btn" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Import</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="export-json-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<input class="table-id" type="hidden">
<div class="modal-header">
<h5>Copy DET Settings</h5>
<button type="button" class="close close-modal-btn" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class='row'>
<div class="col-sm-12"><label>Please copy your json below</label></div>
</div>
<div class="row">
<div class="col-sm-12">
<div style="background-color:lightgrey; border: 1px solid black; color:deeppink; padding: 5px">
<?php print htmlspecialchars(json_encode($settings, JSON_PRETTY_PRINT), ENT_QUOTES); ?>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary close-modal-btn" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
require_once "script.php";
/**
* Display REDCap footer.
*/
require_once APP_PATH_DOCROOT . 'ProjectGeneral/footer.php';
?>