<?php

namespace Ministra\Tasks;

require __DIR__ . '/common.php';
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272;
use Ministra\Lib\SysEvent;
if (\Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\K131970f0a776522b1a53ba419cd5e32c::getSafe('enable_internal_billing', false)) {
    $ids = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::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\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->update('`users`', ['status' => 1, 'last_change_status' => 'NOW()'], [" `id` IN ('" . \implode("', '", $ids) . "') AND 1=" => 1, 'status' => 0]);
    $online = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\f1346478e91df21aff77c1e1db9ef4c7::f361ecbb283b26c9d3a0143f742dd591();
    $event = new \Ministra\Lib\SysEvent();
    $event->setUserListById(\array_intersect($ids, $online));
    $event->sendCutOff();
}
