403Webshell
Server IP : 37.9.174.138  /  Your IP : 216.73.216.117
Web Server : Apache
System : Linux vps6.backend.sk 6.12.100+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.100-1 (2026-07-30) x86_64
User : ftpuser ( 1001)
PHP Version : 8.4.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/backend-accounting.sk/app/modules/worksheets/code/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/backend-accounting.sk/app/modules/worksheets/code/WorksheetPeriodHelper.php
<?php

namespace modules\worksheets\code;

use app\classes\PDODatabase;
use app\constants\State;

class WorksheetPeriodHelper {

    /** @var array<string, int|null> */
    private static $latestGeneratedPeriodCache = [];

    /**
     * Inclusive ISO date bounds for the current calendar month.
     *
     * @return array{min: string, max: string}
     */
    public static function getCurrentCalendarMonthDateBounds(?\DateTimeInterface $now = null): array {
        if ($now instanceof \DateTimeImmutable) {
            $base = $now;
        } elseif ($now instanceof \DateTimeInterface) {
            $base = new \DateTimeImmutable($now->format('Y-m-d H:i:s'));
        } else {
            $base = new \DateTimeImmutable('today');
        }

        return [
            'min' => $base->modify('first day of this month')->format('Y-m-d'),
            'max' => $base->modify('last day of this month')->format('Y-m-d'),
        ];
    }

    public static function getLatestGeneratedPeriod(string $tableName): ?int {
        if (array_key_exists($tableName, self::$latestGeneratedPeriodCache)) {
            return self::$latestGeneratedPeriodCache[$tableName];
        }

        $db = PDODatabase::getInstance();
        $escapedTable = '`' . str_replace('`', '``', $tableName) . '`';
        $value = $db->getValue(
            'SELECT MAX(period) FROM ' . $escapedTable . ' WHERE state != :DELETED',
            ['DELETED' => State::DELETED]
        );

        $period = ($value === null || $value === '') ? null : (int) $value;
        self::$latestGeneratedPeriodCache[$tableName] = $period;

        return $period;
    }

    public static function isLatestGeneratedPeriod(string $tableName, ?int $period): bool {
        if ($period === null || $period <= 0) {
            return false;
        }

        $latest = self::getLatestGeneratedPeriod($tableName);

        return $latest !== null && $period === $latest;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit