- Renombrado «DC3» a «API Peñasquito» (URL base del documento) en UI/docs; rutas y claves de config conservadas por compatibilidad. - Persistencia de ticket_id en nueva tabla `penasquito_tickets`: POST /search/ guarda el ticket y los siguientes requests retoman GET /result/<ticket_id>/ sin reencolar. - Polling acotado por request HTTP (~6 s) con `PenasquitoPendingException` y caja «reintentar» en lookup; ticket queda válido 1 h. - `users_cache.company` nuevo (con migración idempotente); persistResult guarda empresa + competencias en transacción y aplica source distinto. - Mensajes HTTP específicos (400/401/403/404/408/429/5xx) y `/` final forzado en rutas (DRF), FOLLOWLOCATION habilitado. - Vista de perfil muestra «Empresa» y aviso cuando no hay competencias. - Auth::login evita doble fetch cuando ya tenemos el `result` del API. - i18n ES/EN actualizados; lookup_pending_*; limpieza de archivos lang. Co-authored-by: Cursor <cursoragent@cursor.com>
81 lines
3.3 KiB
PHP
81 lines
3.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use CertiMine\I18n;
|
|
use CertiMine\Util;
|
|
|
|
/** @var array<string,mixed> $row */
|
|
/** @var list<array<string,mixed>> $certs */
|
|
/** @var list<array<string,mixed>> $auths */
|
|
/** @var bool $green */
|
|
/** @var string $qrUrl */
|
|
|
|
require __DIR__ . '/partials/header.php';
|
|
$isEs = I18n::lang() === 'es';
|
|
$ptype = (string) $row['person_type'];
|
|
$name = (string) $row['display_name'];
|
|
|
|
$statusLabel = static function (string $s): string {
|
|
return I18n::t('status_' . $s);
|
|
};
|
|
?>
|
|
<div class="d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3">
|
|
<h1 class="h3 mb-0"><?= Util::h($name) ?></h1>
|
|
<?php if ($ptype === 'contractor'): ?>
|
|
<span class="badge <?= $green ? 'bg-success' : 'bg-warning text-dark' ?> fs-6">
|
|
<span class="material-symbols-outlined align-middle">eco</span>
|
|
<?= Util::h(I18n::t('profile_green')) ?>: <?= Util::h($green ? I18n::t('profile_green_yes') : I18n::t('profile_green_no')) ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<p class="text-muted mb-2">
|
|
<?= $ptype === 'contractor' ? Util::h(I18n::t('lookup_contractor')) : Util::h(I18n::t('lookup_employee')) ?>
|
|
· <?= Util::h((string) ($row['employee_number'] ?? '')) ?>
|
|
</p>
|
|
<?php $company = trim((string) ($row['company'] ?? '')); ?>
|
|
<?php if ($company !== ''): ?>
|
|
<p class="mb-3">
|
|
<span class="material-symbols-outlined align-middle text-muted">apartment</span>
|
|
<span class="text-muted"><?= Util::h(I18n::t('profile_company')) ?>:</span>
|
|
<strong><?= Util::h($company) ?></strong>
|
|
</p>
|
|
<?php endif; ?>
|
|
|
|
<div class="mb-4">
|
|
<label class="form-label small text-muted">QR / deep link</label>
|
|
<input class="form-control form-control-sm" readonly value="<?= Util::h($qrUrl) ?>">
|
|
</div>
|
|
|
|
<h2 class="h5"><?= Util::h(I18n::t('profile_certs')) ?></h2>
|
|
<div class="table-responsive card mb-4">
|
|
<table class="table mb-0">
|
|
<thead><tr><th><?= $isEs ? 'Título' : 'Title' ?></th><th>NOM</th><th><?= Util::h(I18n::t('expires')) ?></th><th><?= $isEs ? 'Estado' : 'Status' ?></th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ($certs as $c): ?>
|
|
<tr>
|
|
<td><?= Util::h((string) $c['title']) ?></td>
|
|
<td><?= Util::h((string) ($c['nom_code'] ?? '—')) ?></td>
|
|
<td><?= Util::h((string) ($c['expires_at'] ?? '—')) ?></td>
|
|
<td><span class="badge text-bg-light border"><?= Util::h($statusLabel((string) $c['status'])) ?></span></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php if ($certs === []): ?>
|
|
<tr><td colspan="4" class="text-muted"><?= Util::h(I18n::t('profile_no_competencies')) ?></td></tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php if ($ptype === 'contractor' && $auths !== []): ?>
|
|
<h2 class="h5"><?= Util::h(I18n::t('profile_auths')) ?></h2>
|
|
<ul class="list-group mb-4">
|
|
<?php foreach ($auths as $a): ?>
|
|
<li class="list-group-item d-flex justify-content-between">
|
|
<span><?= Util::h((string) $a['code']) ?> — <?= Util::h($isEs ? (string) $a['name_es'] : (string) $a['name_en']) ?></span>
|
|
<small class="text-muted"><?= Util::h(I18n::t('expires')) ?>: <?= Util::h((string) ($a['valid_until'] ?? '—')) ?></small>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
|
|
<?php require __DIR__ . '/partials/footer.php'; ?>
|