Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions client/agreement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
session_start();
define('WDS_SYSTEM', true);
require_once __DIR__ . '/../includes/portal-helpers.php';

portalRequireLogin();
if (portalGetRole() !== 'client') {
header('Location: /dashboard.php');
exit;
}

$user = portalGetUser();
$username = (string)($user['username'] ?? '');
$agreementId = trim((string)($_GET['agreement_id'] ?? ''));

$agreement = null;
$clientRequestIds = [];
foreach (portalLoadProjectRequests() as $request) {
if ((string)($request['client_username'] ?? '') === $username) {
$clientRequestIds[] = portalGetRequestDisplayId((array)$request);
}
}

foreach (portalLoadProjectAgreements() as $row) {
if ((string)($row['agreement_id'] ?? '') !== $agreementId) {
continue;
}
if ((string)($row['client_username'] ?? '') === $username || in_array((string)($row['request_id'] ?? ''), $clientRequestIds, true)) {
$agreement = $row;
break;
}
}

if ($agreement === null) {
http_response_code(404);
}

$current_page = 'client-portal';
$header_class = 'inner-header';
?>
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Project Agreement | Client Portal</title><link href="../assets/css/coreloop.css" rel="stylesheet">
<style>.wrap{padding:30px 0 70px;}.card{background:#0c1729;border:1px solid rgba(54,243,255,.18);border-radius:10px;padding:16px;} .lbl{color:#5a7a9e;font-size:.72rem;text-transform:uppercase;} .val{color:#eaf3ff;font-size:.86rem;white-space:pre-wrap;} .mono{font-family:monospace;color:#ffc600;}</style></head>
<body>
<?php include __DIR__ . '/../includes/header.php'; ?>
<?php include __DIR__ . '/../includes/navigation.php'; ?>
<section class="wrap"><div class="container"><a href="/client/contracts.php" style="color:#36f3ff;font-size:.84rem;">← Back to project agreements</a><div class="card" style="margin-top:10px;">
<?php if ($agreement === null): ?><p style="color:#fecaca;">Project agreement not found.</p><?php else: ?>
<h2 style="margin:0 0 10px;color:#ffc600;font-size:1.1rem;">Project Agreement</h2>
<div class="lbl">Agreement ID</div><div class="val mono"><?php echo pe($agreement['agreement_id'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Request ID</div><div class="val mono"><?php echo pe($agreement['request_id'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Proposal ID</div><div class="val mono"><?php echo pe($agreement['proposal_id'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Project Title</div><div class="val"><?php echo pe($agreement['project_title'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Scope Of Work</div><div class="val"><?php echo pe($agreement['scope_of_work'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Deliverables</div><div class="val"><?php echo pe($agreement['deliverables'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Timeline</div><div class="val"><?php echo pe($agreement['timeline'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Payment Terms</div><div class="val"><?php echo pe($agreement['payment_terms'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Revision Terms</div><div class="val"><?php echo pe($agreement['revision_terms'] ?? ''); ?></div>
<div class="lbl" style="margin-top:8px;">Customer Responsibilities</div><div class="val"><?php echo pe($agreement['customer_responsibilities'] ?? ''); ?></div>
<?php endif; ?>
</div></div></section>
<?php include __DIR__ . '/../includes/footer.php'; ?>
<script src="../assets/js/jquery-1.12.3.min.js"></script><script src="../assets/js/bootstrap.min.js"></script>
</body></html>
82 changes: 46 additions & 36 deletions client/contracts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,27 @@
define('WDS_SYSTEM', true);
require_once __DIR__ . '/../includes/portal-helpers.php';

portalRequireClient();
portalRequireLogin();
if (portalGetRole() !== 'client') {
header('Location: /dashboard.php');
exit;
}

$user = portalGetUser();
$username = (string)($user['username'] ?? '');
$requests = array_values(array_filter(portalLoadProjectRequests(), function ($r) use ($username) {
return (string)($r['client_username'] ?? '') === $username;
}));
$requestIds = array_map(function ($r) { return portalGetRequestDisplayId((array)$r); }, $requests);

$agreements = array_values(array_filter(portalLoadProjectAgreements(), function ($a) use ($requestIds, $username) {
return in_array((string)($a['request_id'] ?? ''), $requestIds, true)
|| (string)($a['client_username'] ?? '') === $username;
}));

usort($agreements, function ($a, $b) {
return strcmp((string)($b['updated_at'] ?? $b['created_at'] ?? ''), (string)($a['updated_at'] ?? $a['created_at'] ?? ''));
});

$current_page = 'client-portal';
$header_class = 'inner-header';
Expand All @@ -15,51 +35,41 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="../assets/images/RL-icon.png">
<title>My Contracts | Client Portal | Runlevel Systems</title>
<title>My Project Agreements | Client Portal | Runlevel Systems</title>
<link href="../assets/css/coreloop.css" rel="stylesheet">
<style>
.portal-wrap { padding: 40px 0 80px; }
.portal-back { color: #36f3ff; font-size: 0.9rem; margin-bottom: 18px; display: inline-block; }
.portal-back:hover { color: #ffc600; }
.portal-card { background: #0c1729; border: 1px solid rgba(54,243,255,0.18); border-radius: 10px; padding: 30px; }
.portal-card h2 { color: #ffc600; margin-top: 0; }
.info-section { background: rgba(54,243,255,0.05); border: 1px solid rgba(54,243,255,0.15); border-radius: 8px; padding: 20px 22px; margin-bottom: 22px; }
.coming-soon { text-align: center; padding: 40px 20px; color: #5a7a9e; }
.coming-soon .icon { font-size: 2.5rem; margin-bottom: 12px; }
.portal-wrap{padding:30px 0 70px;}
.card{background:#0c1729;border:1px solid rgba(54,243,255,.18);border-radius:10px;padding:16px;}
.item{background:#09111d;border:1px solid rgba(54,243,255,.14);border-radius:8px;padding:12px;margin-bottom:10px;}
</style>
</head>
<body>
<?php include __DIR__ . '/../includes/header.php'; ?>
<?php include __DIR__ . '/../includes/navigation.php'; ?>

<section class="portal-wrap">
<div class="container">
<a href="/client/dashboard.php" class="portal-back">← Back to Dashboard</a>

<div class="portal-card">
<h2>📑 My Contracts</h2>

<div class="info-section">
<h4 style="color:#36f3ff; margin-top:0;">About Contracts</h4>
<p style="color:#a8bedc; margin-bottom:0;">
For smaller jobs, the accepted proposal and Runlevel Systems Terms of Service typically serve as
the project agreement. For larger, commercial, or ongoing work, a written project agreement may
be used. Contracts spell out project scope, payment terms, deliverables, and both parties'
responsibilities in more detail.
</p>
</div>

<div class="coming-soon">
<div class="icon">🔧</div>
<p style="color:#5a7a9e;">Contracts for your projects will appear here when applicable.</p>
<p>
<a href="/contracts.php" style="color:#36f3ff; font-size:0.875rem;">Learn more about how contracts work →</a>
</p>
</div>
</div>
<div class="container">
<a href="/dashboard.php" style="color:#36f3ff;font-size:.84rem;">← Back to Dashboard</a>
<div class="card" style="margin-top:10px;">
<h2 style="margin:0 0 12px;color:#ffc600;font-size:1.1rem;">My Project Agreements</h2>
<?php if (empty($agreements)): ?>
<p style="color:#7a9ac0;">No project agreements available yet.</p>
<?php else: ?>
<?php foreach ($agreements as $agreement): ?>
<div class="item">
<div style="display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;">
<div style="color:#ffc600;font-family:monospace;font-weight:700;"><?php echo pe($agreement['agreement_id'] ?? 'Agreement'); ?></div>
<div style="color:#a8bedc;font-size:.8rem;"><?php echo pe(ucfirst((string)($agreement['status'] ?? 'draft'))); ?></div>
</div>
<div style="color:#eaf3ff;font-size:.9rem;margin-top:4px;"><?php echo pe($agreement['project_title'] ?? 'Project Agreement'); ?></div>
<div style="color:#7a9ac0;font-size:.78rem;margin-top:4px;">Request ID: <?php echo pe($agreement['request_id'] ?? ''); ?></div>
<a style="display:inline-block;margin-top:6px;color:#36f3ff;font-size:.82rem;" href="/client/agreement.php?agreement_id=<?php echo urlencode((string)($agreement['agreement_id'] ?? '')); ?>">View project agreement</a>
</div>
<?php endforeach; ?>
<?php endif; ?>
<p style="margin:8px 0 0;color:#5a7a9e;font-size:.75rem;">TODO: Add online acceptance/signature workflow later.</p>
</div>
</div>
</section>

<?php include __DIR__ . '/../includes/footer.php'; ?>
<script src="../assets/js/jquery-1.12.3.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
Expand Down
Loading