bill.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. function exec_ogp_module()
  3. {
  4. //Include database connection details
  5. require('includes/config.inc.php');
  6. global $db,$view,$settings;
  7. if(isset($_GET['type']) && $_GET['type'] == 'cleared')
  8. {
  9. echo '<body onload="window.print()" >';
  10. $view->setCharset(get_lang('lang_charset'));
  11. }
  12. $user_id = $_SESSION['user_id'];
  13. $cart_id = $_POST['cart_id'];
  14. $isAdmin = $db->isAdmin( $_SESSION['user_id'] );
  15. if ( $isAdmin )
  16. $orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
  17. else
  18. $orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id." AND user_id=".$user_id );
  19. $cart = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_carts WHERE cart_id=".$cart_id );
  20. if( !empty($orders) )
  21. {
  22. ?>
  23. <br><br>
  24. <table width="772" height="438" border="0" style="color:#000000" bgcolor="#FFFFFF">
  25. <tr bgcolor="#000000">
  26. <td colspan="5" align="center" style="color:white">
  27. <p style="font-size:18pt"><b><?php print_lang("invoice");?></b></p>
  28. </td>
  29. </tr>
  30. <tr>
  31. <td height="21" colspan="5">&nbsp;</td>
  32. </tr>
  33. <tr>
  34. <td width="150" height="21" align="left"><?php print_lang("business");?>:<br><b><?php echo "<b>".$settings['panel_name']."</b>"; ?></td>
  35. <td colspan="2" rowspan="3">&nbsp;</td>
  36. <td colspan="2" rowspan="3"><img width="300" height="100" src="images/banner.gif"></td>
  37. </tr>
  38. <tr>
  39. <td width="150" height="21" align="left"><?php print_lang("business_email");?>:<br><?php echo "<b>".$settings['panel_email_address']."</b>"; ?></td>
  40. </tr>
  41. <tr>
  42. <td height="23" colspan="5">&nbsp;</td>
  43. </tr>
  44. <tr>
  45. <td height="23" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("item");?></strong></div></td>
  46. <td width="150" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("invoice_duration");?></strong></div></td>
  47. <td width="150" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("slot_cost");?></strong></div></td>
  48. <td style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("slot_quantity");?></strong></div></td>
  49. <td style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("order_price");?></strong></div></td>
  50. </tr>
  51. <?php
  52. $subtotal = 0;
  53. foreach($orders as $order)
  54. {
  55. $order_id = $order['order_id'];
  56. $user_id = $order['user_id'];
  57. $service_id = $order['service_id'];
  58. $home_name = $order['home_name']." - ".$order_id;
  59. $ip = $order['ip'];
  60. $max_players = $order['max_players'];
  61. $qty = $order['qty'];
  62. $invoice_duration = $order['invoice_duration'];
  63. $price = $order['price'];
  64. $subtotal += $price;
  65. $qry_service = "SELECT DISTINCT price_hourly, price_monthly, price_year FROM ".$table_prefix."billing_services WHERE service_id=".$service_id;
  66. $result_service = $db->resultQuery($qry_service);
  67. $row_service = $result_service[0];
  68. //Calculating Costs
  69. if ($invoice_duration == "hour")
  70. {
  71. $price_slot=$row_service['price_hourly'];
  72. }
  73. elseif ($invoice_duration == "month")
  74. {
  75. $price_slot=$row_service['price_monthly'];
  76. }
  77. elseif ($invoice_duration == "year")
  78. {
  79. $price_slot=$row_service['price_year']*12;
  80. }
  81. $duration = $invoice_duration > 1 ? $invoice_duration."s":$invoice_duration;
  82. ?>
  83. <tr>
  84. <td height="23"><?php echo $order['home_name']; ?></td>
  85. <td><?php echo $qty." ".get_lang($duration); ?></td>
  86. <td><?php echo number_format( $price_slot, 2 )." ".$settings['currency']."/".get_lang($invoice_duration); ?></td>
  87. <td><?php echo $max_players; ?></td>
  88. <td><?php echo number_format( $price, 2 )." ".$settings['currency']; ?></td>
  89. </tr><?php
  90. }
  91. $total = $subtotal+($cart[0]['tax_amount']/100*$subtotal);
  92. ?>
  93. <tr>
  94. <td height="24" colspan="5">&nbsp;</td>
  95. </tr>
  96. <tr>
  97. <td colspan="3" rowspan="4">&nbsp;</td>
  98. <td height="23" style="border: 2px solid #000000"><div align="right"><strong><?php print_lang("subtotal");?> : </strong></div></td>
  99. <td style="border: 2px solid #000000"><?php echo number_format( $subtotal, 2 )." ".$settings['currency']; ?></td>
  100. </tr>
  101. <tr>
  102. <td height="23" style="border: 2px solid #000000"><div align="right"><strong><?php print_lang("tax");?> : </strong></div></td>
  103. <td style="border: 2px solid #000000"><?php echo $cart[0]['tax_amount']."%"; ?></td>
  104. </tr>
  105. <tr>
  106. <td height="23" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="right"><strong><?php print_lang("total");?> : </strong></div></td>
  107. <td style="border: 2px solid #000000" bgcolor="#CCCCCC"><?php echo $total." ".$settings['currency']; ?></td>
  108. </tr>
  109. <tr>
  110. <td height="23" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="right"><strong><?php print_lang("cart_id");?> : </strong></div></td>
  111. <td style="border: 2px solid #000000" ><?php echo $cart_id; ?></td>
  112. </tr>
  113. <tr>
  114. <td height="23" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="right"><strong><?php print_lang("date");?> : </strong></div></td>
  115. <td style="border: 2px solid #000000"><?php echo $cart[0]['date']; ?></td>
  116. </tr>
  117. <tr>
  118. <td height="21" colspan="2">&nbsp;</td>
  119. </tr>
  120. </table>
  121. <br><br>
  122. <form method='post' action='?m=billing&p=bill&type=cleared' >
  123. <input type="hidden" name="cart_id" value="<?php echo $_POST['cart_id'];?>">
  124. <input type="submit" value="<?php print_lang('print_invoice') ?>" />
  125. </form>
  126. <form method='post' action='?m=billing&p=<?php
  127. $isAdmin = $db->isAdmin($_SESSION['user_id']);
  128. if ($isAdmin)
  129. {
  130. echo 'orders';
  131. }
  132. else
  133. {
  134. echo 'cart';
  135. }
  136. echo "'><input type='submit' value='";
  137. print_lang('back');
  138. ?>'/>
  139. </form>
  140. <br><br><?php
  141. }
  142. }
  143. ?>