4 * Edit Layout Properties.
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
;
24 // Check authorization.
25 $thisauth = AclMain
::aclCheckCore('admin', 'super');
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' ];
35 <title
><?php
echo xlt("Edit Layout Properties"); ?
></title
>
36 <?php Header
::setupHeader('opener'); ?
>
39 td
{ font
-size
:10pt
; }
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
];
68 s +
= codetype +
':' + code
;
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(';');
97 <body
class="body_top">
100 if (!empty($_POST['form_submit']) && !$alertmsg) {
101 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
102 CsrfUtils
::csrfNotVerified();
107 "grp_subtitle = ?, " .
108 "grp_init_open = ?, " .
111 $_POST['form_subtitle'],
112 empty($_POST['form_init_open' ]) ?
0 : 1,
113 intval($_POST['form_columns']),
118 "grp_subtitle = ?, " .
119 "grp_mapping = ?, " .
121 "grp_activity = ?, " .
122 "grp_repeats = ?, " .
123 "grp_columns = ?, " .
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 = ?, " .
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'],
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' ]),
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');
159 $sqlvars[] = $layout_id;
160 $sqlvars[] = $group_id;
162 "UPDATE layout_group_properties SET $sets " .
163 "WHERE grp_form_id = ? AND grp_group_id = ?",
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)) {
177 "SELECT grp_form_id FROM layout_group_properties WHERE " .
178 "grp_form_id = ? AND grp_group_id = ''",
182 $sqlvars[] = $form_form_id;
184 "INSERT INTO layout_group_properties " .
185 "SET $sets, grp_form_id = ?, grp_group_id = ''",
188 $layout_id = $form_form_id;
190 $alertmsg = xl('This layout ID already exists');
193 $alertmsg = xl('Invalid layout ID');
197 // Close this window and redisplay the layout editor.
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";
212 'grp_subtitle' => '',
213 'grp_mapping' => 'Clinical',
215 'grp_activity' => '1',
216 'grp_repeats' => '0',
217 'grp_columns' => '4',
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' => '',
227 'grp_last_update' => '',
232 "SELECT * FROM layout_group_properties WHERE " .
233 "grp_form_id = ? AND grp_group_id = ?",
234 array($layout_id, $group_id)
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()); ?>" />
246 <table
class='w-100 border-0'>
248 <td valign
='top' width
='1%' nowrap
>
249 <?php
echo xlt('Layout ID'); ?
>
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.') ?
>
256 <?php
echo text($layout_id); ?
>
261 <?php
if (empty($group_id) && !empty($row['grp_last_update'])) { ?
>
263 <td valign
='top' width
='1%' nowrap
>
264 <?php
echo xlt('Last Update'); ?
>
267 <?php
echo text($row['grp_last_update']); ?
>
272 <?php
if (empty($group_id)) { ?
>
274 <td valign
='top' width
='1%' nowrap
>
275 <?php
echo xlt('Title'); ?
>
278 <input type
='text' class='form-control' size
='40' name
='form_title' value
='<?php echo attr($row['grp_title
']); ?>' />
284 <td valign
='top' width
='1%' nowrap
>
285 <?php
echo xlt('Subtitle'); ?
>
288 <input type
='text' class='form-control' size
='40' name
='form_subtitle' value
='<?php echo attr($row['grp_subtitle
']); ?>' />
292 <?php
if (empty($group_id)) { ?
>
295 <td
><?php
echo xlt('For transactions, change category to Transactions'); ?
></td
>
298 <td valign
='top' width
='1%' nowrap
>
299 <?php
echo xlt('Category'); ?
>
303 <input type
='text' class='form-control' size
='40' name
='form_mapping' value
='<?php echo attr($row['grp_mapping
']); ?>' />
308 <td valign
='top' width
='1%' nowrap
>
309 <?php
echo xlt('Active{{Item}}'); ?
>
312 <input type
='checkbox' name
='form_activity' <?php
echo ($row['grp_activity']) ?
"checked" : ""; ?
> />
317 <td valign
='top' width
='1%' nowrap
>
318 <?php
echo xlt('Sequence'); ?
>
321 <input type
='text' class='form-control' size
='4' name
='form_seq' value
='<?php echo attr($row['grp_seq
']); ?>' />
326 <td valign
='top' width
='1%' nowrap
>
327 <?php
echo xlt('Repeats'); ?
>
330 <input type
='text' class='form-control' size
='4' name
='form_repeats'
331 value
='<?php echo attr($row['grp_repeats
']); ?>' />
338 <td valign
='top' nowrap
>
339 <?php
echo xlt('Layout Columns'); ?
>
342 <select name
='form_columns' class='form-control'>
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']) {
350 echo ">" . text($cols) . "</option>\n";
357 <?php
if (empty($group_id)) { ?
>
359 <td valign
='top' nowrap
>
360 <?php
echo xlt('Font Size'); ?
>
363 <select name
='form_size' class='form-control'>
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']) {
371 echo ">" . text($size) . "</option>\n";
379 <td valign
='top' nowrap
>
380 <?php
echo xlt('Issue Type'); ?
>
383 <select name
='form_issue' class='form-control'>
384 <option value
=''></option
>
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']) {
396 echo ">" . xlt($itrow['singular']) . "</option>\n";
404 <td valign
='top' nowrap
>
405 <?php
echo xlt('Access Control'); ?
>
408 <select name
='form_aco' class='form-control'>
409 <option value
=''></option
>
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) {
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']) {
431 echo ">" . xlt($aco_title) . "</option>\n";
433 echo " </optgroup>\n";
442 <td valign='top' width='1%' nowrap>
443 <?php echo xlt('Enable Save and Close'); ?>
446 <input type='checkbox' name='form_save_close' <?php echo ($row['grp_save_close']) ? "checked" : ""; ?> />
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'); ?
>
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
']) : ""; ?>' />
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'); ?
>
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
']) : ""; ?>' />
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'); ?
>
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
']) : ""; ?>' />
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'); ?
>
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'); ?
>
501 <?php
} else { // else this is a group ?>
503 <td valign
='top' width
='1%' nowrap
>
504 <?php
echo xlt('Initially Open Group'); ?
>
507 <input type
='checkbox' name
='form_init_open' <?php
echo ($row['grp_init_open']) ?
"checked" : ""; ?
> />
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()' />
522 echo " alert(" . js_escape($alertmsg) . ");\n";
523 echo " window.close();\n";