123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php
- if (cfr('PASSIVE')) {
- $alterCfg = $ubillingConfig->getAlter();
- $FreezeDaysChargeEnabled = ( isset($alterCfg['FREEZE_DAYS_CHARGE_ENABLED']) && $alterCfg['FREEZE_DAYS_CHARGE_ENABLED'] );
- $makeRedirect = false;
- $FreezingAvailable = true;
- if (isset($_GET['username'])) {
- $login = vf($_GET['username']);
- if ($FreezeDaysChargeEnabled) {
- if (wf_CheckPost(array('newfreezedaysamnt'))) {
- simple_update_field('frozen_charge_days', 'freeze_days_amount', $_POST['newfreezedaysamnt'], "WHERE `login`='" . $login . "' ");
- log_register('CHANGE Freeze days amount (' . $login . ') ON ' . $_POST['newfreezedaysamnt']);
- $makeRedirect = true;
- }
- if (wf_CheckPost(array('newwrkdaystorestorefrzdays'))) {
- simple_update_field('frozen_charge_days', 'work_days_restore', $_POST['newwrkdaystorestorefrzdays'], "WHERE `login`='" . $login . "' ");
- log_register('CHANGE Workdays amount to restore freeze days (' . $login . ') ON ' . $_POST['newwrkdaystorestorefrzdays']);
- $makeRedirect = true;
- }
- }
- // change passive if need
- if (isset($_POST['newpassive'])) {
- $passive = $_POST['newpassive'];
- $billing->setpassive($login, $passive);
- log_register('CHANGE Passive (' . $login . ') ON ' . $passive);
- $makeRedirect = true;
- }
- if ($makeRedirect) {
- rcms_redirect("?module=passiveedit&username=" . $login);
- }
- $current_passive = zb_UserGetStargazerData($login);
- $current_passive = $current_passive['Passive'];
- $useraddress = zb_UserGetFullAddress($login) . ' (' . $login . ')';
- $form = '';
- $form2 = '';
- if ($FreezeDaysChargeEnabled) {
- $FrozenAllQuery = "SELECT * FROM `frozen_charge_days` WHERE `login` = '" . $login . "';";
- $FrozenAll = simple_queryall($FrozenAllQuery);
- if (!empty($FrozenAll)) {
- foreach ($FrozenAll as $usr => $usrlogin) {
- $FrzDaysAmount = $usrlogin['freeze_days_amount'];
- $FrzDaysUsed = $usrlogin['freeze_days_used'];
- $DaysWorked = $usrlogin['days_worked'];
- $WrkDaysToRestoreFrzDays = $usrlogin['work_days_restore'];
- $inputs = '';
- if (($FrzDaysUsed >= $FrzDaysAmount) && ($DaysWorked <= $WrkDaysToRestoreFrzDays)) {
- $FreezingAvailable = false;
- $inputs .= wf_tag('h3', false, '', 'style="color:#e95802; font-weight:600"');
- $inputs .= __('Changing freeze status is unavailable: total amount of freeze days used up');
- $inputs .= wf_tag('h3', true);
- }
- $cells = wf_TableCell(__('Freeze days used'), '', 'row2');
- $cells .= wf_TableCell($FrzDaysUsed, '', 'row2');
- $rows = wf_TableRow($cells);
- $cells = wf_TableCell(__('Freeze days available'), '', 'row2');
- $cells .= wf_TableCell($FrzDaysAmount - $FrzDaysUsed, '', 'row2');
- $rows .= wf_TableRow($cells);
- $cells = wf_TableCell(__('Days worked after freeze days used up'), '', 'row2');
- $cells .= wf_TableCell($DaysWorked, '', 'row2');
- $rows .= wf_TableRow($cells);
- $cells = wf_TableCell(__('Workdays left to restore'), '', 'row2');
- $cells .= wf_TableCell($WrkDaysToRestoreFrzDays - $DaysWorked, '', 'row2');
- $rows .= wf_TableRow($cells);
- $cells = wf_TableCell(__('Freeze days total amount'), '', 'row2');
- $cells .= wf_TableCell($FrzDaysAmount, '', 'row2');
- $cells .= wf_TableCell(wf_TextInput('newfreezedaysamnt', '', '', false, 40), '', 'row3');
- $rows .= wf_TableRow($cells);
- $cells = wf_TableCell(__('Workdays amount to restore freeze days'), '', 'row2');
- $cells .= wf_TableCell($WrkDaysToRestoreFrzDays, '', 'row2');
- $cells .= wf_TableCell(wf_TextInput('newwrkdaystorestorefrzdays', '', '', false, 40), '', 'row3');
- $rows .= wf_TableRow($cells);
- $table = wf_TableBody($rows, '100%', 0, '');
- $inputs .= $table;
- $inputs .= wf_Submit(__('Change'));
- $inputs .= wf_delimiter();
- $form2 = wf_Form("", 'POST', $inputs, '');
- }
- }
- }
- $freezingAllowed = true;
- $freezingDenyReason = '';
- if (@$alterCfg['DDT_ANTIFREEZE']) {
- // . .
- // |\_|\
- // | a_a\
- // | | "]
- // ____| '-\___
- // /.----.___.-'\
- // // _ \
- // // .-. (~v~) /|
- // |'| /\: .-- / \
- // // |-/ \_/____/\/~|
- // |/ \ | []_|_|_] \ |
- // | \ | \ |___ _\ ]_}
- // | | '-' / '.' |
- // | | / /|: |
- // | | | / |: /\
- // | | / / | / \
- // | | | / / | \
- // \ | |/\/ |/|/\ \
- // \|\ |\| | | / /\/\__\
- // \ \| | / | |__
- // / | |____)
- // |_/
- if (!cfr('SWRTZNGRFREEZE')) {
- $ddt = new DoomsDayTariffs(true);
- $protectedTariffs = $ddt->getCurrentTariffsDDT();
- $userData = zb_UserGetStargazerData($login);
- $userTariff = $userData['Tariff'];
- if (isset($protectedTariffs[$userTariff])) {
- $freezingAllowed = false;
- $freezingDenyReason .= __('This user uses one of doomsday tariffs') . '. ' . __('Freezing denied') . '.';
- }
- }
- }
- if ($freezingAllowed) {
- // Edit form construct
- $fieldname = __('Current passive state');
- $fieldkey = 'newpassive';
- $form .= web_EditorTrigerDataForm($fieldname, $fieldkey, $useraddress, $current_passive, !$FreezingAvailable);
- $form .= $form2;
- $form .= web_UserControls($login);
- } else {
- $messages = new UbillingMessageHelper();
- $form = $messages->getStyledMessage($freezingDenyReason, 'error');
- $form .= wf_delimiter();
- $form .= web_UserControls($login);
- }
- // show form
- show_window(__('Edit passive'), $form);
- } else {
- show_error(__('Something went wrong') . ': EX_NO_USERNAME');
- }
- } else {
- show_error(__('You cant control this module'));
- }
- ?>
|