Portal Update Forum Request (#2068)
[openemr.git] / interface / super / edit_layout_props.php
blob8a5686c3cdc35ecab52eadf2582c545e355768cc
1 <?php
2 /**
3 * Edit Layout Properties.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2016-2017 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/acl.inc");
17 require_once("$phpgacl_location/gacl_api.class.php");
19 $alertmsg = "";
21 // Check authorization.
22 $thisauth = acl_check('admin', 'super');
23 if (!$thisauth) {
24 die(xlt('Not authorized'));
27 $layout_id = empty($_GET['layout_id']) ? '' : $_GET['layout_id'];
28 $group_id = empty($_GET['group_id' ]) ? '' : $_GET['group_id' ];
30 <html>
31 <head>
32 <?php html_header_show();?>
33 <title><?php echo xlt("Edit Layout Properties"); ?></title>
34 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
36 <style>
37 td { font-size:10pt; }
38 </style>
40 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js?v=<?php echo $v_js_includes; ?>"></script>
41 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
42 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery/dist/jquery.min.js"></script>
43 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
45 <script language="JavaScript">
47 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
49 // The name of the input element to receive a found code.
50 var current_sel_name = '';
52 // This invokes the "dynamic" find-code popup.
53 function sel_related(elem, codetype) {
54 current_sel_name = elem ? elem.name : '';
55 var url = '<?php echo $rootdir ?>/patient_file/encounter/find_code_dynamic.php';
56 if (codetype) url += '?codetype=' + encodeURIComponent(codetype);
57 dlgopen(url, '_blank', 800, 500);
60 // This is for callback by the find-code popup.
61 // Appends to or erases the current list of related codes.
62 function set_related(codetype, code, selector, codedesc) {
63 var f = document.forms[0];
64 // frc will be the input element containing the codes.
65 var frc = f[current_sel_name];
66 var s = frc.value;
67 if (code) {
68 if (s.length > 0) {
69 s += ';';
71 s += codetype + ':' + code;
72 } else {
73 s = '';
75 frc.value = s;
76 return '';
79 // This is for callback by the find-code popup.
80 // Deletes the specified codetype:code from the active input element.
81 function del_related(s) {
82 var f = document.forms[0];
83 my_del_related(s, f[current_sel_name], false);
86 // This is for callback by the find-code popup.
87 // Returns the array of currently selected codes with each element in codetype:code format.
88 function get_related() {
89 var f = document.forms[0];
90 if (current_sel_name) {
91 return f[current_sel_name].value.split(';');
93 return new Array();
96 </script>
98 </head>
100 <body class="body_top">
102 <?php
103 if ($_POST['form_submit'] && !$alertmsg) {
104 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
105 csrfNotVerified();
108 if ($group_id) {
109 $sets =
110 "grp_subtitle = ?, " .
111 "grp_columns = ?";
112 $sqlvars = array(
113 $_POST['form_subtitle'],
114 intval($_POST['form_columns']),
116 } else {
117 $sets =
118 "grp_title = ?, " .
119 "grp_subtitle = ?, " .
120 "grp_mapping = ?, " .
121 "grp_seq = ?, " .
122 "grp_activity = ?, " .
123 "grp_repeats = ?, " .
124 "grp_columns = ?, " .
125 "grp_size = ?, " .
126 "grp_issue_type = ?, " .
127 "grp_aco_spec = ?, " .
128 "grp_services = ?, " .
129 "grp_products = ?, " .
130 "grp_diags = ?";
131 $sqlvars = array(
132 $_POST['form_title'],
133 $_POST['form_subtitle'],
134 $_POST['form_mapping'],
135 intval($_POST['form_seq']),
136 empty($_POST['form_activity']) ? 0 : 1,
137 intval($_POST['form_repeats']),
138 intval($_POST['form_columns']),
139 intval($_POST['form_size']),
140 $_POST['form_issue'],
141 $_POST['form_aco'],
142 empty($_POST['form_services']) ? '' : (empty($_POST['form_services_codes']) ? '*' : $_POST['form_services_codes']),
143 empty($_POST['form_products']) ? '' : (empty($_POST['form_products_codes']) ? '*' : $_POST['form_products_codes']),
144 empty($_POST['form_diags' ]) ? '' : (empty($_POST['form_diags_codes' ]) ? '*' : $_POST['form_diags_codes' ]),
148 if ($layout_id) {
149 // They have edited an existing layout.
150 $sqlvars[] = $layout_id;
151 $sqlvars[] = $group_id;
152 sqlStatement(
153 "UPDATE layout_group_properties SET $sets " .
154 "WHERE grp_form_id = ? AND grp_group_id = ?",
155 $sqlvars
157 } else if (!$group_id) {
158 // They want to add a new layout. New groups not supported here.
159 $form_form_id = $_POST['form_form_id'];
160 if (preg_match('/(LBF|LBT)[0-9A-Za-z_]+/', $form_form_id)) {
161 $tmp = sqlQuery(
162 "SELECT grp_form_id FROM layout_group_properties WHERE " .
163 "grp_form_id = ? AND grp_group_id = ''",
164 array($form_form_id)
166 if (empty($row)) {
167 $sqlvars[] = $form_form_id;
168 sqlStatement(
169 "INSERT INTO layout_group_properties " .
170 "SET $sets, grp_form_id = ?, grp_group_id = ''",
171 $sqlvars
173 $layout_id = $form_form_id;
174 } else {
175 $alertmsg = xl('This layout ID already exists');
177 } else {
178 $alertmsg = xl('Invalid layout ID');
182 // Close this window and redisplay the layout editor.
184 echo "<script language='JavaScript'>\n";
185 if ($alertmsg) {
186 echo " alert(" . js_escape($alertmsg) . ");\n";
188 echo " if (opener.refreshme) opener.refreshme(" . js_escape($layout_id) . ");\n";
189 echo " window.close();\n";
190 echo "</script></body></html>\n";
191 exit();
194 $row = array(
195 'grp_form_id' => '',
196 'grp_title' => '',
197 'grp_subtitle' => '',
198 'grp_mapping' => 'Clinical',
199 'grp_seq' => '0',
200 'grp_activity' => '1',
201 'grp_repeats' => '0',
202 'grp_columns' => '4',
203 'grp_size' => '9',
204 'grp_issue_type' => '',
205 'grp_aco_spec' => '',
206 'grp_services' => '',
207 'grp_products' => '',
208 'grp_diags' => '',
211 if ($layout_id) {
212 $row = sqlQuery(
213 "SELECT * FROM layout_group_properties WHERE " .
214 "grp_form_id = ? AND grp_group_id = ?",
215 array($layout_id, $group_id)
217 if (empty($row)) {
218 die(xlt('This layout does not exist.'));
223 <form method='post' action='edit_layout_props.php?<?php echo "layout_id=" . attr_url($layout_id) . "&group_id=" . attr_url($group_id); ?>'>
224 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
225 <center>
227 <table border='0' width='100%'>
228 <?php if (empty($layout_id)) { ?>
229 <tr>
230 <td valign='top' width='1%' nowrap>
231 <?php echo xlt('Layout ID'); ?>
232 </td>
233 <td>
234 <input type='text' size='31' maxlength='31' name='form_form_id'
235 value='' /><br />
236 <?php echo xlt('Visit form ID must start with LBF. Transaction form ID must start with LBT.') ?>
237 </td>
238 </tr>
239 <?php } ?>
241 <?php if (empty($group_id)) { ?>
242 <tr>
243 <td valign='top' width='1%' nowrap>
244 <?php echo xlt('Title'); ?>
245 </td>
246 <td>
247 <input type='text' size='40' name='form_title' style='width:100%'
248 value='<?php echo attr($row['grp_title']); ?>' />
249 </td>
250 </tr>
251 <?php } ?>
253 <tr>
254 <td valign='top' width='1%' nowrap>
255 <?php echo xlt('Subtitle'); ?>
256 </td>
257 <td>
258 <input type='text' size='40' name='form_subtitle' style='width:100%'
259 value='<?php echo attr($row['grp_subtitle']); ?>' />
260 </td>
261 </tr>
263 <?php if (empty($group_id)) { ?>
265 <tr>
266 <td valign='top' width='1%' nowrap>
267 <?php echo xlt('Category'); ?>
268 </td>
269 <td>
270 <input type='text' size='40' name='form_mapping' style='width:100%'
271 value='<?php echo attr($row['grp_mapping']); ?>' />
272 </td>
273 </tr>
275 <tr>
276 <td valign='top' width='1%' nowrap>
277 <?php echo xlt('Active'); ?>
278 </td>
279 <td>
280 <input type='checkbox' name='form_activity' <?php echo ($row['grp_activity']) ? "checked" : ""; ?> />
281 </td>
282 </tr>
284 <tr>
285 <td valign='top' width='1%' nowrap>
286 <?php echo xlt('Sequence'); ?>
287 </td>
288 <td>
289 <input type='text' size='4' name='form_seq'
290 value='<?php echo attr($row['grp_seq']); ?>' />
291 </td>
292 </tr>
294 <tr>
295 <td valign='top' width='1%' nowrap>
296 <?php echo xlt('Repeats'); ?>
297 </td>
298 <td>
299 <input type='text' size='4' name='form_repeats'
300 value='<?php echo attr($row['grp_repeats']); ?>' />
301 </td>
302 </tr>
304 <?php } ?>
306 <tr>
307 <td valign='top' nowrap>
308 <?php echo xlt('Layout Columns'); ?>
309 </td>
310 <td>
311 <select name='form_columns'>
312 <?php
313 echo "<option value='0'>" . xlt('Default') . "</option>\n";
314 for ($cols = 2; $cols <= 10; ++$cols) {
315 echo "<option value='" . attr($cols) . "'";
316 if ($cols == $row['grp_columns']) {
317 echo " selected";
319 echo ">" . text($cols) . "</option>\n";
322 </select>
323 </td>
324 </tr>
326 <?php if (empty($group_id)) { ?>
328 <tr>
329 <td valign='top' nowrap>
330 <?php echo xlt('Font Size'); ?>
331 </td>
332 <td>
333 <select name='form_size'>
334 <?php
335 echo "<option value='0'>" . xlt('Default') . "</option>\n";
336 for ($size = 5; $size <= 15; ++$size) {
337 echo "<option value='" . attr($size) . "'";
338 if ($size == $row['grp_size']) {
339 echo " selected";
341 echo ">" . text($size) . "</option>\n";
344 </select>
345 </td>
346 </tr>
348 <tr>
349 <td valign='top' nowrap>
350 <?php echo xlt('Issue Type'); ?>
351 </td>
352 <td>
353 <select name='form_issue'>
354 <option value=''></option>
355 <?php
356 $itres = sqlStatement(
357 "SELECT type, singular FROM issue_types " .
358 "WHERE category = ? AND active = 1 ORDER BY singular",
359 array($GLOBALS['ippf_specific'] ? 'ippf_specific' : 'default')
361 while ($itrow = sqlFetchArray($itres)) {
362 echo "<option value='" . attr($itrow['type']) . "'";
363 if ($itrow['type'] == $row['grp_issue_type']) {
364 echo " selected";
366 echo ">" . xlt($itrow['singular']) . "</option>\n";
369 </select>
370 </td>
371 </tr>
373 <tr>
374 <td valign='top' nowrap>
375 <?php echo xlt('Access Control'); ?>
376 </td>
377 <td>
378 <select name='form_aco' style='width:100%'>
379 <option value=''></option>
380 <?php
381 $gacl = new gacl_api();
382 // collect and sort all aco objects
383 $list_aco_objects = $gacl->get_objects(null, 0, 'ACO');
384 ksort($list_aco_objects);
385 foreach ($list_aco_objects as $seckey => $dummy) {
386 if (empty($dummy)) {
387 continue;
389 asort($list_aco_objects[$seckey]);
390 $aco_section_data = $gacl->get_section_data($seckey, 'ACO');
391 $aco_section_title = $aco_section_data[3];
392 echo " <optgroup label='" . xla($aco_section_title) . "'>\n";
393 foreach ($list_aco_objects[$seckey] as $acokey) {
394 $aco_id = $gacl->get_object_id($seckey, $acokey, 'ACO');
395 $aco_data = $gacl->get_object_data($aco_id, 'ACO');
396 $aco_title = $aco_data[0][3];
397 echo " <option value='" . attr("$seckey|$acokey") . "'";
398 if ("$seckey|$acokey" == $row['grp_aco_spec']) {
399 echo " selected";
401 echo ">" . xlt($aco_title) . "</option>\n";
403 echo " </optgroup>\n";
406 </select>
407 </td>
408 </tr>
410 <tr>
411 <td valign='top' width='1%' nowrap>
412 <input type='checkbox' name='form_services' <?php echo ($row['grp_services']) ? "checked" : ""; ?> />
413 <?php echo xlt('Show Services Section'); ?>
414 </td>
415 <td>
416 <input type='text' size='40' name='form_services_codes' onclick='sel_related(this, "MA")' style='width:100%'
417 value='<?php echo ($row['grp_services'] != '*') ? attr($row['grp_services']) : ""; ?>' />
418 </td>
419 </tr>
421 <tr>
422 <td valign='top' width='1%' nowrap>
423 <input type='checkbox' name='form_products' <?php echo ($row['grp_products']) ? "checked" : ""; ?> />
424 <?php echo xlt('Show Products Section'); ?>
425 </td>
426 <td>
427 <input type='text' size='40' name='form_products_codes' onclick='sel_related(this, "PROD")' style='width:100%'
428 value='<?php echo ($row['grp_products'] != '*') ? attr($row['grp_products']) : ""; ?>' />
429 </td>
430 </tr>
432 <tr>
433 <td valign='top' width='1%' nowrap>
434 <input type='checkbox' name='form_diags' <?php echo ($row['grp_diags']) ? "checked" : ""; ?> />
435 <?php echo xlt('Show Diagnoses Section'); ?>
436 </td>
437 <td>
438 <input type='text' size='40' name='form_diags_codes' onclick='sel_related(this, "ICD10")' style='width:100%'
439 value='<?php echo ($row['grp_diags'] != '*') ? attr($row['grp_diags']) : ""; ?>' />
440 </td>
441 </tr>
443 <?php } ?>
445 </table>
448 <input type='submit' name='form_submit' value='<?php echo xla('Submit'); ?>' />
450 &nbsp;
451 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick='window.close()' />
452 </p>
454 </center>
455 </form>
456 <script language='JavaScript'>
457 <?php
458 if ($alertmsg) {
459 echo " alert(" . js_escape($alertmsg) . ");\n";
460 echo " window.close();\n";
463 </script>
464 </body>
465 </html>