<?php

namespace Ministra\Tasks;

include __DIR__ . '/common.php';
use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba;
use Ministra\Lib\SysEvent;
if (\Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf::getSafe('enable_internal_billing', false)) {
    $ids = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->from('`users`')->where(['(TO_DAYS(`expire_billing_date`) - TO_DAYS(NOW()) - 1) < 0 AND ' . "CAST(`expire_billing_date` AS CHAR) <> '0000-00-00 00:00:00' AND 1=" => 1, 'status' => 0])->get()->all('id');
    \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->update('`users`', ['status' => 1, 'last_change_status' => 'NOW()'], [" `id` IN ('" . \implode("', '", $ids) . "') AND 1=" => 1, 'status' => 0]);
    $online = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\b0144dbc621686d5838378f3b96bd17b::d3f4fb87821dcd5d8ccd0de1a79d8eee1();
    $event = new \Ministra\Lib\SysEvent();
    $event->setUserListById(\array_intersect($ids, $online));
    $event->sendCutOff();
}
