changing test for effective end date to include enddate which is NULL
[openemr.git] / sql_patch.php
blob45ef3f9dda0b4eb18aad20f4ec7c7e1ef2fd7368
1 <?php
2 // Copyright (C) 2008-2010 Rod Roark <rod@sunsetsystems.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.
8 //
9 // This may be run after an upgraded OpenEMR has been installed.
10 // Its purpose is to upgrade the MySQL OpenEMR database as needed
11 // for the new release.
13 // Disable PHP timeout. This will not work in safe mode.
14 ini_set('max_execution_time', '0');
16 $ignoreAuth = true; // no login required
18 require_once('interface/globals.php');
19 require_once('library/sql.inc');
20 require_once('library/sql_upgrade_fx.php');
21 require_once('version.php');
23 // Force logging off
24 $GLOBALS["enable_auditlog"]=0;
28 <html>
29 <head>
30 <title>OpenEMR Database Patch</title>
31 <link rel='STYLESHEET' href='interface/themes/style_blue.css'>
32 </head>
33 <body>
34 <center>
35 <span class='title'>OpenEMR Database Patch</span>
36 <br>
37 </center>
39 <?php
40 upgradeFromSqlFile('patch.sql');
41 flush();
43 echo "<font color='green'>Updating global configuration defaults...</font><br />\n";
44 require_once("library/globals.inc.php");
45 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
46 foreach ($grparr as $fldid => $fldarr) {
47 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
48 if (substr($fldtype, 0, 2) !== 'm_') {
49 $row = sqlQuery("SELECT count(*) AS count FROM globals WHERE gl_name = '$fldid'");
50 if (empty($row['count'])) {
51 sqlStatement("INSERT INTO globals ( gl_name, gl_index, gl_value ) " .
52 "VALUES ( '$fldid', '0', '$flddef' )");
58 echo "<font color='green'>Updating version indicators...</font><br />\n";
59 sqlStatement("UPDATE version SET v_realpatch = '$v_realpatch'");
61 echo "<p><font color='green'>Database patch finished.</font></p>\n";
62 echo "</body></html>\n";
63 exit();
67 </body>
68 </html>