diff --git a/.gitignore b/.gitignore
index d982b65d..6280a9a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,6 @@
/app/templates_c/*.txt
/app/templates_c/*.doc
/app/templates_c/*.docx
+/mysql-int/hispmd_dev.sql
+/src/hispmddb/
+/src/*.sql
diff --git a/Dockerfile b/Dockerfile
index 23ff47b2..70a0a6e8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -55,6 +55,7 @@ RUN apt-get update && \
intl \
pdo_mysql \
pdo_pgsql \
+ pgsql \
pdo_sqlite \
soap \
zip \
diff --git a/api/database/restore.php b/api/database/restore.php
index 64a4e0dd..03e2cf27 100644
--- a/api/database/restore.php
+++ b/api/database/restore.php
@@ -26,13 +26,38 @@
exit;
}
-// Command to execute pg_restore inside the Docker container
-$command = "docker exec -i $containerName sh -c \"PGPASSWORD='$dbPassword' pg_restore -h $dbHost -U $dbUser -d $dbName -v /tmp/$backupFile\" < $backupFilePath";
+// Check if the database exists
+$checkDbCommand = "docker exec -i $containerName sh -c \"PGPASSWORD='$dbPassword' psql -h $dbHost -U $dbUser -tAc 'SELECT 1 FROM pg_database WHERE datname = \"$dbName\"'\"";
+exec($checkDbCommand, $output, $return_var);
-// Execute the command
-$output = [];
-$return_var = 0;
-exec($command . ' 2>&1', $output, $return_var);
+$databaseExists = trim(implode("\n", $output)) === '1';
+
+
+// Drop all tables and other objects in the public schema
+$dropAllCommand = "docker exec -i $containerName sh -c \"PGPASSWORD='$dbPassword' psql -h $dbHost -U $dbUser -d $dbName -c 'DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public;'\"";
+exec($dropAllCommand . ' 2>&1', $output, $return_var);
+
+if ($return_var !== 0) {
+ echo "Error dropping schema. Details:\n";
+ echo implode("\n", $output);
+ exit;
+}
+
+
+
+// Copy the backup file to the Docker container
+$copyBackupCommand = "docker cp $backupFilePath $containerName:/tmp/$backupFile";
+exec($copyBackupCommand . ' 2>&1', $output, $return_var);
+
+if ($return_var !== 0) {
+ echo "Error copying backup file to Docker container. Details:\n";
+ echo implode("\n", $output);
+ exit;
+}
+
+// Restore the backup
+$restoreCommand = "docker exec -i $containerName sh -c \"PGPASSWORD='$dbPassword' pg_restore -h $dbHost -U $dbUser -d $dbName -v /tmp/$backupFile\"";
+exec($restoreCommand . ' 2>&1', $output, $return_var);
if ($return_var === 0) {
echo "Backup successfully restored: $backupFilePath";
diff --git a/api/database/restores.php b/api/database/restores.php
index 74619c09..5ba19663 100644
--- a/api/database/restores.php
+++ b/api/database/restores.php
@@ -26,13 +26,38 @@
exit;
}
-// Command to execute pg_restore inside the Docker container
-$command = "docker exec -i $containerName sh -c \"PGPASSWORD='$dbPassword' pg_restore -h $dbHost -U $dbUser -d $dbName -v /tmp/$backupFile\" < $backupFilePath";
+// Check if the database exists
+$checkDbCommand = "docker exec -i $containerName sh -c \"PGPASSWORD='$dbPassword' psql -h $dbHost -U $dbUser -tAc 'SELECT 1 FROM pg_database WHERE datname = \"$dbName\"'\"";
+exec($checkDbCommand, $output, $return_var);
-// Execute the command
-$output = [];
-$return_var = 0;
-exec($command . ' 2>&1', $output, $return_var);
+$databaseExists = trim(implode("\n", $output)) === '1';
+
+
+// Drop all tables and other objects in the public schema
+$dropAllCommand = "docker exec -i $containerName sh -c \"PGPASSWORD='$dbPassword' psql -h $dbHost -U $dbUser -d $dbName -c 'DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public;'\"";
+exec($dropAllCommand . ' 2>&1', $output, $return_var);
+
+if ($return_var !== 0) {
+ echo "Error dropping schema. Details:\n";
+ echo implode("\n", $output);
+ exit;
+}
+
+
+
+// Copy the backup file to the Docker container
+$copyBackupCommand = "docker cp $backupFilePath $containerName:/tmp/$backupFile";
+exec($copyBackupCommand . ' 2>&1', $output, $return_var);
+
+if ($return_var !== 0) {
+ echo "Error copying backup file to Docker container. Details:\n";
+ echo implode("\n", $output);
+ exit;
+}
+
+// Restore the backup
+$restoreCommand = "docker exec -i $containerName sh -c \"PGPASSWORD='$dbPassword' pg_restore -h $dbHost -U $dbUser -d $dbName -v /tmp/$backupFile\"";
+exec($restoreCommand . ' 2>&1', $output, $return_var);
if ($return_var === 0) {
echo "Backup successfully restored: $backupFilePath";
diff --git a/app/include/appsettings.php b/app/include/appsettings.php
index 20e1c084..d8610676 100644
--- a/app/include/appsettings.php
+++ b/app/include/appsettings.php
@@ -740,9 +740,9 @@
$strLastSQL = "";
$showCustomMarkerOnPrint = false;
-$projectBuildKey = "511_1724336618";
+$projectBuildKey = "515_1724336618";
$wizardBuildKey = "39558";
-$projectBuildNumber = "511";
+$projectBuildNumber = "515";
$mlang_messages = array();
$mlang_charsets = array();
@@ -958,39 +958,39 @@
// here goes EVENT_INIT_APP event
-
-//********** Insert a record into another table ************
-
+//********** Insert a record into another table ************
+
// here goes EVENT_INIT_APP event
-$currentDateTimeForDb = localdatetime2db( runner_date_format("m-d-y H:i:s") );
+$currentDateTimeForDb = localdatetime2db(runner_date_format("m-d-y H:i:s"));
+
// receiving AJAX request with the new page URL
// in timetracker table we create a new record
// and return the TrackerID value of the new record
-if( postvalue("pageOpen") != false ){
- $data = array();
- $data["pagename"] = postvalue("pageName");
- $data["timeon"] = $currentDateTimeForDb;
- $data["userID"] = Security::getUserName();
- if(postvalue("recordID") != false){
- $data["recordID"] = postvalue("recordID");
- }
- DB::Insert("timetracker", $data);
- //return TrackerID
- echo DB::LastId();
- exit();
-
+if (postvalue("pageOpen") != false) {
+ $data = array();
+ $data["pagename"] = postvalue("pageName");
+ $data["timeon"] = $currentDateTimeForDb;
+ $data["userid"] = Security::getUserName(); // Changed to userid
+ if (postvalue("recordID") != false) {
+ $data["recordid"] = postvalue("recordID"); // Changed to recordid
+ }
+ DB::Insert("timetracker", $data);
+ //return TrackerID
+ echo DB::LastId();
+ exit();
}
-// receiving AJAX request that tell us we are still on the same pageпродолжается
+
+// receiving AJAX request that tells us we are still on the same page
// we just update the value of timeoff field for the current TrackerID
-if( postvalue("TrackerID") !=false ){
- $now_datetime = $currentDateTimeForDb;
- DB::Update("timetracker",array("timeoff"=> $now_datetime ),array("trackerId" => postvalue("TrackerID") ));
- exit();
+if (postvalue("TrackerID") != false) {
+ $now_datetime = $currentDateTimeForDb;
+ DB::Update("timetracker", array("timeoff" => $now_datetime), array("trackerid" => postvalue("TrackerID")));
+ exit();
}
// Place event code here.
// Use "Add Action" button to add code snippets.
-;
+
;
diff --git a/app/include/custom_functions.js b/app/include/custom_functions.js
index e3426c6d..979a100a 100644
--- a/app/include/custom_functions.js
+++ b/app/include/custom_functions.js
@@ -1,51 +1,45 @@
-$("document").ready(function() {
+$("document").ready(function () {
Runner.customEvents = [];
- // every notifyInterval seconds we execute an AJAX requests that tells the server that user is still ont he page
var notifyInterval = 5;
- // this function is executed on every page load, here we tell the server what page the user currently on
-
function setPageTimer(pageObj) {
- // ajax- parameters with the page URL
- var notify_params = { pageOpen: 1, pageName: Runner.pages.getUrl(pageObj.shortTName,pageObj.pageType) };
- // if this is an Edit/View page we also pass an ID of the record
- if (pageObj.pageType === "edit" || pageObj.pageType === "view") notify_params.recordID = pageObj.keys[0];
- // we send AJAX request and get back trackerId value of the current log table recod
- $.get("", notify_params, function(TrackerID) {
- // send AJAX request with the current notifyInterval value, that tells the server the user is still on the page
- interval = setInterval(function() {
- $.get("", { TrackerID: TrackerID });
- }, notifyInterval * 1000);
+ var notify_params = { pageOpen: 1, pageName: Runner.pages.getUrl(pageObj.shortTName, pageObj.pageType) };
+
+ if (pageObj.pageType === "edit" || pageObj.pageType === "view") {
+ notify_params.recordID = pageObj.keys[0];
+ }
+
+ $.get("", notify_params, function (TrackerID) {
+ if (TrackerID) {
+ interval = setInterval(function () {
+ $.get("", { TrackerID: TrackerID });
+ }, notifyInterval * 1000);
+ }
});
}
var originalInit = Runner.pages.RunnerPage.prototype.init;
-
- Runner.pages.RunnerPage.prototype.init = function() {
+
+ Runner.pages.RunnerPage.prototype.init = function () {
var pageObj = this;
var isTab = typeof this.tabControl !== "undefined";
- // check if the current page a details tab
- if (isTab) {
-
- if (!Runner.customEvents.includes(this.tName + "_" + this.pageType)) {
- Runner.customEvents.push(this.tName + "_" + this.pageType);
- pageObj.on("afterPageReady", function() {
- // when tab is closed we clear the interval counter
- pageObj.tabControl.off("hide.bs.tab").on("hide.bs.tab", function(e) {
- clearInterval(interval);
- });
- // when details tab is open we start the counter
- pageObj.tabControl.off("show.bs.tab").on("show.bs.tab", function(e) {
- var activeTab = $(e.target);
- var panelContent = activeTab.parents("ul").next();
- var activePanel = panelContent.find(".tab-pane.active");
-
- setPageTimer(Runner.pages.PageManager.getById(activePanel.find(".r-form").attr("data-pageid")));
+ if (isTab) {
+ if (!Runner.customEvents.includes(this.tName + "_" + this.pageType)) {
+ Runner.customEvents.push(this.tName + "_" + this.pageType);
+ pageObj.on("afterPageReady", function () {
+ pageObj.tabControl.off("hide.bs.tab").on("hide.bs.tab", function (e) {
+ clearInterval(interval);
+ });
+ pageObj.tabControl.off("show.bs.tab").on("show.bs.tab", function (e) {
+ var activeTab = $(e.target);
+ var panelContent = activeTab.parents("ul").next();
+ var activePanel = panelContent.find(".tab-pane.active");
+
+ setPageTimer(Runner.pages.PageManager.getById(activePanel.find(".r-form").attr("data-pageid")));
+ });
});
- });
- }
-
+ }
}
if (!isTab || (isTab && this.$panel.parents(".tab-pane").hasClass("active"))) {
@@ -55,6 +49,3 @@ $("document").ready(function() {
originalInit.call(this);
}
});
-
-// Place event code here.
-// Use "Add Action" button to add code snippets.
\ No newline at end of file
diff --git a/app/include/footer.php b/app/include/footer.php
index 6bd438bb..6692e237 100644
--- a/app/include/footer.php
+++ b/app/include/footer.php
@@ -7,6 +7,8 @@
+
+
+