update services

This commit is contained in:
Flatlogic Bot 2026-03-03 16:57:49 +00:00
parent f49527d7c4
commit a251e37178
6 changed files with 50 additions and 22 deletions

View File

@ -1,5 +1,6 @@
<?php
// Generated by setup_mariadb_project.sh — edit as needed.
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_38384');
define('DB_USER', 'app_38384');
@ -25,22 +26,26 @@ function check_permission($page = null, $user_id = null) {
$cache_key = $user_id . '_' . $page;
if (isset($permissions_cache[$cache_key])) return $permissions_cache[$cache_key];
$stmt = db()->prepare("SELECT can_view as view, can_add as `add`, can_edit as edit, can_delete as `delete` FROM user_permissions WHERE user_id = ? AND page = ?");
$stmt->execute([$user_id, $page]);
$perms = $stmt->fetch();
try {
$stmt = db()->prepare("SELECT can_view as view, can_add as `add`, can_edit as edit, can_delete as `delete` FROM user_permissions WHERE user_id = ? AND page = ?");
$stmt->execute([$user_id, $page]);
$perms = $stmt->fetch();
if (!$perms) {
if (!$perms) {
return ['view' => 0, 'add' => 0, 'edit' => 0, 'delete' => 0];
}
$result = [
'view' => (int)$perms['view'],
'add' => (int)$perms['add'],
'edit' => (int)$perms['edit'],
'delete' => (int)$perms['delete']
];
$permissions_cache[$cache_key] = $result;
return $result;
} catch (Exception $e) {
return ['view' => 0, 'add' => 0, 'edit' => 0, 'delete' => 0];
}
$result = [
'view' => (int)$perms['view'],
'add' => (int)$perms['add'],
'edit' => (int)$perms['edit'],
'delete' => (int)$perms['delete']
];
$permissions_cache[$cache_key] = $result;
return $result;
}
function get_setting($key, $default = null) {

View File

@ -1,5 +1,28 @@
<?php
session_start();
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
function load_dotenv_lang(): void {
static $loaded = false;
if ($loaded) return;
$envPath = realpath(__DIR__ . '/../../.env'); // executor/.env
if ($envPath && is_readable($envPath)) {
$lines = @file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: [];
foreach ($lines as $line) {
if ($line[0] === '#' || trim($line) === '') continue;
if (!str_contains($line, '=')) continue;
[$k, $v] = array_map('trim', explode('=', $line, 2));
$v = trim($v, "' ");
if ($k !== '' && (getenv($k) === false || getenv($k) === '')) {
putenv("{$k}={$v}");
}
}
$loaded = true;
}
}
load_dotenv_lang();
$lang = $_SESSION['lang'] ?? 'en';
if (isset($_GET['lang'])) {
@ -491,4 +514,4 @@ function branch_url($new_branch_id) {
$params = $_GET;
$params['switch_branch'] = $new_branch_id;
return '?' . http_build_query($params);
}
}

View File

@ -954,4 +954,4 @@ document.getElementById('itemImageFile').addEventListener('change', function(e)
});
</script>
<?php require_once __DIR__ . '/includes/footer.php'; ?>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

View File

@ -333,7 +333,7 @@ document.addEventListener('DOMContentLoaded', () => {
</style>
<?php
function getStatusColor($status) {
if (!function_exists('getStatusColor')) { function getStatusColor($status) {
return [
'received' => 'secondary',
'processing' => 'primary',
@ -341,6 +341,6 @@ function getStatusColor($status) {
'delivered' => 'dark',
'cancelled' => 'danger',
][$status] ?? 'info';
}
}}
require_once __DIR__ . '/includes/footer.php';
?>

View File

@ -277,7 +277,7 @@ $payments = $stmt->fetchAll();
</div>
<?php
function getStatusColor($status) {
if (!function_exists('getStatusColor')) { function getStatusColor($status) {
return [
'received' => 'secondary',
'processing' => 'primary',
@ -285,7 +285,7 @@ function getStatusColor($status) {
'delivered' => 'dark',
'cancelled' => 'danger',
][$status] ?? 'info';
}
}}
function getPaymentStatusColor($status) {
return [
'unpaid' => 'danger',

View File

@ -336,7 +336,7 @@ document.addEventListener('DOMContentLoaded', () => {
</style>
<?php
function getStatusColor($status) {
if (!function_exists('getStatusColor')) { function getStatusColor($status) {
return [
'received' => 'secondary',
'processing' => 'primary',
@ -344,7 +344,7 @@ function getStatusColor($status) {
'delivered' => 'dark',
'cancelled' => 'danger',
][$status] ?? 'info';
}
}}
function getPaymentStatusColor($status) {
return [
'unpaid' => 'danger',