index.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. if (cfr('PASSIVE')) {
  3. $alterCfg = $ubillingConfig->getAlter();
  4. $FreezeDaysChargeEnabled = ( isset($alterCfg['FREEZE_DAYS_CHARGE_ENABLED']) && $alterCfg['FREEZE_DAYS_CHARGE_ENABLED'] );
  5. $makeRedirect = false;
  6. $FreezingAvailable = true;
  7. if (isset($_GET['username'])) {
  8. $login = vf($_GET['username']);
  9. if ($FreezeDaysChargeEnabled) {
  10. if (wf_CheckPost(array('newfreezedaysamnt'))) {
  11. simple_update_field('frozen_charge_days', 'freeze_days_amount', $_POST['newfreezedaysamnt'], "WHERE `login`='" . $login . "' ");
  12. log_register('CHANGE Freeze days amount (' . $login . ') ON ' . $_POST['newfreezedaysamnt']);
  13. $makeRedirect = true;
  14. }
  15. if (wf_CheckPost(array('newwrkdaystorestorefrzdays'))) {
  16. simple_update_field('frozen_charge_days', 'work_days_restore', $_POST['newwrkdaystorestorefrzdays'], "WHERE `login`='" . $login . "' ");
  17. log_register('CHANGE Workdays amount to restore freeze days (' . $login . ') ON ' . $_POST['newwrkdaystorestorefrzdays']);
  18. $makeRedirect = true;
  19. }
  20. }
  21. // change passive if need
  22. if (isset($_POST['newpassive'])) {
  23. $passive = $_POST['newpassive'];
  24. $billing->setpassive($login, $passive);
  25. log_register('CHANGE Passive (' . $login . ') ON ' . $passive);
  26. $makeRedirect = true;
  27. }
  28. if ($makeRedirect) {
  29. rcms_redirect("?module=passiveedit&username=" . $login);
  30. }
  31. $current_passive = zb_UserGetStargazerData($login);
  32. $current_passive = $current_passive['Passive'];
  33. $useraddress = zb_UserGetFullAddress($login) . ' (' . $login . ')';
  34. $form = '';
  35. $form2 = '';
  36. if ($FreezeDaysChargeEnabled) {
  37. $FrozenAllQuery = "SELECT * FROM `frozen_charge_days` WHERE `login` = '" . $login . "';";
  38. $FrozenAll = simple_queryall($FrozenAllQuery);
  39. if (!empty($FrozenAll)) {
  40. foreach ($FrozenAll as $usr => $usrlogin) {
  41. $FrzDaysAmount = $usrlogin['freeze_days_amount'];
  42. $FrzDaysUsed = $usrlogin['freeze_days_used'];
  43. $DaysWorked = $usrlogin['days_worked'];
  44. $WrkDaysToRestoreFrzDays = $usrlogin['work_days_restore'];
  45. $inputs = '';
  46. if (($FrzDaysUsed >= $FrzDaysAmount) && ($DaysWorked <= $WrkDaysToRestoreFrzDays)) {
  47. $FreezingAvailable = false;
  48. $inputs .= wf_tag('h3', false, '', 'style="color:#e95802; font-weight:600"');
  49. $inputs .= __('Changing freeze status is unavailable: total amount of freeze days used up');
  50. $inputs .= wf_tag('h3', true);
  51. }
  52. $cells = wf_TableCell(__('Freeze days used'), '', 'row2');
  53. $cells .= wf_TableCell($FrzDaysUsed, '', 'row2');
  54. $rows = wf_TableRow($cells);
  55. $cells = wf_TableCell(__('Freeze days available'), '', 'row2');
  56. $cells .= wf_TableCell($FrzDaysAmount - $FrzDaysUsed, '', 'row2');
  57. $rows .= wf_TableRow($cells);
  58. $cells = wf_TableCell(__('Days worked after freeze days used up'), '', 'row2');
  59. $cells .= wf_TableCell($DaysWorked, '', 'row2');
  60. $rows .= wf_TableRow($cells);
  61. $cells = wf_TableCell(__('Workdays left to restore'), '', 'row2');
  62. $cells .= wf_TableCell($WrkDaysToRestoreFrzDays - $DaysWorked, '', 'row2');
  63. $rows .= wf_TableRow($cells);
  64. $cells = wf_TableCell(__('Freeze days total amount'), '', 'row2');
  65. $cells .= wf_TableCell($FrzDaysAmount, '', 'row2');
  66. $cells .= wf_TableCell(wf_TextInput('newfreezedaysamnt', '', '', false, 40), '', 'row3');
  67. $rows .= wf_TableRow($cells);
  68. $cells = wf_TableCell(__('Workdays amount to restore freeze days'), '', 'row2');
  69. $cells .= wf_TableCell($WrkDaysToRestoreFrzDays, '', 'row2');
  70. $cells .= wf_TableCell(wf_TextInput('newwrkdaystorestorefrzdays', '', '', false, 40), '', 'row3');
  71. $rows .= wf_TableRow($cells);
  72. $table = wf_TableBody($rows, '100%', 0, '');
  73. $inputs .= $table;
  74. $inputs .= wf_Submit(__('Change'));
  75. $inputs .= wf_delimiter();
  76. $form2 = wf_Form("", 'POST', $inputs, '');
  77. }
  78. }
  79. }
  80. $freezingAllowed = true;
  81. $freezingDenyReason = '';
  82. if (@$alterCfg['DDT_ANTIFREEZE']) {
  83. // . .
  84. // |\_|\
  85. // | a_a\
  86. // | | "]
  87. // ____| '-\___
  88. // /.----.___.-'\
  89. // // _ \
  90. // // .-. (~v~) /|
  91. // |'| /\: .-- / \
  92. // // |-/ \_/____/\/~|
  93. // |/ \ | []_|_|_] \ |
  94. // | \ | \ |___ _\ ]_}
  95. // | | '-' / '.' |
  96. // | | / /|: |
  97. // | | | / |: /\
  98. // | | / / | / \
  99. // | | | / / | \
  100. // \ | |/\/ |/|/\ \
  101. // \|\ |\| | | / /\/\__\
  102. // \ \| | / | |__
  103. // / | |____)
  104. // |_/
  105. if (!cfr('SWRTZNGRFREEZE')) {
  106. $ddt = new DoomsDayTariffs(true);
  107. $protectedTariffs = $ddt->getCurrentTariffsDDT();
  108. $userData = zb_UserGetStargazerData($login);
  109. $userTariff = $userData['Tariff'];
  110. if (isset($protectedTariffs[$userTariff])) {
  111. $freezingAllowed = false;
  112. $freezingDenyReason .= __('This user uses one of doomsday tariffs') . '. ' . __('Freezing denied') . '.';
  113. }
  114. }
  115. }
  116. if ($freezingAllowed) {
  117. // Edit form construct
  118. $fieldname = __('Current passive state');
  119. $fieldkey = 'newpassive';
  120. $form .= web_EditorTrigerDataForm($fieldname, $fieldkey, $useraddress, $current_passive, !$FreezingAvailable);
  121. $form .= $form2;
  122. $form .= web_UserControls($login);
  123. } else {
  124. $messages = new UbillingMessageHelper();
  125. $form = $messages->getStyledMessage($freezingDenyReason, 'error');
  126. $form .= wf_delimiter();
  127. $form .= web_UserControls($login);
  128. }
  129. // show form
  130. show_window(__('Edit passive'), $form);
  131. } else {
  132. show_error(__('Something went wrong') . ': EX_NO_USERNAME');
  133. }
  134. } else {
  135. show_error(__('You cant control this module'));
  136. }
  137. ?>