Adding reminder for transaction form generation (#5332)
[openemr.git] / interface / super / edit_layout_props.php
blobe7ef1b041ebc17f43ec866a5d74218d85349c768
1 <?php
3 /**
4 * Edit Layout Properties.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2016-2021 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
17 use OpenEMR\Common\Acl\AclMain;
18 use OpenEMR\Common\Csrf\CsrfUtils;
19 use OpenEMR\Core\Header;
20 use OpenEMR\Gacl\GaclApi;
22 $alertmsg = "";
24 // Check authorization.
25 $thisauth = AclMain::aclCheckCore('admin', 'super');
26 if (!$thisauth) {
27 die(xlt('Not authorized'));
30 $layout_id = empty($_GET['layout_id']) ? '' : $_GET['layout_id'];
31 $group_id = empty($_GET['group_id' ]) ? '' : $_GET['group_id' ];
33 <html>
34 <head>
35 <title><?php echo xlt("Edit Layout Properties"); ?></title>
36 <?php Header::setupHeader('opener'); ?>
38 <style>
39 td { font-size:10pt; }
40 </style>
42 <script>
44 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
46 // The name of the input element to receive a found code.
47 var current_sel_name = '';
49 // This invokes the "dynamic" find-code popup.
50 function sel_related(elem, codetype) {
51 current_sel_name = elem ? elem.name : '';
52 var url = '<?php echo $rootdir ?>/patient_file/encounter/find_code_dynamic.php';
53 if (codetype) url += '?codetype=' + encodeURIComponent(codetype);
54 dlgopen(url, '_blank', 800, 500);
57 // This is for callback by the find-code popup.
58 // Appends to or erases the current list of related codes.
59 function set_related(codetype, code, selector, codedesc) {
60 var f = document.forms[0];
61 // frc will be the input element containing the codes.
62 var frc = f[current_sel_name];
63 var s = frc.value;
64 if (code) {
65 if (s.length > 0) {
66 s += ';';
68 s += codetype + ':' + code;
69 } else {
70 s = '';
72 frc.value = s;
73 return '';
76 // This is for callback by the find-code popup.
77 // Deletes the specified codetype:code from the active input element.
78 function del_related(s) {
79 var f = document.forms[0];
80 my_del_related(s, f[current_sel_name], false);
83 // This is for callback by the find-code popup.
84 // Returns the array of currently selected codes with each element in codetype:code format.
85 function get_related() {
86 var f = document.forms[0];
87 if (current_sel_name) {
88 return f[current_sel_name].value.split(';');
90 return new Array();
93 </script>
95 </head>
97 <body class="body_top">
99 <?php
100 if (!empty($_POST['form_submit']) && !$alertmsg) {
101 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
102 CsrfUtils::csrfNotVerified();
105 if ($group_id) {
106 $sets =
107 "grp_subtitle = ?, " .
108 "grp_init_open = ?, " .
109 "grp_columns = ?";
110 $sqlvars = array(
111 $_POST['form_subtitle'],
112 empty($_POST['form_init_open' ]) ? 0 : 1,
113 intval($_POST['form_columns']),
115 } else {
116 $sets =
117 "grp_title = ?, " .
118 "grp_subtitle = ?, " .
119 "grp_mapping = ?, " .
120 "grp_seq = ?, " .
121 "grp_activity = ?, " .
122 "grp_repeats = ?, " .
123 "grp_columns = ?, " .
124 "grp_size = ?, " .
125 "grp_issue_type = ?, " .
126 "grp_aco_spec = ?, " .
127 // "grp_save_close = ?, " .
128 "grp_init_open = ?, " .
129 "grp_referrals = ?, " .
130 "grp_services = ?, " .
131 "grp_products = ?, " .
132 "grp_diags = ?";
133 $sqlvars = array(
134 $_POST['form_title'],
135 $_POST['form_subtitle'],
136 $_POST['form_mapping'],
137 intval($_POST['form_seq']),
138 empty($_POST['form_activity']) ? 0 : 1,
139 intval($_POST['form_repeats']),
140 intval($_POST['form_columns']),
141 intval($_POST['form_size']),
142 $_POST['form_issue'],
143 $_POST['form_aco'],
144 // empty($_POST['form_save_close']) ? 0 : 1,
145 empty($_POST['form_init_open' ]) ? 0 : 1,
146 empty($_POST['form_referrals']) ? 0 : 1,
147 empty($_POST['form_services']) ? '' : (empty($_POST['form_services_codes']) ? '*' : $_POST['form_services_codes']),
148 empty($_POST['form_products']) ? '' : (empty($_POST['form_products_codes']) ? '*' : $_POST['form_products_codes']),
149 empty($_POST['form_diags' ]) ? '' : (empty($_POST['form_diags_codes' ]) ? '*' : $_POST['form_diags_codes' ]),
153 if ($layout_id) {
154 // They have edited an existing layout.
155 $form_title = $_POST['form_title'] ?? '';
156 if ($form_title == '' && !$group_id) {
157 $alertmsg = xl('Title is required');
158 } else {
159 $sqlvars[] = $layout_id;
160 $sqlvars[] = $group_id;
161 sqlStatement(
162 "UPDATE layout_group_properties SET $sets " .
163 "WHERE grp_form_id = ? AND grp_group_id = ?",
164 $sqlvars
167 } elseif (!$group_id) {
168 // They want to add a new layout. New groups not supported here.
169 $form_form_id = $_POST['form_form_id'];
170 $form_title = $_POST['form_title'];
171 if ($form_form_id == '') {
172 $alertmsg = xl('Layout ID is required');
173 } elseif ($form_title == '') {
174 $alertmsg = xl('Title is required');
175 } elseif (preg_match('/(LBF|LBT|HIS)[0-9A-Za-z_]+/', $form_form_id)) {
176 $tmp = sqlQuery(
177 "SELECT grp_form_id FROM layout_group_properties WHERE " .
178 "grp_form_id = ? AND grp_group_id = ''",
179 array($form_form_id)
181 if (empty($row)) {
182 $sqlvars[] = $form_form_id;
183 sqlStatement(
184 "INSERT INTO layout_group_properties " .
185 "SET $sets, grp_form_id = ?, grp_group_id = ''",
186 $sqlvars
188 $layout_id = $form_form_id;
189 } else {
190 $alertmsg = xl('This layout ID already exists');
192 } else {
193 $alertmsg = xl('Invalid layout ID');
197 // Close this window and redisplay the layout editor.
199 echo "<script>\n";
200 if ($alertmsg) {
201 echo " alert(" . js_escape($alertmsg) . ");\n";
203 echo " if (opener.refreshme) opener.refreshme(" . js_escape($layout_id) . ");\n";
204 echo " window.close();\n";
205 echo "</script></body></html>\n";
206 exit();
209 $row = array(
210 'grp_form_id' => '',
211 'grp_title' => '',
212 'grp_subtitle' => '',
213 'grp_mapping' => 'Clinical',
214 'grp_seq' => '0',
215 'grp_activity' => '1',
216 'grp_repeats' => '0',
217 'grp_columns' => '4',
218 'grp_size' => '9',
219 'grp_issue_type' => '',
220 'grp_aco_spec' => '',
221 // 'grp_save_close' => '0',
222 'grp_init_open' => '0',
223 'grp_referrals' => '0',
224 'grp_services' => '',
225 'grp_products' => '',
226 'grp_diags' => '',
227 'grp_last_update' => '',
230 if ($layout_id) {
231 $row = sqlQuery(
232 "SELECT * FROM layout_group_properties WHERE " .
233 "grp_form_id = ? AND grp_group_id = ?",
234 array($layout_id, $group_id)
236 if (empty($row)) {
237 die(xlt('This layout does not exist.'));
242 <form method='post' action='edit_layout_props.php?<?php echo "layout_id=" . attr_url($layout_id) . "&group_id=" . attr_url($group_id); ?>'>
243 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
244 <center>
246 <table class='w-100 border-0'>
247 <tr>
248 <td valign='top' width='1%' nowrap>
249 <?php echo xlt('Layout ID'); ?>
250 </td>
251 <td>
252 <?php if (empty($layout_id)) { ?>
253 <input type='text' class='form-control' size='31' maxlength='31' name='form_form_id' value='' /><br />
254 <?php echo xlt('Visit form ID must start with LBF. Transaction form ID must start with LBT.') ?>
255 <?php } else { ?>
256 <?php echo text($layout_id); ?>
257 <?php } ?>
258 </td>
259 </tr>
261 <?php if (empty($group_id) && !empty($row['grp_last_update'])) { ?>
262 <tr>
263 <td valign='top' width='1%' nowrap>
264 <?php echo xlt('Last Update'); ?>
265 </td>
266 <td>
267 <?php echo text($row['grp_last_update']); ?>
268 </td>
269 </tr>
270 <?php } ?>
272 <?php if (empty($group_id)) { ?>
273 <tr>
274 <td valign='top' width='1%' nowrap>
275 <?php echo xlt('Title'); ?>
276 </td>
277 <td>
278 <input type='text' class='form-control' size='40' name='form_title' value='<?php echo attr($row['grp_title']); ?>' />
279 </td>
280 </tr>
281 <?php } ?>
283 <tr>
284 <td valign='top' width='1%' nowrap>
285 <?php echo xlt('Subtitle'); ?>
286 </td>
287 <td>
288 <input type='text' class='form-control' size='40' name='form_subtitle' value='<?php echo attr($row['grp_subtitle']); ?>' />
289 </td>
290 </tr>
292 <?php if (empty($group_id)) { ?>
293 <tr>
294 <td></td>
295 <td><?php echo xlt('For transactions, change category to Transactions'); ?></td>
296 </tr>
297 <tr>
298 <td valign='top' width='1%' nowrap>
299 <?php echo xlt('Category'); ?>
300 </td>
301 <td>
303 <input type='text' class='form-control' size='40' name='form_mapping' value='<?php echo attr($row['grp_mapping']); ?>' />
304 </td>
305 </tr>
307 <tr>
308 <td valign='top' width='1%' nowrap>
309 <?php echo xlt('Active{{Item}}'); ?>
310 </td>
311 <td>
312 <input type='checkbox' name='form_activity' <?php echo ($row['grp_activity']) ? "checked" : ""; ?> />
313 </td>
314 </tr>
316 <tr>
317 <td valign='top' width='1%' nowrap>
318 <?php echo xlt('Sequence'); ?>
319 </td>
320 <td>
321 <input type='text' class='form-control' size='4' name='form_seq' value='<?php echo attr($row['grp_seq']); ?>' />
322 </td>
323 </tr>
325 <tr>
326 <td valign='top' width='1%' nowrap>
327 <?php echo xlt('Repeats'); ?>
328 </td>
329 <td>
330 <input type='text' class='form-control' size='4' name='form_repeats'
331 value='<?php echo attr($row['grp_repeats']); ?>' />
332 </td>
333 </tr>
335 <?php } ?>
337 <tr>
338 <td valign='top' nowrap>
339 <?php echo xlt('Layout Columns'); ?>
340 </td>
341 <td>
342 <select name='form_columns' class='form-control'>
343 <?php
344 echo "<option value='0'>" . xlt('Default') . "</option>\n";
345 for ($cols = 2; $cols <= 12; ++$cols) {
346 echo "<option value='" . attr($cols) . "'";
347 if ($cols == $row['grp_columns']) {
348 echo " selected";
350 echo ">" . text($cols) . "</option>\n";
353 </select>
354 </td>
355 </tr>
357 <?php if (empty($group_id)) { ?>
358 <tr>
359 <td valign='top' nowrap>
360 <?php echo xlt('Font Size'); ?>
361 </td>
362 <td>
363 <select name='form_size' class='form-control'>
364 <?php
365 echo "<option value='0'>" . xlt('Default') . "</option>\n";
366 for ($size = 5; $size <= 15; ++$size) {
367 echo "<option value='" . attr($size) . "'";
368 if ($size == $row['grp_size']) {
369 echo " selected";
371 echo ">" . text($size) . "</option>\n";
374 </select>
375 </td>
376 </tr>
378 <tr>
379 <td valign='top' nowrap>
380 <?php echo xlt('Issue Type'); ?>
381 </td>
382 <td>
383 <select name='form_issue' class='form-control'>
384 <option value=''></option>
385 <?php
386 $itres = sqlStatement(
387 "SELECT type, singular FROM issue_types " .
388 "WHERE category = ? AND active = 1 ORDER BY singular",
389 array($GLOBALS['ippf_specific'] ? 'ippf_specific' : 'default')
391 while ($itrow = sqlFetchArray($itres)) {
392 echo "<option value='" . attr($itrow['type']) . "'";
393 if ($itrow['type'] == $row['grp_issue_type']) {
394 echo " selected";
396 echo ">" . xlt($itrow['singular']) . "</option>\n";
399 </select>
400 </td>
401 </tr>
403 <tr>
404 <td valign='top' nowrap>
405 <?php echo xlt('Access Control'); ?>
406 </td>
407 <td>
408 <select name='form_aco' class='form-control'>
409 <option value=''></option>
410 <?php
411 $gacl = new GaclApi();
412 // collect and sort all aco objects
413 $list_aco_objects = $gacl->get_objects(null, 0, 'ACO');
414 ksort($list_aco_objects);
415 foreach ($list_aco_objects as $seckey => $dummy) {
416 if (empty($dummy)) {
417 continue;
419 asort($list_aco_objects[$seckey]);
420 $aco_section_data = $gacl->get_section_data($seckey, 'ACO');
421 $aco_section_title = $aco_section_data[3];
422 echo " <optgroup label='" . xla($aco_section_title) . "'>\n";
423 foreach ($list_aco_objects[$seckey] as $acokey) {
424 $aco_id = $gacl->get_object_id($seckey, $acokey, 'ACO');
425 $aco_data = $gacl->get_object_data($aco_id, 'ACO');
426 $aco_title = $aco_data[0][3];
427 echo " <option value='" . attr("$seckey|$acokey") . "'";
428 if ("$seckey|$acokey" == $row['grp_aco_spec']) {
429 echo " selected";
431 echo ">" . xlt($aco_title) . "</option>\n";
433 echo " </optgroup>\n";
436 </select>
437 </td>
438 </tr>
440 <?php /* ?>
441 <tr>
442 <td valign='top' width='1%' nowrap>
443 <?php echo xlt('Enable Save and Close'); ?>
444 </td>
445 <td>
446 <input type='checkbox' name='form_save_close' <?php echo ($row['grp_save_close']) ? "checked" : ""; ?> />
447 </td>
448 </tr>
449 <?php */ ?>
451 <tr>
452 <td valign='top' width='1%' nowrap>
453 <input type='checkbox' name='form_services' <?php echo ($row['grp_services']) ? "checked" : ""; ?> />
454 <?php echo xlt('Show Services Section'); ?>
455 </td>
456 <td>
457 <input type='text' class='form-control' size='40' name='form_services_codes' onclick='sel_related(this, "MA")' value='<?php echo ($row['grp_services'] != '*') ? attr($row['grp_services']) : ""; ?>' />
458 </td>
459 </tr>
461 <tr>
462 <td valign='top' width='1%' nowrap>
463 <input type='checkbox' name='form_products' <?php echo ($row['grp_products']) ? "checked" : ""; ?> />
464 <?php echo xlt('Show Products Section'); ?>
465 </td>
466 <td>
467 <input type='text' class='form-control' size='40' name='form_products_codes' onclick='sel_related(this, "PROD")' value='<?php echo ($row['grp_products'] != '*') ? attr($row['grp_products']) : ""; ?>' />
468 </td>
469 </tr>
471 <tr>
472 <td valign='top' width='1%' nowrap>
473 <input type='checkbox' name='form_diags' <?php echo ($row['grp_diags']) ? "checked" : ""; ?> />
474 <?php echo xlt('Show Diagnoses Section'); ?>
475 </td>
476 <td>
477 <input type='text' class='form-control' size='40' name='form_diags_codes' onclick='sel_related(this, "ICD10")' value='<?php echo ($row['grp_diags'] != '*') ? attr($row['grp_diags']) : ""; ?>' />
478 </td>
479 </tr>
481 <tr>
482 <td valign='top' width='1%' nowrap>
483 <input type='checkbox' name='form_referrals' <?php echo ($row['grp_referrals']) ? "checked" : ""; ?> />
484 <?php echo xlt('Show Referrals Section'); ?>
485 </td>
486 <td>
487 &nbsp;
488 </td>
489 </tr>
491 <tr>
492 <td valign='top' width='1%' nowrap>
493 <input type='checkbox' name='form_init_open' <?php echo ($row['grp_init_open']) ? "checked" : ""; ?> />
494 <?php echo xlt('Initially Open Sections'); ?>
495 </td>
496 <td>
497 &nbsp;
498 </td>
499 </tr>
501 <?php } else { // else this is a group ?>
502 <tr>
503 <td valign='top' width='1%' nowrap>
504 <?php echo xlt('Initially Open Group'); ?>
505 </td>
506 <td>
507 <input type='checkbox' name='form_init_open' <?php echo ($row['grp_init_open']) ? "checked" : ""; ?> />
508 </td>
509 </tr>
511 <?php } ?>
513 </table>
515 <input type='submit' class='btn btn-primary' name='form_submit' value='<?php echo xla('Submit'); ?>' />
516 <input type='button' class='btn btn-secondary' value='<?php echo xla('Cancel'); ?>' onclick='window.close()' />
517 </center>
518 </form>
519 <script>
520 <?php
521 if ($alertmsg) {
522 echo " alert(" . js_escape($alertmsg) . ");\n";
523 echo " window.close();\n";
526 </script>
527 </body>
528 </html>