Skip to content

Commit

Permalink
updated major app components and resource views
Browse files Browse the repository at this point in the history
  • Loading branch information
MIKEINTOSHSYSTEMS committed Aug 22, 2024
1 parent b184bae commit 7f82c07
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 172 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ RUN apt-get update && \
intl \
pdo_mysql \
pdo_pgsql \
pgsql \
pdo_sqlite \
soap \
zip \
Expand Down
37 changes: 31 additions & 6 deletions api/database/restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
37 changes: 31 additions & 6 deletions api/database/restores.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
50 changes: 25 additions & 25 deletions app/include/appsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
;


;

Expand Down
69 changes: 30 additions & 39 deletions app/include/custom_functions.js
Original file line number Diff line number Diff line change
@@ -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"))) {
Expand All @@ -55,6 +49,3 @@ $("document").ready(function() {
originalInit.call(this);
}
});

// Place event code here.
// Use "Add Action" button to add code snippets.
5 changes: 5 additions & 0 deletions app/include/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>

<br>
<!--

<div class="calendar-container" align="center">
<div class="ethiopian-calendar">
<h4>ዛሬ ቀኑ</h4>
Expand All @@ -27,6 +29,9 @@
</div>


-->


<br>
<br>
<div align="center">
Expand Down
7 changes: 7 additions & 0 deletions app/include/lookuplinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@ function InitLookupLinks()
$lookupTableLinks["public.mfr_region"]["mfr_region_chart.region"] = array();
}
$lookupTableLinks["public.mfr_region"]["mfr_region_chart.region"]["search"] = array("table" => "mfr_region_chart", "field" => "region", "page" => "search");
if( !isset( $lookupTableLinks["public.mfr_facilities_register"] ) ) {
$lookupTableLinks["public.mfr_facilities_register"] = array();
}
if( !isset( $lookupTableLinks["public.mfr_facilities_register"]["moh_health_facilities.facility_name"] )) {
$lookupTableLinks["public.mfr_facilities_register"]["moh_health_facilities.facility_name"] = array();
}
$lookupTableLinks["public.mfr_facilities_register"]["moh_health_facilities.facility_name"]["edit"] = array("table" => "public.moh_health_facilities", "field" => "facility_name", "page" => "edit");
if( !isset( $lookupTableLinks["public.moh_facility_types"] ) ) {
$lookupTableLinks["public.moh_facility_types"] = array();
}
Expand Down
Loading

0 comments on commit 7f82c07

Please sign in to comment.