Merge pull request #1108 from sjpadgett/lbf-nationnote-issue
[openemr.git] / patients / index.php
blob87388432a719d0727f71717823391221a73fe0fb
1 <?php
2 // Copyright (C) 2011 Cassian LUP <cassi.lup@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 //setting the session & other config options
10 session_start();
12 //don't require standard openemr authorization in globals.php
13 $ignoreAuth = 1;
15 //For redirect if the site on session does not match
16 $landingpage = "index.php?site=".$_GET['site'];
18 //includes
19 require_once('../interface/globals.php');
21 ini_set("error_log", E_ERROR || ~E_NOTICE);
22 //exit if portal is turned off
23 if (!(isset($GLOBALS['portal_onsite_enable'])) || !($GLOBALS['portal_onsite_enable'])) {
24 echo htmlspecialchars(xl('Patient Portal is turned off'), ENT_NOQUOTES);
25 exit;
28 // security measure -- will check on next page.
29 $_SESSION['itsme'] = 1;
33 // Deal with language selection
35 // collect default language id (skip this if this is a password update)
36 if (!(isset($_SESSION['password_update']))) {
37 $res2 = sqlStatement("select * from lang_languages where lang_description = ?", array($GLOBALS['language_default']));
38 for ($iter = 0; $row = sqlFetchArray($res2); $iter++) {
39 $result2[$iter] = $row;
42 if (count($result2) == 1) {
43 $defaultLangID = $result2[0]{"lang_id"};
44 $defaultLangName = $result2[0]{"lang_description"};
45 } else {
46 //default to english if any problems
47 $defaultLangID = 1;
48 $defaultLangName = "English";
51 // set session variable to default so login information appears in default language
52 $_SESSION['language_choice'] = $defaultLangID;
53 // collect languages if showing language menu
54 if ($GLOBALS['language_menu_login']) {
55 // sorting order of language titles depends on language translation options.
56 $mainLangID = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
57 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation'])) {
58 $sql = "SELECT * FROM lang_languages ORDER BY lang_description, lang_id";
59 $res3=SqlStatement($sql);
60 } else {
61 // Use and sort by the translated language name.
62 $sql = "SELECT ll.lang_id, " .
63 "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS trans_lang_description, " .
64 "ll.lang_description " .
65 "FROM lang_languages AS ll " .
66 "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
67 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
68 "ld.lang_id = ? " .
69 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
70 $res3=SqlStatement($sql, array($mainLangID));
73 for ($iter = 0; $row = sqlFetchArray($res3); $iter++) {
74 $result3[$iter] = $row;
77 if (count($result3) == 1) {
78 //default to english if only return one language
79 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='1' />\n";
81 } else {
82 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='".htmlspecialchars($defaultLangID, ENT_QUOTES)."' />\n";
88 <html>
89 <head>
90 <title><?php echo xlt('Patient Portal Login'); ?></title>
92 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
93 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery.gritter-1-7-4/js/jquery.gritter.min.js"></script>
95 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery.gritter-1-7-4/css/jquery.gritter.css" />
96 <link rel="stylesheet" type="text/css" href="css/base.css" />
98 <script type="text/javascript">
99 function process() {
101 if (!(validate())) {
102 alert ('<?php echo addslashes(xl('Field(s) are missing!')); ?>');
103 return false;
106 function validate() {
107 var pass=true;
108 if (document.getElementById('uname').value == "") {
109 document.getElementById('uname').style.border = "1px solid red";
110 pass=false;
112 if (document.getElementById('pass').value == "") {
113 document.getElementById('pass').style.border = "1px solid red";
114 pass=false;
116 return pass;
118 function process_new_pass() {
120 if (!(validate_new_pass())) {
121 alert ('<?php echo addslashes(xl('Field(s) are missing!')); ?>');
122 return false;
124 if (document.getElementById('pass_new').value != document.getElementById('pass_new_confirm').value) {
125 alert ('<?php echo addslashes(xl('The new password fields are not the same.')); ?>');
126 return false;
128 if (document.getElementById('pass').value == document.getElementById('pass_new').value) {
129 alert ('<?php echo addslashes(xl('The new password can not be the same as the current password.')); ?>');
130 return false;
134 function validate_new_pass() {
135 var pass=true;
136 if (document.getElementById('uname').value == "") {
137 document.getElementById('uname').style.border = "1px solid red";
138 pass=false;
140 if (document.getElementById('pass').value == "") {
141 document.getElementById('pass').style.border = "1px solid red";
142 pass=false;
144 if (document.getElementById('pass_new').value == "") {
145 document.getElementById('pass_new').style.border = "1px solid red";
146 pass=false;
148 if (document.getElementById('pass_new_confirm').value == "") {
149 document.getElementById('pass_new_confirm').style.border = "1px solid red";
150 pass=false;
152 return pass;
154 </script>
155 <style type="text/css">
156 body {
157 font-family: sans-serif;
158 background-color: #638fd0;
160 background: -webkit-radial-gradient(circle, white, #638fd0);
161 background: -moz-radial-gradient(circle, white, #638fd0);
164 </style>
167 </head>
168 <body>
169 <br><br>
170 <center>
172 <?php if (isset($_SESSION['password_update'])||isset($_GET['password_update'])) {
173 $_SESSION['password_update']=1;
175 <div id="wrapper" class="centerwrapper">
176 <h2 class="title"><?php echo htmlspecialchars(xl('Please Enter a New Password'), ENT_NOQUOTES); ?></h2>
177 <form action="get_patient_info.php" method="POST" onsubmit="return process_new_pass()" >
178 <table>
179 <tr>
180 <td class="algnRight"><?php echo htmlspecialchars(xl('User Name'), ENT_NOQUOTES); ?></td>
181 <td><input name="uname" id="uname" type="text" autocomplete="off" value="<?php echo attr($_SESSION['portal_username']); ?>"/></td>
182 </tr>
183 <tr>
184 <td class="algnRight"><?php echo htmlspecialchars(xl('Current Password'), ENT_NOQUOTES);?></>
185 <td>
186 <input name="pass" id="pass" type="password" autocomplete="off" />
187 </td>
188 </tr>
189 <tr>
190 <td class="algnRight"><?php echo htmlspecialchars(xl('New Password'), ENT_NOQUOTES);?></>
191 <td>
192 <input name="pass_new" id="pass_new" type="password" />
193 </td>
194 </tr>
195 <tr>
196 <td class="algnRight"><?php echo htmlspecialchars(xl('Confirm New Password'), ENT_NOQUOTES);?></>
197 <td>
198 <input name="pass_new_confirm" id="pass_new_confirm" type="password" />
199 </td>
200 </tr>
201 <tr>
202 <td colspan=2><br><center><input type="submit" value="<?php echo htmlspecialchars(xl('Log In'), ENT_QUOTES);?>" /></center></td>
203 </tr>
204 </table>
205 </form>
207 <div class="copyright"><?php echo htmlspecialchars(xl('Powered by'), ENT_NOQUOTES);?> OpenEMR</div>
208 </div>
209 <?php } else { ?>
210 <div id="wrapper" class="centerwrapper">
211 <h2 class="title"><?php echo htmlspecialchars(xl('Patient Portal Login'), ENT_NOQUOTES); ?></h2>
212 <form action="get_patient_info.php" method="POST" onsubmit="return process()" >
213 <table>
214 <tr>
215 <td class="algnRight"><?php echo htmlspecialchars(xl('User Name'), ENT_NOQUOTES); ?></td>
216 <td><input name="uname" id="uname" type="text" autocomplete="off" /></td>
217 </tr>
218 <tr>
219 <td class="algnRight"><?php echo htmlspecialchars(xl('Password'), ENT_NOQUOTES);?></>
220 <td>
221 <input name="pass" id="pass" type="password" autocomplete="off" />
222 </td>
223 </tr>
225 <?php if ($GLOBALS['language_menu_login']) { ?>
226 <?php if (count($result3) != 1) { ?>
227 <tr>
228 <td><span class="text"><?php echo htmlspecialchars(xl('Language'), ENT_NOQUOTES); ?></span></td>
229 <td>
230 <select name=languageChoice size="1">
231 <?php
232 echo "<option selected='selected' value='".htmlspecialchars($defaultLangID, ENT_QUOTES)."'>" . htmlspecialchars(xl('Default') . " - " . xl($defaultLangName), ENT_NOQUOTES) . "</option>\n";
233 foreach ($result3 as $iter) {
234 if ($GLOBALS['language_menu_showall']) {
235 if (!$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
236 continue; // skip the dummy language
239 echo "<option value='".htmlspecialchars($iter['lang_id'], ENT_QUOTES)."'>".htmlspecialchars($iter['trans_lang_description'], ENT_NOQUOTES)."</option>\n";
240 } else {
241 if (in_array($iter['lang_description'], $GLOBALS['language_menu_show'])) {
242 if (!$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
243 continue; // skip the dummy language
246 echo "<option value='".htmlspecialchars($iter['lang_id'], ENT_QUOTES)."'>".htmlspecialchars($iter['trans_lang_description'], ENT_NOQUOTES)."</option>\n";
251 </select>
252 </td>
253 </tr>
254 <?php }
255 } ?>
257 <tr>
258 <td colspan=2><br><center><input type="submit" value="<?php echo htmlspecialchars(xl('Log In'), ENT_QUOTES);?>" /></center></td>
259 </tr>
260 </table>
261 <?php if (!(empty($hiddenLanguageField))) {
262 echo $hiddenLanguageField;
263 } ?>
264 </form>
266 <div class="copyright"><?php echo htmlspecialchars(xl('Powered by'), ENT_NOQUOTES);?> OpenEMR</div>
267 </div>
268 <?php } ?>
270 </center>
272 <script type="text/javascript">
273 $(document).ready(function() {
275 <?php // if something went wrong
276 if (isset($_GET['w'])) { ?>
277 var unique_id = $.gritter.add({
278 title: '<span class="red"><?php echo htmlspecialchars(xl('Oops!'), ENT_QUOTES);?></span>',
279 text: '<?php echo htmlspecialchars(xl('Something went wrong. Please try again.', ENT_QUOTES)); ?>',
280 sticky: false,
281 time: '5000',
282 class_name: 'my-nonsticky-class'
283 });
284 <?php } ?>
286 <?php // if successfully logged out
287 if (isset($_GET['logout'])) { ?>
288 var unique_id = $.gritter.add({
289 title: '<span class="green"><?php echo htmlspecialchars(xl('Success'), ENT_QUOTES);?></span>',
290 text: '<?php echo htmlspecialchars(xl('You have been successfully logged out.'), ENT_QUOTES);?>',
291 sticky: false,
292 time: '5000',
293 class_name: 'my-nonsticky-class'
294 });
295 <?php } ?>
296 return false;
299 </script>
301 </body>
302 </html>