bug fix for inventory module destroyed menu link - reported by Nzube
[openemr.git] / patients / index.php
blob44c16667e2a59156a161aa911efb172a9aadf939
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;
41 if (count($result2) == 1) {
42 $defaultLangID = $result2[0]{"lang_id"};
43 $defaultLangName = $result2[0]{"lang_description"};
45 else {
46 //default to english if any problems
47 $defaultLangID = 1;
48 $defaultLangName = "English";
50 // set session variable to default so login information appears in default language
51 $_SESSION['language_choice'] = $defaultLangID;
52 // collect languages if showing language menu
53 if ($GLOBALS['language_menu_login']) {
54 // sorting order of language titles depends on language translation options.
55 $mainLangID = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
56 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation'])) {
57 $sql = "SELECT * FROM lang_languages ORDER BY lang_description, lang_id";
58 $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) );
72 for ($iter = 0;$row = sqlFetchArray($res3);$iter++) {
73 $result3[$iter] = $row;
75 if (count($result3) == 1) {
76 //default to english if only return one language
77 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='1' />\n";
80 else {
81 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='".htmlspecialchars($defaultLangID,ENT_QUOTES)."' />\n";
87 <html>
88 <head>
89 <title><?php echo xlt('Patient Portal Login'); ?></title>
91 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
92 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery.gritter-1-7-4/js/jquery.gritter.min.js"></script>
94 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery.gritter-1-7-4/css/jquery.gritter.css" />
95 <link rel="stylesheet" type="text/css" href="css/base.css" />
97 <script type="text/javascript">
98 function process() {
100 if (!(validate())) {
101 alert ('<?php echo addslashes( xl('Field(s) are missing!') ); ?>');
102 return false;
105 function validate() {
106 var pass=true;
107 if (document.getElementById('uname').value == "") {
108 document.getElementById('uname').style.border = "1px solid red";
109 pass=false;
111 if (document.getElementById('pass').value == "") {
112 document.getElementById('pass').style.border = "1px solid red";
113 pass=false;
115 return pass;
117 function process_new_pass() {
119 if (!(validate_new_pass())) {
120 alert ('<?php echo addslashes( xl('Field(s) are missing!') ); ?>');
121 return false;
123 if (document.getElementById('pass_new').value != document.getElementById('pass_new_confirm').value) {
124 alert ('<?php echo addslashes( xl('The new password fields are not the same.') ); ?>');
125 return false;
127 if (document.getElementById('pass').value == document.getElementById('pass_new').value) {
128 alert ('<?php echo addslashes( xl('The new password can not be the same as the current password.') ); ?>');
129 return false;
133 function validate_new_pass() {
134 var pass=true;
135 if (document.getElementById('uname').value == "") {
136 document.getElementById('uname').style.border = "1px solid red";
137 pass=false;
139 if (document.getElementById('pass').value == "") {
140 document.getElementById('pass').style.border = "1px solid red";
141 pass=false;
143 if (document.getElementById('pass_new').value == "") {
144 document.getElementById('pass_new').style.border = "1px solid red";
145 pass=false;
147 if (document.getElementById('pass_new_confirm').value == "") {
148 document.getElementById('pass_new_confirm').style.border = "1px solid red";
149 pass=false;
151 return pass;
153 </script>
154 <style type="text/css">
155 body {
156 font-family: sans-serif;
157 background-color: #638fd0;
159 background: -webkit-radial-gradient(circle, white, #638fd0);
160 background: -moz-radial-gradient(circle, white, #638fd0);
163 </style>
166 </head>
167 <body>
168 <br><br>
169 <center>
171 <?php if (isset($_SESSION['password_update'])||isset($_GET['password_update'])) {
172 $_SESSION['password_update']=1;
174 <div id="wrapper" class="centerwrapper">
175 <h2 class="title"><?php echo htmlspecialchars( xl('Please Enter a New Password'), ENT_NOQUOTES); ?></h2>
176 <form action="get_patient_info.php" method="POST" onsubmit="return process_new_pass()" >
177 <table>
178 <tr>
179 <td class="algnRight"><?php echo htmlspecialchars( xl('User Name'), ENT_NOQUOTES); ?></td>
180 <td><input name="uname" id="uname" type="text" autocomplete="off" value="<?php echo attr($_SESSION['portal_username']); ?>"/></td>
181 </tr>
182 <tr>
183 <td class="algnRight"><?php echo htmlspecialchars( xl('Current Password'), ENT_NOQUOTES);?></>
184 <td>
185 <input name="pass" id="pass" type="password" autocomplete="off" />
186 </td>
187 </tr>
188 <tr>
189 <td class="algnRight"><?php echo htmlspecialchars( xl('New Password'), ENT_NOQUOTES);?></>
190 <td>
191 <input name="pass_new" id="pass_new" type="password" />
192 </td>
193 </tr>
194 <tr>
195 <td class="algnRight"><?php echo htmlspecialchars( xl('Confirm New Password'), ENT_NOQUOTES);?></>
196 <td>
197 <input name="pass_new_confirm" id="pass_new_confirm" type="password" />
198 </td>
199 </tr>
200 <tr>
201 <td colspan=2><br><center><input type="submit" value="<?php echo htmlspecialchars( xl('Log In'), ENT_QUOTES);?>" /></center></td>
202 </tr>
203 </table>
204 </form>
206 <div class="copyright"><?php echo htmlspecialchars( xl('Powered by'), ENT_NOQUOTES);?> OpenEMR</div>
207 </div>
208 <?php } else { ?>
209 <div id="wrapper" class="centerwrapper">
210 <h2 class="title"><?php echo htmlspecialchars( xl('Patient Portal Login'), ENT_NOQUOTES); ?></h2>
211 <form action="get_patient_info.php" method="POST" onsubmit="return process()" >
212 <table>
213 <tr>
214 <td class="algnRight"><?php echo htmlspecialchars( xl('User Name'), ENT_NOQUOTES); ?></td>
215 <td><input name="uname" id="uname" type="text" autocomplete="off" /></td>
216 </tr>
217 <tr>
218 <td class="algnRight"><?php echo htmlspecialchars( xl('Password'), ENT_NOQUOTES);?></>
219 <td>
220 <input name="pass" id="pass" type="password" autocomplete="off" />
221 </td>
222 </tr>
224 <?php if ($GLOBALS['language_menu_login']) { ?>
225 <?php if (count($result3) != 1) { ?>
226 <tr>
227 <td><span class="text"><?php echo htmlspecialchars( xl('Language'), ENT_NOQUOTES); ?></span></td>
228 <td>
229 <select name=languageChoice size="1">
230 <?php
231 echo "<option selected='selected' value='".htmlspecialchars($defaultLangID,ENT_QUOTES)."'>" . htmlspecialchars( xl('Default') . " - " . xl($defaultLangName), ENT_NOQUOTES) . "</option>\n";
232 foreach ($result3 as $iter) {
233 if ($GLOBALS['language_menu_showall']) {
234 if ( !$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') continue; // skip the dummy language
235 echo "<option value='".htmlspecialchars($iter['lang_id'],ENT_QUOTES)."'>".htmlspecialchars($iter['trans_lang_description'],ENT_NOQUOTES)."</option>\n";
237 else {
238 if (in_array($iter['lang_description'], $GLOBALS['language_menu_show'])) {
239 if ( !$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') continue; // skip the dummy language
240 echo "<option value='".htmlspecialchars($iter['lang_id'],ENT_QUOTES)."'>".htmlspecialchars($iter['trans_lang_description'],ENT_NOQUOTES)."</option>\n";
245 </select>
246 </td>
247 </tr>
248 <?php }} ?>
250 <tr>
251 <td colspan=2><br><center><input type="submit" value="<?php echo htmlspecialchars( xl('Log In'), ENT_QUOTES);?>" /></center></td>
252 </tr>
253 </table>
254 <?php if (!(empty($hiddenLanguageField))) echo $hiddenLanguageField; ?>
255 </form>
257 <div class="copyright"><?php echo htmlspecialchars( xl('Powered by'), ENT_NOQUOTES);?> OpenEMR</div>
258 </div>
259 <?php } ?>
261 </center>
263 <script type="text/javascript">
264 $(document).ready(function() {
266 <?php // if something went wrong
267 if (isset($_GET['w'])) { ?>
268 var unique_id = $.gritter.add({
269 title: '<span class="red"><?php echo htmlspecialchars( xl('Oops!'), ENT_QUOTES);?></span>',
270 text: '<?php echo htmlspecialchars( xl('Something went wrong. Please try again.', ENT_QUOTES)); ?>',
271 sticky: false,
272 time: '5000',
273 class_name: 'my-nonsticky-class'
274 });
275 <?php } ?>
277 <?php // if successfully logged out
278 if (isset($_GET['logout'])) { ?>
279 var unique_id = $.gritter.add({
280 title: '<span class="green"><?php echo htmlspecialchars( xl('Success'), ENT_QUOTES);?></span>',
281 text: '<?php echo htmlspecialchars( xl('You have been successfully logged out.'), ENT_QUOTES);?>',
282 sticky: false,
283 time: '5000',
284 class_name: 'my-nonsticky-class'
285 });
286 <?php } ?>
287 return false;
290 </script>
292 </body>
293 </html>