Fix invoice

This commit is contained in:
Ibnu Maksum 2024-02-23 14:40:47 +07:00
parent c6a203b1f0
commit ddd7fb49fe
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
5 changed files with 137 additions and 89 deletions

View File

@ -181,16 +181,6 @@ CREATE TABLE `tb_languages` (
`id` int(11) NOT NULL `id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
ALTER TABLE `tbl_voucher` ADD `generated_by` INT NOT NULL DEFAULT '0' COMMENT 'id admin' AFTER `status`;
ALTER TABLE `tbl_users` ADD `root` INT NOT NULL DEFAULT '0' COMMENT 'for sub account' AFTER `id`;
ALTER TABLE `tbl_users` CHANGE `user_type` `user_type` ENUM('SuperAdmin','Admin','Report','Agent','Sales') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `tbl_users` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `tbl_users` ADD `phone` VARCHAR(32) NOT NULL DEFAULT '' AFTER `password`, ADD `email` VARCHAR(128) NOT NULL DEFAULT '' AFTER `phone`, ADD `city` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kota' AFTER `email`, ADD `subdistrict` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kecamatan' AFTER `city`, ADD `ward` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kelurahan' AFTER `subdistrict`;
ALTER TABLE `tbl_customers` ADD `created_by` INT NOT NULL DEFAULT '0' AFTER `auto_renewal`;
ALTER TABLE `tbl_plans` ADD `list_expired` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'address list' AFTER `pool_expired`;
ALTER TABLE `tbl_bandwidth` ADD `burst` VARCHAR(128) NOT NULL DEFAULT '' AFTER `rate_up_unit`;
ALTER TABLE `tbl_appconfig` ALTER TABLE `tbl_appconfig`
ADD PRIMARY KEY (`id`); ADD PRIMARY KEY (`id`);
@ -316,3 +306,14 @@ CREATE TABLE tbl_customers_fields (
field_value VARCHAR(255) NOT NULL, field_value VARCHAR(255) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES tbl_customers(id) FOREIGN KEY (customer_id) REFERENCES tbl_customers(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
ALTER TABLE `tbl_voucher` ADD `generated_by` INT NOT NULL DEFAULT '0' COMMENT 'id admin' AFTER `status`;
ALTER TABLE `tbl_users` ADD `root` INT NOT NULL DEFAULT '0' COMMENT 'for sub account' AFTER `id`;
ALTER TABLE `tbl_users` CHANGE `user_type` `user_type` ENUM('SuperAdmin','Admin','Report','Agent','Sales') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `tbl_users` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `tbl_users` ADD `phone` VARCHAR(32) NOT NULL DEFAULT '' AFTER `password`, ADD `email` VARCHAR(128) NOT NULL DEFAULT '' AFTER `phone`, ADD `city` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kota' AFTER `email`, ADD `subdistrict` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kecamatan' AFTER `city`, ADD `ward` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kelurahan' AFTER `subdistrict`;
ALTER TABLE `tbl_customers` ADD `created_by` INT NOT NULL DEFAULT '0' AFTER `auto_renewal`;
ALTER TABLE `tbl_plans` ADD `list_expired` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'address list' AFTER `pool_expired`;
ALTER TABLE `tbl_bandwidth` ADD `burst` VARCHAR(128) NOT NULL DEFAULT '' AFTER `rate_up_unit`;
ALTER TABLE `tbl_transactions` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;
ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;

View File

@ -38,9 +38,10 @@ Class Admin{
} }
} }
public static function _info(){ public static function _info($id = 0){
if(empty($id) && $id>0){
$id = Admin::getID(); $id = Admin::getID();
$d = ORM::for_table('tbl_users')->find_one($id); }
return $d; return ORM::for_table('tbl_users')->find_one($id);
} }
} }

View File

@ -19,7 +19,7 @@ class Package
*/ */
public static function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel) public static function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel)
{ {
global $_c; global $config, $admin;
$date_now = date("Y-m-d H:i:s"); $date_now = date("Y-m-d H:i:s");
$date_only = date("Y-m-d"); $date_only = date("Y-m-d");
$time_only = date("H:i:s"); $time_only = date("H:i:s");
@ -47,6 +47,9 @@ class Package
$t->method = "$gateway - $channel"; $t->method = "$gateway - $channel";
$t->routers = $router_name; $t->routers = $router_name;
$t->type = "Balance"; $t->type = "Balance";
if ($channel == 'Administrator') {
$t->admin_id = $admin['id'];
}
$t->save(); $t->save();
$balance_before = $c['balance']; $balance_before = $c['balance'];
@ -54,9 +57,9 @@ class Package
$balance = $c['balance'] + $p['price']; $balance = $c['balance'] + $p['price'];
$textInvoice = Lang::getNotifText('invoice_balance'); $textInvoice = Lang::getNotifText('invoice_balance');
$textInvoice = str_replace('[[company_name]]', $_c['CompanyName'], $textInvoice); $textInvoice = str_replace('[[company_name]]', $config['CompanyName'], $textInvoice);
$textInvoice = str_replace('[[address]]', $_c['address'], $textInvoice); $textInvoice = str_replace('[[address]]', $config['address'], $textInvoice);
$textInvoice = str_replace('[[phone]]', $_c['phone'], $textInvoice); $textInvoice = str_replace('[[phone]]', $config['phone'], $textInvoice);
$textInvoice = str_replace('[[invoice]]', $inv, $textInvoice); $textInvoice = str_replace('[[invoice]]', $inv, $textInvoice);
$textInvoice = str_replace('[[date]]', Lang::dateTimeFormat($date_now), $textInvoice); $textInvoice = str_replace('[[date]]', Lang::dateTimeFormat($date_now), $textInvoice);
$textInvoice = str_replace('[[payment_gateway]]', $gateway, $textInvoice); $textInvoice = str_replace('[[payment_gateway]]', $gateway, $textInvoice);
@ -67,13 +70,13 @@ class Package
$textInvoice = str_replace('[[name]]', $c['fullname'], $textInvoice); $textInvoice = str_replace('[[name]]', $c['fullname'], $textInvoice);
$textInvoice = str_replace('[[user_name]]', $c['username'], $textInvoice); $textInvoice = str_replace('[[user_name]]', $c['username'], $textInvoice);
$textInvoice = str_replace('[[user_password]]', $c['password'], $textInvoice); $textInvoice = str_replace('[[user_password]]', $c['password'], $textInvoice);
$textInvoice = str_replace('[[footer]]', $_c['note'], $textInvoice); $textInvoice = str_replace('[[footer]]', $config['note'], $textInvoice);
$textInvoice = str_replace('[[balance_before]]', Lang::moneyFormat($balance_before), $textInvoice); $textInvoice = str_replace('[[balance_before]]', Lang::moneyFormat($balance_before), $textInvoice);
$textInvoice = str_replace('[[balance]]', Lang::moneyFormat($balance), $textInvoice); $textInvoice = str_replace('[[balance]]', Lang::moneyFormat($balance), $textInvoice);
if ($_c['user_notification_payment'] == 'sms') { if ($config['user_notification_payment'] == 'sms') {
Message::sendSMS($c['phonenumber'], $textInvoice); Message::sendSMS($c['phonenumber'], $textInvoice);
} else if ($_c['user_notification_payment'] == 'wa') { } else if ($config['user_notification_payment'] == 'wa') {
Message::sendWhatsapp($c['phonenumber'], $textInvoice); Message::sendWhatsapp($c['phonenumber'], $textInvoice);
} }
@ -127,7 +130,7 @@ class Package
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time"); Radius::customerAddPlan($c, $p, "$date_exp $time");
}else{ } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']); Mikrotik::removeHotspotActiveUser($client, $c['username']);
@ -146,6 +149,9 @@ class Package
$b->method = "$gateway - $channel"; $b->method = "$gateway - $channel";
$b->routers = $router_name; $b->routers = $router_name;
$b->type = "Hotspot"; $b->type = "Hotspot";
if ($channel == 'Administrator') {
$b->admin_id = $admin['id'];
}
$b->save(); $b->save();
// insert table transactions // insert table transactions
@ -161,11 +167,14 @@ class Package
$t->method = "$gateway - $channel"; $t->method = "$gateway - $channel";
$t->routers = $router_name; $t->routers = $router_name;
$t->type = "Hotspot"; $t->type = "Hotspot";
if ($channel == 'Administrator') {
$t->admin_id = $admin['id'];
}
$t->save(); $t->save();
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time"); Radius::customerAddPlan($c, $p, "$date_exp $time");
}else{ } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']); Mikrotik::removeHotspotActiveUser($client, $c['username']);
@ -185,6 +194,9 @@ class Package
$d->method = "$gateway - $channel"; $d->method = "$gateway - $channel";
$d->routers = $router_name; $d->routers = $router_name;
$d->type = "Hotspot"; $d->type = "Hotspot";
if ($channel == 'Administrator') {
$d->admin_id = $admin['id'];
}
$d->save(); $d->save();
// insert table transactions // insert table transactions
@ -200,6 +212,9 @@ class Package
$t->method = "$gateway - $channel"; $t->method = "$gateway - $channel";
$t->routers = $router_name; $t->routers = $router_name;
$t->type = "Hotspot"; $t->type = "Hotspot";
if ($channel == 'Administrator') {
$t->admin_id = $admin['id'];
}
$t->save(); $t->save();
} }
Message::sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] . Message::sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
@ -231,7 +246,7 @@ class Package
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time"); Radius::customerAddPlan($c, $p, "$date_exp $time");
}else{ } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removePpoeActive($client, $c['username']);
@ -250,6 +265,9 @@ class Package
$b->method = "$gateway - $channel"; $b->method = "$gateway - $channel";
$b->routers = $router_name; $b->routers = $router_name;
$b->type = "PPPOE"; $b->type = "PPPOE";
if ($channel == 'Administrator') {
$b->admin_id = $admin['id'];
}
$b->save(); $b->save();
// insert table transactions // insert table transactions
@ -265,11 +283,14 @@ class Package
$t->method = "$gateway - $channel"; $t->method = "$gateway - $channel";
$t->routers = $router_name; $t->routers = $router_name;
$t->type = "PPPOE"; $t->type = "PPPOE";
if ($channel == 'Administrator') {
$t->admin_id = $admin['id'];
}
$t->save(); $t->save();
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time"); Radius::customerAddPlan($c, $p, "$date_exp $time");
}else{ } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']); Mikrotik::removePpoeActive($client, $c['username']);
@ -289,6 +310,9 @@ class Package
$d->method = "$gateway - $channel"; $d->method = "$gateway - $channel";
$d->routers = $router_name; $d->routers = $router_name;
$d->type = "PPPOE"; $d->type = "PPPOE";
if ($channel == 'Administrator') {
$d->admin_id = $admin['id'];
}
$d->save(); $d->save();
// insert table transactions // insert table transactions
@ -303,6 +327,9 @@ class Package
$t->time = $time; $t->time = $time;
$t->method = "$gateway - $channel"; $t->method = "$gateway - $channel";
$t->routers = $router_name; $t->routers = $router_name;
if ($channel == 'Administrator') {
$t->admin_id = $admin['id'];
}
$t->type = "PPPOE"; $t->type = "PPPOE";
$t->save(); $t->save();
} }
@ -322,9 +349,9 @@ class Package
$c = ORM::for_table('tbl_customers')->where('username', $username)->find_one(); $c = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one();
$b = ORM::for_table('tbl_user_recharges')->find_one($from_id); $b = ORM::for_table('tbl_user_recharges')->find_one($from_id);
if($p['routers'] == $b['routers'] && $b['routers'] != 'radius'){ if ($p['routers'] == $b['routers'] && $b['routers'] != 'radius') {
$mikrotik = Mikrotik::info($p['routers']); $mikrotik = Mikrotik::info($p['routers']);
}else{ } else {
$mikrotik = Mikrotik::info($b['routers']); $mikrotik = Mikrotik::info($b['routers']);
} }
// delete first // delete first
@ -358,21 +385,21 @@ class Package
} }
} }
// call the next mikrotik // call the next mikrotik
if($p['routers'] != $b['routers'] && $p['routers'] != 'radius'){ if ($p['routers'] != $b['routers'] && $p['routers'] != 'radius') {
$mikrotik = Mikrotik::info($p['routers']); $mikrotik = Mikrotik::info($p['routers']);
} }
if ($p['type'] == 'Hotspot') { if ($p['type'] == 'Hotspot') {
if ($b) { if ($b) {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, $b['expiration'].''.$b['time']); Radius::customerAddPlan($c, $p, $b['expiration'] . '' . $b['time']);
}else{ } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotUser($client, $p, $c); Mikrotik::addHotspotUser($client, $p, $c);
} }
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, $b['expiration'].''.$b['time']); Radius::customerAddPlan($c, $p, $b['expiration'] . '' . $b['time']);
}else{ } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotUser($client, $p, $c); Mikrotik::addHotspotUser($client, $p, $c);
} }
@ -381,14 +408,14 @@ class Package
if ($b) { if ($b) {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p);
}else{ } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoeUser($client, $p, $c); Mikrotik::addPpoeUser($client, $p, $c);
} }
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p);
}else{ } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoeUser($client, $p, $c); Mikrotik::addPpoeUser($client, $p, $c);
} }
@ -401,4 +428,70 @@ class Package
{ {
return substr(str_shuffle(str_repeat('0123456789', $l)), 0, $l); return substr(str_shuffle(str_repeat('0123456789', $l)), 0, $l);
} }
/**
* @param in tbl_transactions
* @param string $router_name router name for this package
* @param int $plan_id plan id for this package
* @param string $gateway payment gateway name
* @param string $channel channel payment gateway
* @return boolean
*/
public static function createInvoice($in)
{
global $config, $admin, $ui;
$date = Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time']);
if ($admin['id'] != $in['admin_id'] && $in['admin_id'] > 0) {
$_admin = Admin::_info($in['admin_id']);
// if admin not deleted
if ($_admin) $admin = $_admin;
}
//print
$invoice = Lang::pad($config['CompanyName'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['address'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['phone'], ' ', 2) . "\n";
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads("Invoice", $in['invoice'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Date'), $date, ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Sales'), $admin['fullname'], ' ') . "\n";
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads(Lang::T('Type'), $in['type'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Name'), $in['plan_name'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($in['price']), ' ') . "\n";
$invoice .= Lang::pad($in['method'], ' ', 2) . "\n";
$invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Password'), '**********', ' ') . "\n";
if ($in['type'] != 'Balance') {
$invoice .= Lang::pads(Lang::T('Created On'), Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time']), ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Expires On'), Lang::dateAndTimeFormat($in['expiration'], $in['time']), ' ') . "\n";
}
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pad($config['note'], ' ', 2) . "\n";
$ui->assign('invoice', $invoice);
$config['printer_cols'] = 30;
//whatsapp
$invoice = Lang::pad($config['CompanyName'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['address'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['phone'], ' ', 2) . "\n";
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads("Invoice", $in['invoice'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Date'), $date, ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Sales'), $admin['fullname'], ' ') . "\n";
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads(Lang::T('Type'), $in['type'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Name'), $in['plan_name'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($in['price']), ' ') . "\n";
$invoice .= Lang::pad($in['method'], ' ', 2) . "\n";
$invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Password'), '**********', ' ') . "\n";
if ($in['type'] != 'Balance') {
$invoice .= Lang::pads(Lang::T('Created On'), Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time']), ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Expires On'), Lang::dateAndTimeFormat($in['expiration'], $in['time']), ' ') . "\n";
}
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pad($config['note'], ' ', 2) . "\n";
$ui->assign('whatsapp', urlencode("```$invoice```"));
}
} }

View File

@ -129,8 +129,7 @@ switch ($action) {
if (Package::rechargeUser($id_customer, $server, $plan, "Recharge", $admin['fullname'])) { if (Package::rechargeUser($id_customer, $server, $plan, "Recharge", $admin['fullname'])) {
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one(); $c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
$ui->assign('in', $in); Package::createInvoice($in);
$ui->assign('date', date("Y-m-d H:i:s"));
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');
_log('[' . $admin['username'] . ']: ' . 'Recharge ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']); _log('[' . $admin['username'] . ']: ' . 'Recharge ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']);
} else { } else {
@ -153,56 +152,8 @@ switch ($action) {
} }
r2(U . 'prepaid/view/' . $id, 'd', "Customer not found"); r2(U . 'prepaid/view/' . $id, 'd', "Customer not found");
} }
//print Package::createInvoice($in);
$invoice = Lang::pad($config['CompanyName'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['address'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['phone'], ' ', 2) . "\n";
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads("Invoice", $in['invoice'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Date'), $date, ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Sales'), $admin['fullname'], ' ') . "\n";
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads(Lang::T('Type'), $in['type'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Name'), $in['plan_name'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($in['price']), ' ') . "\n";
$invoice .= Lang::pad($in['method'], ' ', 2) . "\n";
$invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Password'), '**********', ' ') . "\n";
if ($in['type'] != 'Balance') {
$invoice .= Lang::pads(Lang::T('Created On'), Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time']), ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Expires On'), Lang::dateAndTimeFormat($in['expiration'], $in['time']), ' ') . "\n";
}
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pad($config['note'], ' ', 2) . "\n";
$ui->assign('invoice', $invoice);
$config['printer_cols'] = 30;
//whatsapp
$invoice = Lang::pad($config['CompanyName'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['address'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['phone'], ' ', 2) . "\n";
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads("Invoice", $in['invoice'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Date'), $date, ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Sales'), $admin['fullname'], ' ') . "\n";
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads(Lang::T('Type'), $in['type'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Name'), $in['plan_name'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($in['price']), ' ') . "\n";
$invoice .= Lang::pad($in['method'], ' ', 2) . "\n";
$invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Password'), '**********', ' ') . "\n";
if ($in['type'] != 'Balance') {
$invoice .= Lang::pads(Lang::T('Created On'), Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time']), ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Expires On'), Lang::dateAndTimeFormat($in['expiration'], $in['time']), ' ') . "\n";
}
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pad($config['note'], ' ', 2) . "\n";
$ui->assign('whatsapp', urlencode("```$invoice```"));
$ui->assign('_title', 'View Invoice'); $ui->assign('_title', 'View Invoice');
$ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time']));
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');
break; break;
@ -683,8 +634,7 @@ switch ($action) {
$v1->user = $user['username']; $v1->user = $user['username'];
$v1->save(); $v1->save();
$in = ORM::for_table('tbl_transactions')->where('username', $user['username'])->order_by_desc('id')->find_one(); $in = ORM::for_table('tbl_transactions')->where('username', $user['username'])->order_by_desc('id')->find_one();
$ui->assign('in', $in); Package::createInvoice($in);
$ui->assign('date', date("Y-m-d H:i:s"));
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');
} else { } else {
r2(U . 'prepaid/refill', 'e', "Failed to refill account"); r2(U . 'prepaid/refill', 'e', "Failed to refill account");
@ -709,8 +659,7 @@ switch ($action) {
if (Package::rechargeUser($user, 'balance', $plan, "Deposit", $admin['fullname'])) { if (Package::rechargeUser($user, 'balance', $plan, "Deposit", $admin['fullname'])) {
$c = ORM::for_table('tbl_customers')->where('id', $user)->find_one(); $c = ORM::for_table('tbl_customers')->where('id', $user)->find_one();
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
$ui->assign('in', $in); Package::createInvoice($in);
$ui->assign('date', date("Y-m-d H:i:s"));
$ui->display('invoice.tpl'); $ui->display('invoice.tpl');
} else { } else {
r2(U . 'prepaid/refill', 'e', "Failed to refill account"); r2(U . 'prepaid/refill', 'e', "Failed to refill account");

View File

@ -65,5 +65,9 @@
], ],
"2024.2.20.1" : [ "2024.2.20.1" : [
"DROP TABLE IF EXISTS `tbl_customers_meta`;" "DROP TABLE IF EXISTS `tbl_customers_meta`;"
],
"2024.2.23" : [
"ALTER TABLE `tbl_transactions` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;",
"ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;"
] ]
} }