fixed error - Error saving job statuses
This commit is contained in:
parent
dc3ef2491a
commit
8ab8df671a
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
function get_current_user() {
|
||||
function getCurrentAppUser() {
|
||||
// In a real application, this would fetch the logged-in user from a session or token.
|
||||
// For now, we'll hardcode the admin user from the seeded data.
|
||||
// This assumes the admin user has company_id 1 (from the seed).
|
||||
@ -14,7 +14,7 @@ function get_current_user() {
|
||||
}
|
||||
|
||||
function get_current_company_id() {
|
||||
$user = get_current_user();
|
||||
$user = getCurrentAppUser();
|
||||
return $user ? $user['company_id'] : null;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ function get_company_onboarding_status($company_id) {
|
||||
}
|
||||
|
||||
function logActivity($job_id, $event_type, $field_name = null, $old_value = null, $new_value = null) {
|
||||
$user = get_current_user();
|
||||
$user = getCurrentAppUser();
|
||||
if (!$user) { return; } // Don't log if no user context
|
||||
$stmt = db()->prepare("INSERT INTO activity_logs (job_id, company_id, user_id, user_name, event_type, field_name, old_value, new_value) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
require_once 'includes/helpers.php';
|
||||
|
||||
// Get current user and company ID
|
||||
$user = get_current_user();
|
||||
$user = getCurrentAppUser();
|
||||
|
||||
// If no user or company ID, redirect to a login/error page (to be implemented later)
|
||||
if (!$user || !($company_id = get_current_company_id())) {
|
||||
@ -73,7 +73,7 @@ $clients = getClients($company_id);
|
||||
<div class="container">
|
||||
<a class="navbar-brand fw-bold" href="index.php">Repairs Pro</a>
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="me-3 text-secondary"><?php echo htmlspecialchars($user['name']); ?></span>
|
||||
<span class="me-3 text-secondary"><?php echo htmlspecialchars($user['name'] ?? ''); ?></span>
|
||||
<button class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#createJobModal">New Job</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once 'includes/helpers.php';
|
||||
$user = get_current_user();
|
||||
$user = getCurrentAppUser();
|
||||
$company_id = get_current_company_id();
|
||||
$job_id = $_GET['id'] ?? null;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ require_once __DIR__ . '/includes/helpers.php';
|
||||
|
||||
// Placeholder for company ID - in a real app, this would come from the session after login
|
||||
$company_id = get_current_company_id();
|
||||
$current_user = get_current_user();
|
||||
$current_user = getCurrentAppUser();
|
||||
|
||||
if (!$company_id) {
|
||||
// Redirect to login or error page if no company is identified
|
||||
@ -45,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
$insert_stmt = $pdo->prepare("INSERT INTO job_statuses (company_id, name, is_default) VALUES (?, ?, ?)");
|
||||
foreach ($statuses as $index => $status_name) {
|
||||
$is_default = ($index == $default_status_index);
|
||||
$is_default = (int)($index == $default_status_index); // Explicitly cast to int (0 or 1)
|
||||
$insert_stmt->execute([$company_id, $status_name, $is_default]);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user