Upload files to "system/autoload"

Signed-off-by: nestict <icttechnest@gmail.com>
This commit is contained in:
2025-05-24 10:51:52 +02:00
parent dbe54cb3d0
commit 585a7382f1
5 changed files with 317 additions and 0 deletions

View File

@ -0,0 +1,64 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
**/
/**
* This script is for managing user balance
**/
class Balance
{
public static function plus($id_customer, $amount)
{
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
$c->balance = $amount + $c['balance'];
$c->save();
}
public static function transfer($id_customer, $phoneTarget, $amount)
{
global $config;
if (Balance::min($id_customer, $amount)) {
return Balance::plusByPhone($phoneTarget, $amount);
} else {
return false;
}
}
public static function min($id_customer, $amount)
{
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
if ($c && $c['balance'] >= $amount) {
$c->balance = $c['balance'] - $amount;
$c->save();
return true;
} else {
return false;
}
}
public static function plusByPhone($phone_customer, $amount)
{
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
if ($c) {
$c->balance = $amount + $c['balance'];
$c->save();
return true;
}
return false;
}
public static function minByPhone($phone_customer, $amount)
{
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
if ($c && $c['balance'] >= $amount) {
$c->balance = $c['balance'] - $amount;
$c->save();
return true;
} else {
return false;
}
}
}