Files
Investidor-V2/outputs/investmoz-staff-preparation-20261012/inspect-contact-manual-readonly.php
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

34 lines
2.9 KiB
PHP

<?php
ini_set('zend.exception_ignore_args', '1');
try {
$portal = dirname(__DIR__, 2);
$plan = json_decode(file_get_contents($portal.'/storage/app/private/investmoz-v2/portal-audit/internal-designation-plan.json'), true, 512, JSON_THROW_ON_ERROR);
$qa = $plan['source'];
if (!str_contains($qa, 'onboarding-qa-internal-20261011_191450')) throw new RuntimeException('Separate QA source required');
require $qa.'/qa-autoload.php';
$app = require $qa.'/bootstrap/app.php';
(new Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables)->bootstrap($app);
(new Illuminate\Foundation\Bootstrap\LoadConfiguration)->bootstrap($app);
$c = config('database.connections.'.config('database.default'));
if ($c['driver'] !== 'pgsql' || (int)$c['port'] !== 55441 || $c['database'] !== 'onboarding_internal_20261011_191450_test' || !empty($c['url'])) throw new RuntimeException('QA target rejected');
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
$db = Illuminate\Support\Facades\DB::class;
$db::statement('BEGIN READ ONLY');
try {
if ((int)$db::selectOne('SELECT inet_server_port() AS port')->port !== 55441) throw new RuntimeException('QA server rejected');
$record = App\Models\Opportunity::findOrFail(7);
$values = app(App\Services\OpportunityManagement::class)->values($record);
$contactId = $values['canonical']['internal_contact_id'] ?? null;
$contact = $contactId ? $db::table('contacts')->where('id', $contactId)->first(['id', 'source_system', 'created_at', 'updated_at', 'deleted_at']) : null;
$events = $db::table('audit_events')->where('actor_user_id', 45)->where('occurred_at', '>', '2026-10-12 10:00:00+00')
->where(fn ($q) => $q->where('source_system', 'opportunity-management')->orWhere('action', 'opportunity_contact_registered'))
->orderBy('occurred_at')->get(['action', 'source_system', 'actor_user_id', 'occurred_at']);
$proof = ['at' => gmdate('c'), 'read_only' => true, 'target' => $c['database'].':55441', 'record_id' => $record->id,
'owner_user_id' => $record->owner_user_id, 'status' => $record->status, 'management_version' => $record->management_version,
'updated_at' => $record->updated_at?->toIso8601String(), 'selected_contact_id' => $contactId, 'contact' => $contact, 'events_after_test_started' => $events,
'workflow_enabled' => (bool)config('portal.profile_access_enabled'), 'active_writes' => 0, 'no_codes_cookies_or_credentials_recorded' => true];
} finally { $db::statement('ROLLBACK'); }
file_put_contents(__DIR__.'/manual-contact-readonly.json', json_encode($proof, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));
echo json_encode($proof, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR);
} catch (Throwable $e) { echo json_encode(['result' => 'stopped', 'type' => $e::class, 'line' => $e->getLine()]); exit(1); }