Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

viewinvoice.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/usr/bin/php -q
  2. <?PHP
  3. require_once('lib/account.php');
  4. require_once('lib/common.php');
  5. require_once('lib/database.php');
  6. if (!isset($_GET['n']) || !ctype_digit($_GET['n'])) {
  7. header('Location: '.CP_PATH.'invoices');
  8. exit;
  9. }
  10. $sql = 'SELECT bill_due, bill_generated, bill_total, bill_paid FROM bills WHERE ';
  11. $sql .= 'bill_id = '.m($_GET['n']).' AND user_id = '.m(UID);
  12. $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  13. if (mysql_num_rows($res) != 1) {
  14. header('Location: '.CP_PATH.'invoices');
  15. exit;
  16. }
  17. $row = mysql_fetch_array($res);
  18. define('INVOICEID', str_pad($_GET['n'],5,'0',STR_PAD_LEFT));
  19. define('PAID', $row['bill_paid']);
  20. ?>
  21. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  22. <html>
  23. <head>
  24. <title>UTD-Hosting :: Invoice <?PHP echo INVOICEID; ?></title>
  25. <style type="text/css">
  26. body {
  27. padding: 75px 150px;
  28. font-family: "DejaVu Serif", serif;
  29. }
  30. th {
  31. text-align: right;
  32. }
  33. table.item {
  34. width: 100%;
  35. }
  36. table.item th { text-align: left; }
  37. h3,h2 {
  38. border-bottom: 1px solid #ccc;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <img src="<?PHP echo CP_PATH; ?>res/logo.png" alt="UTD-Hosting" id="logo">
  44. <h2>Invoice #<?PHP echo INVOICEID; ?></h2>
  45. <table>
  46. <tr>
  47. <th>Issued:</th>
  48. <td><?PHP echo date('r', $row['bill_generated']); ?></td>
  49. </tr>
  50. <tr>
  51. <th>Due:</th>
  52. <td><?PHP echo date('r', $row['bill_due']); ?></td>
  53. </tr>
  54. <tr>
  55. <th>Status:</th>
  56. <td><?PHP if ($row['bill_paid'] == 1) { echo 'Paid'; } else { echo 'Outstanding'; } ?></td>
  57. </tr>
  58. </table>
  59. <h3>Itemisation</h3>
  60. <table class="item">
  61. <tr><th>Description</th><th>Cost</th></tr>
  62. <?PHP
  63. $tot = 0;
  64. $sql = 'SELECT package_name, bi_cost FROM billitems NATURAL JOIN userpackages';
  65. $sql .= ' NATURAL JOIN packages WHERE bill_id = '.m($_GET['n']);
  66. $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  67. while ($row = mysql_fetch_array($res)) {
  68. echo '<tr><td>'.$row['package_name'].'</td><td>&pound;';
  69. echo money_format('%i',$row['bi_cost']/100);
  70. $tot += $row['bi_cost'];
  71. echo '</td></tr>';
  72. }
  73. ?>
  74. </table>
  75. <h3>Total</h3>
  76. <p>The total cost of this invoice is
  77. &pound;<?PHP echo money_format('%i',$tot/100); ?>.</p>
  78. <h3>Payment</h3>
  79. <?PHP
  80. if (PAID != 1) {
  81. ?>
  82. <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  83. <input type="hidden" name="cmd" value="_xclick">
  84. <input type="hidden" name="business" value="sales@utd-hosting.com">
  85. <input type="hidden" name="item_name" value="UTD-Hosting invoice #<?PHP echo INVOICEID; ?>">
  86. <input type="hidden" name="item_number" value="<?PHP echo INVOICEID; ?>">
  87. <input type="hidden" name="amount" value="<?PHP echo money_format('%i',$tot/100); ?>">
  88. <input type="hidden" name="no_shipping" value="1">
  89. <input type="hidden" name="no_note" value="1">
  90. <input type="hidden" name="currency_code" value="GBP">
  91. <input type="hidden" name="bn" value="PP-BuyNowBF">
  92. <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but02.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" style="float: right;">
  93. </form>
  94. <?PHP
  95. echo '<p>This invoice is outstanding. To pay this invoice using PayPal, ';
  96. echo 'please use the button to the right.';
  97. } else {
  98. echo '<p>This invoice has been paid. Thank you for using UTD-Hosting.';
  99. }
  100. ?>
  101. If you have any queries about this invoice, please e-mail
  102. sales@utd-hosting.com, including the invoice number and your account name.
  103. </p>
  104. </body>
  105. </html>