Merge pull request #29 from GameServerPanel/copilot/remove-old-billing-module
[WIP] Remove old billing module and update status descriptions
This commit is contained in:
commit
e0e2cce661
5 changed files with 31 additions and 31 deletions
|
|
@ -327,7 +327,7 @@ function ogpHome()
|
||||||
$db->logger( get_lang("logging_in") ."...");
|
$db->logger( get_lang("logging_in") ."...");
|
||||||
$db->query("DELETE FROM `OGP_DB_PREFIXban_list` WHERE client_ip='$client_ip';");
|
$db->query("DELETE FROM `OGP_DB_PREFIXban_list` WHERE client_ip='$client_ip';");
|
||||||
//find number of servers user has. if zero, then redirect to the shop page.
|
//find number of servers user has. if zero, then redirect to the shop page.
|
||||||
$result = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE user_id='".$_SESSION['user_id']."' AND status < 1 ");
|
$result = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE user_id='".$_SESSION['user_id']."' AND status IN ('in-cart', 'unknown') ");
|
||||||
$servercount = 0;
|
$servercount = 0;
|
||||||
foreach($result as $servers)
|
foreach($result as $servers)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -297,12 +297,12 @@ function exec_ogp_module()
|
||||||
|
|
||||||
if($order['finish_date'] == 0){
|
if($order['finish_date'] == 0){
|
||||||
$finish_date = strtotime('+'.$order['qty'].' day');
|
$finish_date = strtotime('+'.$order['qty'].' day');
|
||||||
$status = 1;
|
$status = 'paid';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//this is a renewel, start from end of previous order
|
//this is a renewel, start from end of previous order
|
||||||
$finish_date = strtotime('+'.$order['qty'].' day',$order['finish_date']);
|
$finish_date = strtotime('+'.$order['qty'].' day',$order['finish_date']);
|
||||||
$status = 1;
|
$status = 'paid';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -311,13 +311,13 @@ function exec_ogp_module()
|
||||||
// this is a new order
|
// this is a new order
|
||||||
if($order['finish_date'] == 0){
|
if($order['finish_date'] == 0){
|
||||||
$finish_date = strtotime('+'.$order['qty'].' month');
|
$finish_date = strtotime('+'.$order['qty'].' month');
|
||||||
$status = 1;
|
$status = 'paid';
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//this is a renewel, start from end of previous order
|
//this is a renewel, start from end of previous order
|
||||||
$finish_date = strtotime('+'.$order['qty'].' month',$order['finish_date']);
|
$finish_date = strtotime('+'.$order['qty'].' month',$order['finish_date']);
|
||||||
$status = 1;
|
$status = 'paid';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($order['invoice_duration'] == "year")
|
elseif ($order['invoice_duration'] == "year")
|
||||||
|
|
@ -325,12 +325,12 @@ function exec_ogp_module()
|
||||||
// this is a new order
|
// this is a new order
|
||||||
if($order['finish_date'] == 0){
|
if($order['finish_date'] == 0){
|
||||||
$finish_date = strtotime('+'.$order['qty'].' year');
|
$finish_date = strtotime('+'.$order['qty'].' year');
|
||||||
$status = 1;
|
$status = 'paid';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//this is a renewel, start from end of previous order
|
//this is a renewel, start from end of previous order
|
||||||
$finish_date = strtotime('+'.$order['qty'].' year',$order['finish_date']);
|
$finish_date = strtotime('+'.$order['qty'].' year',$order['finish_date']);
|
||||||
$status = 1;
|
$status = 'paid';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,10 @@ $db->logger("AUTO-CLEAN: Server Cleanup running at ".$rundate);
|
||||||
|
|
||||||
//THESE SERVERS HAVE REACHED THE DATE FOR INVOICE, FINISH_DATE - 7 (OR WHAT IS IN SETTINGS)
|
//THESE SERVERS HAVE REACHED THE DATE FOR INVOICE, FINISH_DATE - 7 (OR WHAT IS IN SETTINGS)
|
||||||
//SET STATUS -1 MEANING INVOICED
|
//SET STATUS -1 MEANING INVOICED
|
||||||
//LOOP THROUGH ALL SERVERS WITH STATUS = 1 (ACTIVE) -----------------------------------------------------------
|
//LOOP THROUGH ALL SERVERS WITH STATUS = 'paid' (ACTIVE) -----------------------------------------------------------
|
||||||
$user_homes = $db->resultQuery( "SELECT *
|
$user_homes = $db->resultQuery( "SELECT *
|
||||||
FROM " . $table_prefix . "billing_orders
|
FROM " . $table_prefix . "billing_orders
|
||||||
WHERE status > 0 AND finish_date <" . $invoice_date);
|
WHERE status = 'paid' AND finish_date <" . $invoice_date);
|
||||||
|
|
||||||
if (!is_array($user_homes))
|
if (!is_array($user_homes))
|
||||||
{
|
{
|
||||||
|
|
@ -72,9 +72,9 @@ else
|
||||||
$home_id = $user_home['home_id'];
|
$home_id = $user_home['home_id'];
|
||||||
|
|
||||||
|
|
||||||
// Reset the STATUS -1 so cart.php will create an invoice
|
// Reset the STATUS 'invoiced' so cart.php will create an invoice
|
||||||
$db->query( "UPDATE " . $table_prefix . "billing_orders
|
$db->query( "UPDATE " . $table_prefix . "billing_orders
|
||||||
SET status=-1
|
SET status='invoiced'
|
||||||
WHERE order_id=".$db->realEscapeSingle($user_home['order_id']));
|
WHERE order_id=".$db->realEscapeSingle($user_home['order_id']));
|
||||||
|
|
||||||
// SEND EMAIL
|
// SEND EMAIL
|
||||||
|
|
@ -99,10 +99,10 @@ else
|
||||||
|
|
||||||
//THESE ARE THE SERVERS THAT HAVE NOT BEEN PAID AND THE FINISH_DATE IS TODAY
|
//THESE ARE THE SERVERS THAT HAVE NOT BEEN PAID AND THE FINISH_DATE IS TODAY
|
||||||
//THESE SERVERS GET SUSPENDED
|
//THESE SERVERS GET SUSPENDED
|
||||||
//LOOP THROUGH ALL ORDERS WITH STATUS 0 OR -1 (INACTIVE OR INVOICED)
|
//LOOP THROUGH ALL ORDERS WITH STATUS 'invoiced' OR 'in-cart' OR 'unknown' (INACTIVE OR INVOICED)
|
||||||
$user_homes = $db->resultQuery( "SELECT *
|
$user_homes = $db->resultQuery( "SELECT *
|
||||||
FROM " . $table_prefix . "billing_orders
|
FROM " . $table_prefix . "billing_orders
|
||||||
WHERE (status = -1 OR status = 0) AND finish_date < ".$today);
|
WHERE status IN ('invoiced', 'in-cart', 'unknown') AND finish_date < ".$today);
|
||||||
|
|
||||||
if (!is_array($user_homes))
|
if (!is_array($user_homes))
|
||||||
{
|
{
|
||||||
|
|
@ -128,10 +128,10 @@ else
|
||||||
}
|
}
|
||||||
$db->unassignHomeFrom("user", $user_id, $home_id);
|
$db->unassignHomeFrom("user", $user_id, $home_id);
|
||||||
|
|
||||||
// Reset the invoice end date to -2
|
// Reset the invoice end date to 'suspended'
|
||||||
// User can still RENEW server
|
// User can still RENEW server
|
||||||
$db->query( "UPDATE " . $table_prefix . "billing_orders
|
$db->query( "UPDATE " . $table_prefix . "billing_orders
|
||||||
SET status=-2
|
SET status='suspended'
|
||||||
WHERE order_id=".$db->realEscapeSingle($user_home['order_id']));
|
WHERE order_id=".$db->realEscapeSingle($user_home['order_id']));
|
||||||
|
|
||||||
//logger
|
//logger
|
||||||
|
|
@ -152,11 +152,11 @@ else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// end date = -2 (suspended) and its been suspended for $removal_date days
|
// end date = 'suspended' (suspended) and its been suspended for $removal_date days
|
||||||
//set removed servers as -99
|
//set removed servers as 'deleted'
|
||||||
$user_homes = $db->resultQuery( "SELECT *
|
$user_homes = $db->resultQuery( "SELECT *
|
||||||
FROM " . $table_prefix . "billing_orders
|
FROM " . $table_prefix . "billing_orders
|
||||||
WHERE status = -2 AND finish_date < ".$removal_date );
|
WHERE status = 'suspended' AND finish_date < ".$removal_date );
|
||||||
|
|
||||||
if (!is_array($user_homes))
|
if (!is_array($user_homes))
|
||||||
{
|
{
|
||||||
|
|
@ -181,7 +181,7 @@ else
|
||||||
|
|
||||||
// Reset the invoice end date
|
// Reset the invoice end date
|
||||||
$db->query( "UPDATE " . $table_prefix . "billing_orders
|
$db->query( "UPDATE " . $table_prefix . "billing_orders
|
||||||
SET status=-3
|
SET status='deleted'
|
||||||
WHERE order_id=".$db->realEscapeSingle($user_home['order_id']));
|
WHERE order_id=".$db->realEscapeSingle($user_home['order_id']));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ $install_queries[2] = array(
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` DROP `home_path`;",
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` DROP `home_path`;",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` DROP `paid`;",
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` DROP `paid`;",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `home_id` varchar(255) NOT NULL DEFAULT '0';",
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `home_id` varchar(255) NOT NULL DEFAULT '0';",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `status` varchar(16) NOT NULL DEFAULT '0';",
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `status` varchar(16) NOT NULL DEFAULT 'unknown';",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `date` varchar(16) NOT NULL DEFAULT '0';",
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `date` varchar(16) NOT NULL DEFAULT '0';",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `tax_amount` varchar(16) NOT NULL DEFAULT '0';",
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `tax_amount` varchar(16) NOT NULL DEFAULT '0';",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `currency` varchar(3) NOT NULL DEFAULT '0';"
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `currency` varchar(3) NOT NULL DEFAULT '0';"
|
||||||
|
|
@ -126,8 +126,8 @@ $install_queries[3] = array(
|
||||||
|
|
||||||
$install_queries[4] = array(
|
$install_queries[4] = array(
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `extended` tinyint(1) NOT NULL;",
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `extended` tinyint(1) NOT NULL;",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_services` ADD `enabled` int(11) NOT NULL;"
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_services` ADD `enabled` int(11) NOT NULL;",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `coupon_id` varchar(3) NOT NULL DEFAULT '0';"
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `coupon_id` varchar(3) NOT NULL DEFAULT '0';",
|
||||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `coupon_id` varchar(3) NOT NULL DEFAULT '0';"
|
"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `coupon_id` varchar(3) NOT NULL DEFAULT '0';"
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -341,31 +341,31 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
|
||||||
//default is it never expires
|
//default is it never expires
|
||||||
$expiration_dates = "This Server Will NEVER Expire";
|
$expiration_dates = "This Server Will NEVER Expire";
|
||||||
//get all orders thare are active or invoiced
|
//get all orders thare are active or invoiced
|
||||||
$query = "SELECT * FROM ogp_billing_orders WHERE home_id = " . $server_home['home_id'] . " AND status >= -2" ;
|
$query = "SELECT * FROM ogp_billing_orders WHERE home_id = " . $server_home['home_id'] . " AND status IN ('paid', 'invoiced', 'suspended', 'in-cart', 'unknown')" ;
|
||||||
$results = $db->resultQuery($query);
|
$results = $db->resultQuery($query);
|
||||||
if(!is_null($results[0]['status']))
|
if(!is_null($results[0]['status']))
|
||||||
{
|
{
|
||||||
//there is an end date
|
//there is an end date
|
||||||
if($results[0]['status'] > 0)
|
if($results[0]['status'] == 'paid')
|
||||||
{
|
{
|
||||||
$expire_date = $results[0]['finish_date'];
|
$expire_date = $results[0]['finish_date'];
|
||||||
$expiration_dates = "<font color='green'>" . read_expire($expire_date) . "</font>";
|
$expiration_dates = "<font color='green'>" . read_expire($expire_date) . "</font>";
|
||||||
}
|
}
|
||||||
// 0 its expire, invoice printed
|
// in-cart its expire, invoice printed
|
||||||
if($results[0]['status'] == 0)
|
if($results[0]['status'] == 'in-cart' || $results[0]['status'] == 'unknown')
|
||||||
{
|
{
|
||||||
$expire_date = $results[0]['finish_date'];
|
$expire_date = $results[0]['finish_date'];
|
||||||
$expiration_dates = "<font color='yellow'>". read_expire($expire_date) . "</font><a href='home.php?m=billing&p=cart'> Invoice</a>";
|
$expiration_dates = "<font color='yellow'>". read_expire($expire_date) . "</font><a href='home.php?m=billing&p=cart'> Invoice</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// -1 its expire, invoice printed
|
// invoiced its expire, invoice printed
|
||||||
if($results[0]['status'] == -1)
|
if($results[0]['status'] == 'invoiced')
|
||||||
{
|
{
|
||||||
$expire_date = $results[0]['finish_date'];
|
$expire_date = $results[0]['finish_date'];
|
||||||
$expiration_dates = "<font color='yellow'>". read_expire($expire_date) . "</font><a href='home.php?m=billing&p=cart'> Invoice</a>";
|
$expiration_dates = "<font color='yellow'>". read_expire($expire_date) . "</font><a href='home.php?m=billing&p=cart'> Invoice</a>";
|
||||||
}
|
}
|
||||||
// -2 its suspended, invoice still available
|
// suspended its suspended, invoice still available
|
||||||
if($results[0]['status'] == -2)
|
if($results[0]['status'] == 'suspended')
|
||||||
{
|
{
|
||||||
$expire_date = $results[0]['finish_date'];
|
$expire_date = $results[0]['finish_date'];
|
||||||
$expiration_dates = "<font color='red'> SUSPENDED </font><a href='home.php?m=billing&p=cart'> Invoice</a>";
|
$expiration_dates = "<font color='red'> SUSPENDED </font><a href='home.php?m=billing&p=cart'> Invoice</a>";
|
||||||
|
|
@ -532,7 +532,7 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
|
||||||
$address = "<span style='color:darkred;font-weight:bold;'>Agent Offline</span>";
|
$address = "<span style='color:darkred;font-weight:bold;'>Agent Offline</span>";
|
||||||
}
|
}
|
||||||
$user = $db->getUserById($server_home['user_id_main']);
|
$user = $db->getUserById($server_home['user_id_main']);
|
||||||
$query = "SELECT * FROM ogp_billing_orders WHERE home_id = " . $server_home['home_id'] . " AND status > 0" ;
|
$query = "SELECT * FROM ogp_billing_orders WHERE home_id = " . $server_home['home_id'] . " AND status = 'paid'" ;
|
||||||
//DISABLE SHOWING EXPIRATION DATES
|
//DISABLE SHOWING EXPIRATION DATES
|
||||||
//$expiration_dates = "";
|
//$expiration_dates = "";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue