Fix calendar week translation (#440)
[openemr.git] / sql_patch.php
blob0d2bb6a13356053540d96331b9d461e07584fedb
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_upgrade_fx.php');
21 $versionService = new \services\VersionService();
23 // Fetching current version because it was updated by the sql_upgrade_fx
24 // script and this script will further modify it.
25 $currentVersion = $versionService->fetch();
27 $desiredVersion = $currentVersion;
28 $desiredVersion->setDatabase($v_database);
29 $desiredVersion->setTag($v_tag);
30 $desiredVersion->setRealPatch($v_realpatch);
31 $desiredVersion->setPatch($v_patch);
32 $desiredVersion->setMinor($v_minor);
33 $desiredVersion->setMajor($v_major);
35 // Force logging off
36 $GLOBALS["enable_auditlog"]=0;
38 $EMRversion = trim(preg_replace('/\s*\([^)]*\)/', '', $GLOBALS['openemr_version']));
42 <html>
43 <head>
44 <title>OpenEMR <?php echo attr($EMRversion) ?> <?php echo xlt('Database Patch'); ?></title>
45 <link rel='STYLESHEET' href='interface/themes/style_blue.css'>
46 <link rel="shortcut icon" href="public/images/favicon.ico" />
47 </head>
48 <body style="color:green;">
49 <div style="box-shadow: 3px 3px 5px 6px #ccc; border-radius: 20px; padding: 10px 40px;background-color:#EFEFEF; width:500px; margin:40px auto">
51 <p style="font-weight:bold; font-size:1.8em; text-align:center">OpenEMR <?php echo text($EMRversion),' ',xlt('Database Patch'),' ',text($desiredVersion->getRealPatch()) ?></p>
52 <p style="font-weight:bold; text-align:center;"><?php echo xlt('Applying Patch to site'),' : ',text($_SESSION['site_id']) ?></p>
55 <?php
56 upgradeFromSqlFile('patch.sql');
57 flush();
59 echo '<p style="font-weight:bold; text-align:left; color:green">',xlt('Updating global configuration defaults'),'...</p>';
60 require_once("library/globals.inc.php");
61 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
62 foreach ($grparr as $fldid => $fldarr) {
63 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
64 if (substr($fldtype, 0, 2) !== 'm_') {
65 $row = sqlQuery("SELECT count(*) AS count FROM globals WHERE gl_name = '$fldid'");
66 if (empty($row['count'])) {
67 sqlStatement("INSERT INTO globals ( gl_name, gl_index, gl_value ) " .
68 "VALUES ( '$fldid', '0', '$flddef' )");
74 $canRealPatchBeApplied = $versionService->canRealPatchBeApplied($desiredVersion);
75 if ($canRealPatchBeApplied) {
76 echo '<p style="font-weight:bold; text-align:left;">',xlt('Updating version indicators'),'...</p>';
77 $result = $versionService->update($desiredVersion);
79 if (!$result) {
80 echo '<p style="font-weight:bold; text-align:left; color:red">',xlt('Unable insert version information into database'),'...</p>';
84 echo '<p style="text-align:center; font-size:1.8em;">',xlt('Database Patch'),' ',text($desiredVersion->getRealPatch()),' ',xlt('finished'),'.</p>';
86 echo '<p style="text-align:center; font-size:1.8em;">OpenEMR ',xlt('Version'),' = ',text($EMRversion.'('.$desiredVersion->getRealPatch().')'),'.</p>';
88 echo '<p><a style="border-radius: 10px; padding:5px; width:200px; margin:0 auto; background-color:green; color:white; font-weight:bold; display:block; text-align:center;" href="index.php?site=',attr($_SESSION['site_id']).'">',xlt('Log in'),'</a></p>';
90 if(isset($_SERVER['HTTP_REFERER'])) {
91 $split = preg_split('/\//',$_SERVER['HTTP_REFERER']);
92 if($split[count($split) - 1] == 'admin.php')
93 echo '<p><a style="border-radius: 10px; padding:5px; width:200px; margin:0 auto; background-color:green; color:white; font-weight:bold; display:block; text-align:center;" href="admin.php">',xlt('Back to Admin Page'),'</a></p>';
97 </div>
98 </body>
99 </html>