<?php

require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

// Update a marketing officer's created_at to be 2 months ago for testing
$marketingOfficer = \App\Models\User::role('marketing_officer')->first();

if (!$marketingOfficer) {
    echo "No marketing officer found\n";
    exit(1);
}

// Set creation date to 2 months ago
$twoMonthsAgo = \Carbon\Carbon::now()->subMonths(2)->startOfDay();
\DB::table('users')
    ->where('id', $marketingOfficer->id)
    ->update(['created_at' => $twoMonthsAgo]);

echo "Updated marketing officer creation date to: {$twoMonthsAgo->format('Y-m-d')}\n";
echo "Marketing Officer ID: {$marketingOfficer->id}\n";
echo "\nNow you can test the 'Generate All Periods' button!\n";
echo "It should generate approximately " . ceil($twoMonthsAgo->diffInWeeks(\Carbon\Carbon::now()) / 2) . " periods.\n";
