Make the default 2 tabs more configurable (#1390)
[openemr.git] / interface / main / tabs / main.php
blob2c443e1c66f588dabd0f8eeffe882dd218ba1ee1
1 <?php
2 use Esign\Api;
3 use OpenEMR\Core\Header;
5 /**
6 * Copyright (C) 2016 Kevin Yeh <kevin.y@integralemr.com>
7 * Copyright (C) 2016 Brady Miller <brady.g.miller@gmail.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
20 * @package OpenEMR
21 * @author Kevin Yeh <kevin.y@integralemr.com>
22 * @author Brady Miller <brady.g.miller@gmail.com>
23 * @link http://www.open-emr.org
29 /* Include our required headers */
30 require_once('../../globals.php');
31 require_once $GLOBALS['srcdir'].'/ESign/Api.php';
33 $esignApi = new Api();
35 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
36 <html>
37 <head>
38 <title><?php echo text($openemr_name); ?></title>
40 <script type="text/javascript">
41 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
43 // Since this should be the parent window, this is to prevent calls to the
44 // window that opened this window. For example when a new window is opened
45 // from the Patient Flow Board or the Patient Finder.
46 window.opener = null;
48 // This flag indicates if another window or frame is trying to reload the login
49 // page to this top-level window. It is set by javascript returned by auth.inc
50 // and is checked by handlers of beforeunload events.
51 var timed_out = false;
53 // Include this variable for backward compatibility
54 var loadedFrameCount = 0;
55 var tab_mode=true;
56 function allFramesLoaded() {
57 // Stub function for backward compatibility with frame race condition mechanism
58 return true;
61 function goRepeaterServices(){
62 top.restoreSession();
63 // Ensure send the skip_timeout_reset parameter to not count this as a manual entry in the
64 // timing out mechanism in OpenEMR.
66 // Send the skip_timeout_reset parameter to not count this as a manual entry in the
67 // timing out mechanism in OpenEMR.
68 $.post("<?php echo $GLOBALS['webroot']; ?>/library/ajax/dated_reminders_counter.php",
69 { skip_timeout_reset: "1" },
70 function(data) {
71 // Go knockout.js
72 app_view_model.application_data.user().messages(data);
76 // run background-services
77 $.post("<?php echo $GLOBALS['webroot']; ?>/library/ajax/execute_background_services.php",
78 { skip_timeout_reset: "1", ajax: "1" }
81 // auto run this function every 60 seconds
82 var repeater = setTimeout("goRepeaterServices()", 60000);
85 function isEncounterLocked( encounterId ) {
86 <?php if ($esignApi->lockEncounters()) { ?>
87 // If encounter locking is enabled, make a syncronous call (async=false) to check the
88 // DB to see if the encounter is locked.
89 // Call restore session, just in case
90 top.restoreSession();
91 $.ajax({
92 type: 'POST',
93 url: '<?php echo $GLOBALS['webroot']?>/interface/esign/index.php?module=encounter&method=esign_is_encounter_locked',
94 data: { encounterId : encounterId },
95 success: function( data ) {
96 encounter_locked = data;
98 dataType: 'json',
99 async:false
101 return encounter_locked;
102 <?php } else { ?>
103 // If encounter locking isn't enabled then always return false
104 return false;
105 <?php } ?>
107 var webroot_url="<?php echo $web_root; ?>";
108 </script>
110 <?php Header::setupHeader(["knockout","tabs-theme",'jquery-ui']); ?>
113 <link rel="shortcut icon" href="<?php echo $GLOBALS['images_static_relative']; ?>/favicon.ico" />
115 <script type="text/javascript" src="js/custom_bindings.js?v=<?php echo $v_js_includes; ?>"></script>
116 <script type="text/javascript" src="js/user_data_view_model.js?v=<?php echo $v_js_includes; ?>"></script>
117 <script type="text/javascript" src="js/patient_data_view_model.js?v=<?php echo $v_js_includes; ?>"></script>
118 <script type="text/javascript" src="js/therapy_group_data_view_model.js?v=<?php echo $v_js_includes; ?>"></script>
120 <script type="text/javascript">
121 // Create translations to be used in the menuActionClick() function in below js/tabs_view_model.js script
122 var xl_strings_tabs_view_model = <?php echo json_encode(array(
123 'encounter_locked' => xla('This encounter is locked. No new forms can be added.'),
124 'must_select_patient' => $GLOBALS['enable_group_therapy'] ? xla('You must first select or add a patient or therapy group.') : xla('You must first select or add a patient.'),
125 'must_select_encounter' => xla('You must first select or create an encounter.')
128 </script>
129 <script type="text/javascript" src="js/tabs_view_model.js?v=<?php echo $v_js_includes; ?>"></script>
131 <script type="text/javascript" src="js/application_view_model.js?v=<?php echo $v_js_includes; ?>"></script>
132 <script type="text/javascript" src="js/frame_proxies.js?v=<?php echo $v_js_includes; ?>"></script>
133 <script type="text/javascript" src="js/dialog_utils.js?v=<?php echo $v_js_includes; ?>"></script>
135 <?php
136 // Below code block is to prepare certain elements for deciding what links to show on the menu
138 // prepare newcrop globals that are used in creating the menu
139 if ($GLOBALS['erx_enable']) {
140 $newcrop_user_role_sql = sqlQuery("SELECT `newcrop_user_role` FROM `users` WHERE `username` = ?", array($_SESSION['authUser']));
141 $GLOBALS['newcrop_user_role'] = $newcrop_user_role_sql['newcrop_user_role'];
142 if ($GLOBALS['newcrop_user_role'] === 'erxadmin') {
143 $GLOBALS['newcrop_user_role_erxadmin'] = 1;
147 // prepare track anything to be used in creating the menu
148 $track_anything_sql = sqlQuery("SELECT `state` FROM `registry` WHERE `directory` = 'track_anything'");
149 $GLOBALS['track_anything_state'] = $track_anything_sql['state'];
150 // prepare Issues popup link global that is used in creating the menu
151 $GLOBALS['allow_issue_menu_link'] = ((acl_check('encounters', 'notes', '', 'write') || acl_check('encounters', 'notes_a', '', 'write')) &&
152 acl_check('patients', 'med', '', 'write'));
155 <?php require_once("templates/tabs_template.php"); ?>
156 <?php require_once("templates/menu_template.php"); ?>
157 <?php require_once("templates/patient_data_template.php"); ?>
158 <?php require_once("templates/therapy_group_template.php"); ?>
159 <?php require_once("templates/user_data_template.php"); ?>
160 <?php require_once("menu/menu_json.php"); ?>
161 <?php $userQuery = sqlQuery("select * from users where username = ?", array($_SESSION['authUser'])); ?>
162 <script type="text/javascript">
163 <?php if (!empty($_SESSION['frame1url']) && !empty($_SESSION['frame1target'])) { ?>
164 app_view_model.application_data.tabs.tabsList()[0].url(<?php echo json_encode("../".$_SESSION['frame1url']); ?>);
165 app_view_model.application_data.tabs.tabsList()[0].name(<?php echo json_encode($_SESSION['frame1target']); ?>);
166 <?php } ?>
167 <?php unset($_SESSION['frame1url']); ?>
168 <?php unset($_SESSION['frame1target']); ?>
169 <?php if (!empty($_SESSION['frame2url']) && !empty($_SESSION['frame2target'])) { ?>
170 app_view_model.application_data.tabs.tabsList()[1].url(<?php echo json_encode("../".$_SESSION['frame2url']); ?>);
171 app_view_model.application_data.tabs.tabsList()[1].name(<?php echo json_encode($_SESSION['frame2target']); ?>);
172 <?php } ?>
173 <?php unset($_SESSION['frame2url']); ?>
174 <?php unset($_SESSION['frame2target']); ?>
176 app_view_model.application_data.user(new user_data_view_model(<?php echo json_encode($_SESSION{"authUser"})
177 .',' . json_encode($userQuery['fname'])
178 .',' . json_encode($userQuery['lname'])
179 .',' . json_encode($_SESSION['authGroup']); ?>));
181 </script>
183 </head>
184 <body>
185 <!-- Below iframe is to support auto logout when timeout is reached -->
186 <iframe name="timeout" style="visibility:hidden; position:absolute; left:0; top:0; height:0; width:0; border:none;" src="timeout_iframe.php"></iframe>
187 <?php // mdsupport - app settings
188 $disp_mainBox = '';
189 if (isset($_SESSION['app1'])) {
190 $rs = sqlquery(
191 "SELECT title app_url FROM list_options WHERE activity=1 AND list_id=? AND option_id=?",
192 array('apps', $_SESSION['app1'])
194 if ($rs['app_url'] != "main/main_screen.php") {
195 echo '<iframe name="app1" src="../../'.attr($rs['app_url']).'"
196 style="position:absolute; left:0; top:0; height:100%; width:100%; border:none;" />';
197 $disp_mainBox = 'style="display: none;"';
201 <div id="mainBox" <?php echo $disp_mainBox ?>>
202 <div id="dialogDiv"></div>
203 <div class="body_top">
204 <a href="http://www.open-emr.org" title="OpenEMR <?php echo xla("Website"); ?>" target="_blank"><img class="logo" alt="openEMR small logo" style="float: left; margin:3px 4px 0px 10px;width:20px;z-index:10000;" border="0" src="<?php echo $GLOBALS['images_static_relative']; ?>/menu-logo.png"></a>
205 <span id="menu logo" data-bind="template: {name: 'menu-template', data: application_data} "></span>
206 <span id="userData" data-bind="template: {name: 'user-data-template', data:application_data} "></span>
207 </div>
208 <div id="attendantData" class="body_title acck" data-bind="template: {name: app_view_model.attendant_template_type, data: application_data} ">
209 </div>
210 <div class="body_title" data-bind="template: {name: 'tabs-controls', data: application_data} "> </div>
212 <div class="mainFrames">
213 <div id="framesDisplay" data-bind="template: {name: 'tabs-frames', data: application_data}"> </div>
214 </div>
215 </div>
216 <script>
217 $("#dialogDiv").hide();
218 ko.applyBindings(app_view_model);
220 $(document).ready(function() {
221 $('.dropdown-toggle').dropdown();
222 goRepeaterServices();
223 $('#patient_caret').click(function() {
224 $('#attendantData').slideToggle();
225 $('#patient_caret').toggleClass('fa-caret-down').toggleClass('fa-caret-up');
228 </script>
229 </body>
230 </html>