resultInsertId( 'billing_orders', $fields ); } function assignOrdersToCart($user_id,$tax_amount,$currency,$coupon_id){ global $db; $fields['user_id'] = $user_id; $fields['paid'] = '0'; $fields['tax_amount'] = $tax_amount; $fields['currency'] = $currency; //discount coupon if (!isset($coupon_id)) $coupon_id = "0"; $fields['coupon_id'] = $coupon_id; $check_expired = $db->resultquery("SELECT id from OGP_DB_PREFIXbilling_coupons WHERE id = $fields[coupon_id] AND count > 0 AND expires >= NOW()"); if ($check_expired <= 0) $fields['coupon_id'] = 0; return $db->resultInsertId( 'billing_carts', $fields ); } function exec_ogp_module() { error_reporting(E_ALL); global $db,$view,$settings; $discounted_price = 0; $user_id = $_SESSION['user_id']; if( isset($_POST["update_cart"] )) { //print_r($_POST); $db->query( "UPDATE OGP_DB_PREFIXbilling_orders SET max_players= ".$_POST['slots']." WHERE order_id=".$db->realEscapeSingle($_POST['order_id'])); $db->query( "UPDATE OGP_DB_PREFIXbilling_orders SET qty= ".$_POST['qty']." WHERE order_id=".$db->realEscapeSingle($_POST['order_id'])); $db->query( "UPDATE OGP_DB_PREFIXbilling_orders SET invoice_duration = 'month' WHERE order_id=".$db->realEscapeSingle($_POST['order_id'])); $db->query( "UPDATE OGP_DB_PREFIXgame_mods SET max_players= ".$_POST['slots']." WHERE home_id=".$db->realEscapeSingle($_POST['homeid'])); } //discount coupon if( isset($_POST["coupon_code"] ) && $_POST["coupon_code"] != "") { $coupon_id = 0; $coupon_code = ""; $result = $db->resultquery("SELECT * from OGP_DB_PREFIXbilling_coupons WHERE code= '". $_POST['coupon_code'] . "'"); $coupon_name = "NON-EXISTING COUPON"; $coupon_discount = 0; foreach($result as $couponDB){ $_SESSION['coupon_id'] = $couponDB['id']; $coupon_id = $couponDB['id']; $coupon_code = $couponDB['code']; $coupon_discount = $couponDB['discount']; $coupon_name = $couponDB['name']; $coupon_recurring = $couponDB['recurring']; $coupon_expires = $couponDB['expires']; $coupon_count = $couponDB['count']; $today = date("Y-m-d H:i:s", time()); if($coupon_expires < $today || $coupon_count == 0){ $coupon_id = 0; $coupon_discount = 0; $coupon_name = "EXPIRED COUPON"; } if ($coupon_count > 0) { $coupon_count--; $db->resultquery("UPDATE ogp_billing_coupons SET count = $coupon_count WHERE code = '$_POST[coupon_code]'"); } } } if( isset( $_POST["buy"] ) or isset( $_POST["pay_paypal"] ) ) { if( isset( $_SESSION['CART'] ) ) { $orders = $_SESSION['CART']; if(isset($_SESSION['coupon_id'])){ $coupon_id = $_SESSION['coupon_id']; } else { $coupon_id = 0; } // Fill The Cart on DB $cart_id = assignOrdersToCart($user_id,$settings['tax_amount'],$settings['currency'],$coupon_id); foreach($orders as $order) { $service_id = $order['service_id']; $home_name = $order['home_name']; $ip = $order['ip']; $max_players = $order['max_players']; //They pushed the "buy" button. //So set the quantity and invoice_duration if(isset($_POST["buy"])) { $invoice_duration = "month"; $qty = 1; } else{ $invoice_duration = $order['invoice_duration']; $qty = $order['qty']; } $price = $order['price']; $remote_control_password = $order['remote_control_password']; $ftp_password = $order['ftp_password']; //Save order to DB saveOrderToDb($user_id,$service_id,$home_name,$ip,$max_players,$qty,$invoice_duration,$price,$remote_control_password,$ftp_password,$cart_id,0,0,0,0); if( isset( $_POST["buy"] )) { echo ''; } } // Remove Cart From Session unset($_SESSION['CART']); unset($_SESSION['coupon_id']); } else { $cart_id = $_POST['cart_id']; } if ( !empty( $cart_id ) and isset( $_POST["pay_paypal"] ) and $settings['paypal'] == "1" ) { echo ''; } } if( isset( $_POST["extend"] ) or isset( $_POST["extend_and_pay_paypal"] )) { $orders = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE order_id=".$db->realEscapeSingle($_POST['order_id'])); // ***************************************** //FIGURE OUT IF THIS IS ALREADY BEEN UPDATED //RENEWAL IN DB SO //WE DONT CREATE MULTIPLE INVOICES // ***************************************** foreach($orders as $order) { $cart_id = $order['cart_id']; if($order['status'] < 0) { $cart_id = assignOrdersToCart($user_id,$settings['tax_amount'],$settings['currency'],$_SESSION['coupon_id']); $service_id = $order['service_id']; $home_name = $order['home_name']; $ip = $order['ip']; $max_players = $order['max_players']; $qty = $_POST['qty']; $invoice_duration = $_POST['invoice_duration']; $remote_control_password = $order['remote_control_password']; $ftp_password = $order['ftp_password']; $home_id = $order['home_id']; $status = 0; $finish_date = $order['finish_date']; $services = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_services WHERE service_id=".$db->realEscapeSingle($service_id) ); $service = $services[0]; //Calculating Price switch ($_POST['invoice_duration']) { case "day": $price = $service['price_monthly']/30; break; case "month": $price = $service['price_monthly']; break; case "year": $price = $service['price_monthly']*12; break; } //Save order to DB //save the EXPIRED finish date into NEW finish date. Then check if FINISH DATE !=0 and move that + 1 month into status $order_id = saveOrderToDb($user_id,$service_id,$home_name,$ip,$max_players,$qty,$invoice_duration,$price,$remote_control_password,$ftp_password,$cart_id,$home_id,$status,$finish_date,"1"); //Change the old order expiration to -3 so it can not be extended, since there is a new order managing the same game home. $db->query( "UPDATE OGP_DB_PREFIXbilling_orders SET status=-3 WHERE order_id=".$db->realEscapeSingle($_POST['order_id'])); } } if ( !empty( $cart_id ) and isset( $_POST["extend_and_pay_paypal"] ) and $settings['paypal'] == "1" ) { echo ''; } } if(isset($_POST['remove'])) { $cart_id = $_POST['cart_id']; if( isset( $_SESSION['CART'][$cart_id] ) ) { unset($_SESSION['CART'][$cart_id]); unset($_SESSION['coupon_id']); } $order_id = $_POST['order_id']; $db->query( "DELETE FROM OGP_DB_PREFIXbilling_orders WHERE order_id=".$db->realEscapeSingle($order_id) ); $orders_in_cart = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$db->realEscapeSingle($cart_id) ); if( !$orders_in_cart ) { $db->query( "DELETE FROM OGP_DB_PREFIXbilling_carts WHERE cart_id=".$db->realEscapeSingle($cart_id) ); } } ?>

Cart

resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_carts WHERE user_id=".$db->realEscapeSingle($user_id) ." order by cart_id desc" ); if( $user_carts >=1 ) { // SELECT WHAT KIND OF OLD INVOICES TO DISPLAY. WE NEED A BUTTON? foreach ( $user_carts as $user_cart ) { $cart_id = $user_cart['cart_id']; $carts[$cart_id] = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_carts AS cart JOIN OGP_DB_PREFIXbilling_orders AS orders ON orders.cart_id=cart.cart_id WHERE orders.status IN (0, -1 , -2) AND (cart.cart_id=".$db->realEscapeSingle($cart_id). ") order by order_id asc"); } } if( empty( $carts ) ) { print_failure( get_lang('there_are_no_orders_in_cart') ); ?>

1 ) $order['invoice_duration'] = $order['invoice_duration']."s"; $subtotal += ($order['price']* $order['max_players'] * $order['qty']); ?> 0) { $status = "Active" ; } //status is -1, invoice has been created elseif($order['status'] == -1) { $status = "Invoice Due"; } //invoice was not paid, server is expired and suspended elseif($order['status'] == -2) { $status = "Suspended"; } //display the expiration date and invoice button. if($order['status'] > 0){$warning_status = "". $formated_finish_date ."";} if($order['status'] == -1){$warning_status ="". $formated_finish_date ."";} if($order['status'] == -2){$warning_status ="". $formated_finish_date ."" ;} ?>
Status
getRemoteServer($order['ip']); echo "Order# ".$order['order_id'] . " ".$order['home_name']." Server ID ".$order['home_id'] ; ?> " . $order['max_players'] . " Slots
" . $order['qty'] . " " . $order['invoice_duration'] ; ?>
">
isAdmin( $_SESSION['user_id'] ); $result = $db->resultQuery("SELECT * FROM ogp_billing_orders WHERE user_id=".$user_id); $server_price = number_format( $order['price'], 2 ); if(isset($settings['display_free'])) { $display_free = $settings['display_free']; }else { $display_free = false; } if((($server_price < 0.05 )|| ($isAdmin)) && ($display_free)) //if($display_free) { if($isAdmin) { echo '
'; echo 'When created EDIT this server to assign a user'; } else { echo '
'; } } else{ if($settings['paypal'] == "1") echo ''; } ?>

Update Invoice'; echo ''; ?>
Amount
Discounted Subtotal
Tax Amount
"> ">
">