Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / super / edit_layout_props.php
blobdc3f9c3b0d56cf615b4e0be7e3b7fb4e76a23687
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 <title><?php echo xlt("Edit Layout Properties"); ?></title>
33 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
35 <style>
36 td { font-size:10pt; }
37 </style>
39 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js?v=<?php echo $v_js_includes; ?>"></script>
40 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
41 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery/dist/jquery.min.js"></script>
42 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
44 <script language="JavaScript">
46 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
48 // The name of the input element to receive a found code.
49 var current_sel_name = '';
51 // This invokes the "dynamic" find-code popup.
52 function sel_related(elem, codetype) {
53 current_sel_name = elem ? elem.name : '';
54 var url = '<?php echo $rootdir ?>/patient_file/encounter/find_code_dynamic.php';
55 if (codetype) url += '?codetype=' + encodeURIComponent(codetype);
56 dlgopen(url, '_blank', 800, 500);
59 // This is for callback by the find-code popup.
60 // Appends to or erases the current list of related codes.
61 function set_related(codetype, code, selector, codedesc) {
62 var f = document.forms[0];
63 // frc will be the input element containing the codes.
64 var frc = f[current_sel_name];
65 var s = frc.value;
66 if (code) {
67 if (s.length > 0) {
68 s += ';';
70 s += codetype + ':' + code;
71 } else {
72 s = '';
74 frc.value = s;
75 return '';
78 // This is for callback by the find-code popup.
79 // Deletes the specified codetype:code from the active input element.
80 function del_related(s) {
81 var f = document.forms[0];
82 my_del_related(s, f[current_sel_name], false);
85 // This is for callback by the find-code popup.
86 // Returns the array of currently selected codes with each element in codetype:code format.
87 function get_related() {
88 var f = document.forms[0];
89 if (current_sel_name) {
90 return f[current_sel_name].value.split(';');
92 return new Array();
95 </script>
97 </head>
99 <body class="body_top">
101 <?php
102 if ($_POST['form_submit'] && !$alertmsg) {
103 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
104 csrfNotVerified();
107 if ($group_id) {
108 $sets =
109 "grp_subtitle = ?, " .
110 "grp_columns = ?";
111 $sqlvars = array(
112 $_POST['form_subtitle'],
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_services = ?, " .
128 "grp_products = ?, " .
129 "grp_diags = ?";
130 $sqlvars = array(
131 $_POST['form_title'],
132 $_POST['form_subtitle'],
133 $_POST['form_mapping'],
134 intval($_POST['form_seq']),
135 empty($_POST['form_activity']) ? 0 : 1,
136 intval($_POST['form_repeats']),
137 intval($_POST['form_columns']),
138 intval($_POST['form_size']),
139 $_POST['form_issue'],
140 $_POST['form_aco'],
141 empty($_POST['form_services']) ? '' : (empty($_POST['form_services_codes']) ? '*' : $_POST['form_services_codes']),
142 empty($_POST['form_products']) ? '' : (empty($_POST['form_products_codes']) ? '*' : $_POST['form_products_codes']),
143 empty($_POST['form_diags' ]) ? '' : (empty($_POST['form_diags_codes' ]) ? '*' : $_POST['form_diags_codes' ]),
147 if ($layout_id) {
148 // They have edited an existing layout.
149 $sqlvars[] = $layout_id;
150 $sqlvars[] = $group_id;
151 sqlStatement(
152 "UPDATE layout_group_properties SET $sets " .
153 "WHERE grp_form_id = ? AND grp_group_id = ?",
154 $sqlvars
156 } else if (!$group_id) {
157 // They want to add a new layout. New groups not supported here.
158 $form_form_id = $_POST['form_form_id'];
159 if (preg_match('/(LBF|LBT)[0-9A-Za-z_]+/', $form_form_id)) {
160 $tmp = sqlQuery(
161 "SELECT grp_form_id FROM layout_group_properties WHERE " .
162 "grp_form_id = ? AND grp_group_id = ''",
163 array($form_form_id)
165 if (empty($row)) {
166 $sqlvars[] = $form_form_id;
167 sqlStatement(
168 "INSERT INTO layout_group_properties " .
169 "SET $sets, grp_form_id = ?, grp_group_id = ''",
170 $sqlvars
172 $layout_id = $form_form_id;
173 } else {
174 $alertmsg = xl('This layout ID already exists');
176 } else {
177 $alertmsg = xl('Invalid layout ID');
181 // Close this window and redisplay the layout editor.
183 echo "<script language='JavaScript'>\n";
184 if ($alertmsg) {
185 echo " alert(" . js_escape($alertmsg) . ");\n";
187 echo " if (opener.refreshme) opener.refreshme(" . js_escape($layout_id) . ");\n";
188 echo " window.close();\n";
189 echo "</script></body></html>\n";
190 exit();
193 $row = array(
194 'grp_form_id' => '',
195 'grp_title' => '',
196 'grp_subtitle' => '',
197 'grp_mapping' => 'Clinical',
198 'grp_seq' => '0',
199 'grp_activity' => '1',
200 'grp_repeats' => '0',
201 'grp_columns' => '4',
202 'grp_size' => '9',
203 'grp_issue_type' => '',
204 'grp_aco_spec' => '',
205 'grp_services' => '',
206 'grp_products' => '',
207 'grp_diags' => '',
210 if ($layout_id) {
211 $row = sqlQuery(
212 "SELECT * FROM layout_group_properties WHERE " .
213 "grp_form_id = ? AND grp_group_id = ?",
214 array($layout_id, $group_id)
216 if (empty($row)) {
217 die(xlt('This layout does not exist.'));
222 <form method='post' action='edit_layout_props.php?<?php echo "layout_id=" . attr_url($layout_id) . "&group_id=" . attr_url($group_id); ?>'>
223 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
224 <center>
226 <table border='0' width='100%'>
227 <?php if (empty($layout_id)) { ?>
228 <tr>
229 <td valign='top' width='1%' nowrap>
230 <?php echo xlt('Layout ID'); ?>
231 </td>
232 <td>
233 <input type='text' size='31' maxlength='31' name='form_form_id'
234 value='' /><br />
235 <?php echo xlt('Visit form ID must start with LBF. Transaction form ID must start with LBT.') ?>
236 </td>
237 </tr>
238 <?php } ?>
240 <?php if (empty($group_id)) { ?>
241 <tr>
242 <td valign='top' width='1%' nowrap>
243 <?php echo xlt('Title'); ?>
244 </td>
245 <td>
246 <input type='text' size='40' name='form_title' style='width:100%'
247 value='<?php echo attr($row['grp_title']); ?>' />
248 </td>
249 </tr>
250 <?php } ?>
252 <tr>
253 <td valign='top' width='1%' nowrap>
254 <?php echo xlt('Subtitle'); ?>
255 </td>
256 <td>
257 <input type='text' size='40' name='form_subtitle' style='width:100%'
258 value='<?php echo attr($row['grp_subtitle']); ?>' />
259 </td>
260 </tr>
262 <?php if (empty($group_id)) { ?>
264 <tr>
265 <td valign='top' width='1%' nowrap>
266 <?php echo xlt('Category'); ?>
267 </td>
268 <td>
269 <input type='text' size='40' name='form_mapping' style='width:100%'
270 value='<?php echo attr($row['grp_mapping']); ?>' />
271 </td>
272 </tr>
274 <tr>
275 <td valign='top' width='1%' nowrap>
276 <?php echo xlt('Active'); ?>
277 </td>
278 <td>
279 <input type='checkbox' name='form_activity' <?php echo ($row['grp_activity']) ? "checked" : ""; ?> />
280 </td>
281 </tr>
283 <tr>
284 <td valign='top' width='1%' nowrap>
285 <?php echo xlt('Sequence'); ?>
286 </td>
287 <td>
288 <input type='text' size='4' name='form_seq'
289 value='<?php echo attr($row['grp_seq']); ?>' />
290 </td>
291 </tr>
293 <tr>
294 <td valign='top' width='1%' nowrap>
295 <?php echo xlt('Repeats'); ?>
296 </td>
297 <td>
298 <input type='text' size='4' name='form_repeats'
299 value='<?php echo attr($row['grp_repeats']); ?>' />
300 </td>
301 </tr>
303 <?php } ?>
305 <tr>
306 <td valign='top' nowrap>
307 <?php echo xlt('Layout Columns'); ?>
308 </td>
309 <td>
310 <select name='form_columns'>
311 <?php
312 echo "<option value='0'>" . xlt('Default') . "</option>\n";
313 for ($cols = 2; $cols <= 10; ++$cols) {
314 echo "<option value='" . attr($cols) . "'";
315 if ($cols == $row['grp_columns']) {
316 echo " selected";
318 echo ">" . text($cols) . "</option>\n";
321 </select>
322 </td>
323 </tr>
325 <?php if (empty($group_id)) { ?>
327 <tr>
328 <td valign='top' nowrap>
329 <?php echo xlt('Font Size'); ?>
330 </td>
331 <td>
332 <select name='form_size'>
333 <?php
334 echo "<option value='0'>" . xlt('Default') . "</option>\n";
335 for ($size = 5; $size <= 15; ++$size) {
336 echo "<option value='" . attr($size) . "'";
337 if ($size == $row['grp_size']) {
338 echo " selected";
340 echo ">" . text($size) . "</option>\n";
343 </select>
344 </td>
345 </tr>
347 <tr>
348 <td valign='top' nowrap>
349 <?php echo xlt('Issue Type'); ?>
350 </td>
351 <td>
352 <select name='form_issue'>
353 <option value=''></option>
354 <?php
355 $itres = sqlStatement(
356 "SELECT type, singular FROM issue_types " .
357 "WHERE category = ? AND active = 1 ORDER BY singular",
358 array($GLOBALS['ippf_specific'] ? 'ippf_specific' : 'default')
360 while ($itrow = sqlFetchArray($itres)) {
361 echo "<option value='" . attr($itrow['type']) . "'";
362 if ($itrow['type'] == $row['grp_issue_type']) {
363 echo " selected";
365 echo ">" . xlt($itrow['singular']) . "</option>\n";
368 </select>
369 </td>
370 </tr>
372 <tr>
373 <td valign='top' nowrap>
374 <?php echo xlt('Access Control'); ?>
375 </td>
376 <td>
377 <select name='form_aco' style='width:100%'>
378 <option value=''></option>
379 <?php
380 $gacl = new gacl_api();
381 // collect and sort all aco objects
382 $list_aco_objects = $gacl->get_objects(null, 0, 'ACO');
383 ksort($list_aco_objects);
384 foreach ($list_aco_objects as $seckey => $dummy) {
385 if (empty($dummy)) {
386 continue;
388 asort($list_aco_objects[$seckey]);
389 $aco_section_data = $gacl->get_section_data($seckey, 'ACO');
390 $aco_section_title = $aco_section_data[3];
391 echo " <optgroup label='" . xla($aco_section_title) . "'>\n";
392 foreach ($list_aco_objects[$seckey] as $acokey) {
393 $aco_id = $gacl->get_object_id($seckey, $acokey, 'ACO');
394 $aco_data = $gacl->get_object_data($aco_id, 'ACO');
395 $aco_title = $aco_data[0][3];
396 echo " <option value='" . attr("$seckey|$acokey") . "'";
397 if ("$seckey|$acokey" == $row['grp_aco_spec']) {
398 echo " selected";
400 echo ">" . xlt($aco_title) . "</option>\n";
402 echo " </optgroup>\n";
405 </select>
406 </td>
407 </tr>
409 <tr>
410 <td valign='top' width='1%' nowrap>
411 <input type='checkbox' name='form_services' <?php echo ($row['grp_services']) ? "checked" : ""; ?> />
412 <?php echo xlt('Show Services Section'); ?>
413 </td>
414 <td>
415 <input type='text' size='40' name='form_services_codes' onclick='sel_related(this, "MA")' style='width:100%'
416 value='<?php echo ($row['grp_services'] != '*') ? attr($row['grp_services']) : ""; ?>' />
417 </td>
418 </tr>
420 <tr>
421 <td valign='top' width='1%' nowrap>
422 <input type='checkbox' name='form_products' <?php echo ($row['grp_products']) ? "checked" : ""; ?> />
423 <?php echo xlt('Show Products Section'); ?>
424 </td>
425 <td>
426 <input type='text' size='40' name='form_products_codes' onclick='sel_related(this, "PROD")' style='width:100%'
427 value='<?php echo ($row['grp_products'] != '*') ? attr($row['grp_products']) : ""; ?>' />
428 </td>
429 </tr>
431 <tr>
432 <td valign='top' width='1%' nowrap>
433 <input type='checkbox' name='form_diags' <?php echo ($row['grp_diags']) ? "checked" : ""; ?> />
434 <?php echo xlt('Show Diagnoses Section'); ?>
435 </td>
436 <td>
437 <input type='text' size='40' name='form_diags_codes' onclick='sel_related(this, "ICD10")' style='width:100%'
438 value='<?php echo ($row['grp_diags'] != '*') ? attr($row['grp_diags']) : ""; ?>' />
439 </td>
440 </tr>
442 <?php } ?>
444 </table>
447 <input type='submit' name='form_submit' value='<?php echo xla('Submit'); ?>' />
449 &nbsp;
450 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick='window.close()' />
451 </p>
453 </center>
454 </form>
455 <script language='JavaScript'>
456 <?php
457 if ($alertmsg) {
458 echo " alert(" . js_escape($alertmsg) . ");\n";
459 echo " window.close();\n";
462 </script>
463 </body>
464 </html>