index.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. if ( cfr('SIGNUPPRICES') ) {
  3. global $ubillingConfig;
  4. $alter = $ubillingConfig->getAlter();
  5. if ( isset($alter['SIGNUP_PAYMENTS']) && !empty($alter['SIGNUP_PAYMENTS']) ) {
  6. if ( isset($_GET['tariff']) ) {
  7. $tariff = mysql_real_escape_string($_GET['tariff']);
  8. $prices = zb_TariffGetAllSignupPrices();
  9. if ( !isset($prices[$tariff]) ) {
  10. zb_TariffCreateSignupPrice($tariff, 0);
  11. $prices = zb_TariffGetAllSignupPrices();
  12. }
  13. if ( isset($_POST['new_price']) ) {
  14. zb_TariffDeleteSignupPrice($tariff);
  15. zb_TariffCreateSignupPrice($tariff, $_POST['new_price']);
  16. rcms_redirect("?module=signupprices");
  17. }
  18. $form = '<form action="" method="POST">
  19. <table width="100%" border="0">
  20. <tr>
  21. <td class="row2">' . __('Signup price') . '</td>
  22. <td class="row3">
  23. <input type="text" name="new_price" value="' . $prices[$tariff] . '">
  24. </td>
  25. </tr>
  26. </table>
  27. <input type="submit" value="' . __('Change') . '">
  28. </form><br><br>';
  29. show_window(__('Edit signup price for tariff') . ' "' . $tariff . '"', $form);
  30. show_window('', wf_Link("?module=signupprices", 'Back', true, 'ubButton'));
  31. } elseif ( isset($_GET['username']) ) {
  32. $login = mysql_real_escape_string($_GET['username']);
  33. $has_paid = zb_UserGetSignupPricePaid($login);
  34. $old_price = zb_UserGetSignupPrice($login);
  35. $new_price = isset($_POST['new_price']) ? mysql_real_escape_string($_POST['new_price']) : null;
  36. if ( !is_null($new_price) ) {
  37. if ( $new_price >= $has_paid ) {
  38. $cash = $old_price - $new_price;
  39. zb_UserChangeSignupPrice($login, $new_price);
  40. $billing->addcash($login, $cash);
  41. log_register("CHARGE SignupPriceFee(" . $login . ") " . $cash);
  42. rcms_redirect("?module=useredit&username=" . $login);
  43. } else {
  44. show_window('', wf_modalOpened(__('Error'), __('You may not setup connection payment less then user has already paid!'), '400', '150'));
  45. }
  46. }
  47. $form = '<form action="" method="POST">
  48. <table width="100%" border="0">
  49. <tr>
  50. <td class="row2">' . __('Signup price') . '</td>
  51. <td class="row3">
  52. <input type="text" name="new_price" value="' . $old_price . '">
  53. </td>
  54. </tr>
  55. </table>
  56. <input type="submit" value="' . __('Change') . '">
  57. </form><br><br>';
  58. show_window(__('Edit signup price for user') . ' "' . $login . '"', $form);
  59. show_window('', wf_Link("?module=useredit&username=" . $login, 'Back', true, 'ubButton'));
  60. } else {
  61. $query = "SELECT `name` FROM `tariffs`";
  62. $tariffs = simple_queryall($query);
  63. $prices = zb_TariffGetAllSignupPrices();
  64. $form = '<table width="100%" class="sortable" border="0">';
  65. $form.='<tr class="row1"><td>'.__('Tariff').'</td><td>'.__('Signup price').'</td><td>'.__('Actions').'</td></tr>';
  66. if ( !empty($tariffs) ) {
  67. foreach ( $tariffs as $tariff ) {
  68. $form .= '
  69. <tr class="row3">
  70. <td>' . $tariff['name'] . '</td>
  71. <td>' . ( isset($prices[$tariff['name']]) ? $prices[$tariff['name']] : '0' ) . '</td>
  72. <td>
  73. <a href="?module=signupprices&tariff=' . $tariff['name'] . '">' . wf_img('skins/icons/register.png', __('Edit signup price')) . '</a>
  74. </td>
  75. </tr>
  76. ';
  77. }
  78. }
  79. $form .= '</table>';
  80. show_window(__('Signup price'), $form);
  81. }
  82. }
  83. }