Skip to content

Commit

Permalink
DDT: forced charges history seems works
Browse files Browse the repository at this point in the history
  • Loading branch information
nightflyza committed Oct 5, 2024
1 parent 64be20c commit 56da253
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 11 deletions.
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.9 rev 9214
1.4.9 rev 9215
56 changes: 54 additions & 2 deletions api/libs/api.ddt.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ class DoomsDayTariffs {
*/
const URL_HIST = '?module=ddt&history=true';

/**
* Forced charges history URL
*/
const URL_CH_HIST = '&mode=fch';

/**
* Default user profile link URL
*/
Expand All @@ -167,6 +172,7 @@ class DoomsDayTariffs {
const TABLE_USERREG = 'userreg';

const ROUTE_CH_DELETE = 'deletechargeruleid';
const ROUTE_CH_HISTAJX = 'forcedchargehistoryajax';
const PROUTE_CH_CREATE = 'newchargetariffcreation';
const PROUTE_CH_TARIFF = 'newchargetariff';
const PROUTE_CH_UDAY = 'newchargeuntilday';
Expand Down Expand Up @@ -652,6 +658,7 @@ public function runProcessing() {
$nativeTariffData = $this->allTariffs[$currentUserTariff];
$nativeTariffFee = $nativeTariffData['Fee'];
$nativeTariffPeriod = (isset($nativeTariffData['period'])) ? $nativeTariffData['period'] : 'month';
log_register('DDT FEE CHARGE (' . $eachUserLogin . ') TARIFF `' . $currentUserTariff . '` ON -' . $nativeTariffFee);
zb_CashAdd($eachUserLogin, '-' . $nativeTariffFee, 'correct', 1, 'DDT: ' . $currentUserTariff);

//setting credit if required
Expand Down Expand Up @@ -703,7 +710,9 @@ public function renderControls() {
if (cfr('DDTCONF')) {
$result .= wf_Link(self::URL_ME, web_icon_extended() . ' ' . __('Configuration'), false, 'ubButton');
}
$result .= wf_Link(self::URL_HIST, wf_img('skins/icon_calendar.gif') . ' ' . __('History'), false, 'ubButton');
$result .= wf_Link(self::URL_HIST, wf_img('skins/icon_calendar.gif') . ' ' . __('Doomsday tariffs history'), false, 'ubButton');
$result .= wf_Link(self::URL_HIST . self::URL_CH_HIST, wf_img('skins/icon_dollar_16.gif') . ' ' . __('Forced charges history'), false, 'ubButton');

return ($result);
}

Expand Down Expand Up @@ -1035,7 +1044,7 @@ public function runChargeRules() {
}

//charging from user
log_register('DDT CHARGE (' . $eachUserLogin . ') TARIFF `' . $currentUserTariff . '` ON -' . $chargeFeeAmount);
log_register('DDT FORCED CHARGE (' . $eachUserLogin . ') TARIFF `' . $currentUserTariff . '` ON -' . $chargeFeeAmount);
$chargeComment = 'DDT: ' . $currentUserTariff;
zb_CashAdd($eachUserLogin, '-' . $chargeFeeAmount, 'correct', 1, $chargeComment);
$this->logCharge($eachUserLogin, $currentDate, $currentUserTariff, $chargeFeeAmount);
Expand All @@ -1048,4 +1057,47 @@ public function runChargeRules() {
}
}
}

/**
* Renders forced charges history report container
*
* @return string
*/
public function renderChargesHistoryContainer() {
$result = '';
if (!empty($this->allDDTUsers)) {
$opts = '"order": [[ 1, "desc" ]]';
$ajaxUrl = self::URL_ME . '&' . self::ROUTE_CH_HISTAJX . '=true';

$columns = array('User', 'Date', 'Tariff', 'Sum');
$result .= wf_JqDtLoader($columns, $ajaxUrl, false, __('Users'), 100, $opts);
} else {
$result .= $this->messages->getStyledMessage(__('There is nothing to watch'), 'warning');
}
return ($result);
}

/**
* Renders DDT history report json data
*
* @return void
*/
public function getChargesHistoryAjax() {
$json = new wf_JqDtHelper();
$allChargesHistory = $this->chargeHistDb->getAll();

if (!empty($allChargesHistory)) {
$userFullData = zb_UserGetAllDataCache();
foreach ($allChargesHistory as $io => $each) {
$userLink = isset($userFullData[$each['login']]) ? wf_Link(self::URL_PROFILE . $each['login'], web_profile_icon() . ' ' . $userFullData[$each['login']]['fulladress']) : $each['login'];
$data[] = $userLink;
$data[] = $each['chargedate'];
$data[] = $each['tariff'];
$data[] = $each['summ'];
$json->addRow($data);
unset($data);
}
}
$json->getJson();
}
}
2 changes: 2 additions & 0 deletions languages/russian/ddt.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@
$lang['def']['Additional amount'] = 'Дополнительная сума';
$lang['def']['Credit days'] = 'Дней кредита';
$lang['def']['rule for'] = 'правило для';
$lang['def']['Doomsday tariffs history'] = 'История тарифов судного дня';
$lang['def']['Forced charges history'] = 'История принудительных начислений';


2 changes: 2 additions & 0 deletions languages/ukrainian/ddt.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@
$lang['def']['Additional amount'] = 'Додаткова сума';
$lang['def']['Credit days'] = 'Днів кредиту';
$lang['def']['rule for'] = 'правило для';
$lang['def']['Doomsday tariffs history'] = 'Історія тарифів судного дня';
$lang['def']['Forced charges history'] = 'Історія примусових нарахувань';
28 changes: 20 additions & 8 deletions modules/general/ddt/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,35 @@
}
}

if (ubRouting::checkGet($ddt::ROUTE_CH_HISTAJX)) {
$ddt->getChargesHistoryAjax();
}

$avidity_m = $avidity['M']['ASAKO'];
show_window('', $ddt->$avidity_m());

if (!ubRouting::checkGet($avidity['Y']['TWELVE'])) {
// $avidity_m = $avidity['M']['JB'];
// show_window(__($avidity['L']['REM']), $ddt->$avidity_m());
$avidity_m = $avidity['M']['MEGUMIN'];
show_window(__($avidity['L']['RAM']), $ddt->$avidity_m());
show_window(__('Forced tariffs charge'), $ddt->renderChargeOpsList());
} else {
if (ubRouting::checkGet($avidity['V']['SAD'])) {
$avidity_m = $avidity['M']['BUTTRUE'];
$ddt->$avidity_m();
}
if (!ubRouting::checkGet('mode')) {
if (ubRouting::checkGet($avidity['V']['SAD'])) {
$avidity_m = $avidity['M']['BUTTRUE'];
$ddt->$avidity_m();
}

$avidity_m = $avidity['M']['SUBARU'];
show_window(__($avidity['L']['LYAK']), $ddt->$avidity_m(ubRouting::get($avidity['V']['ZHEKA'])));
$avidity_m = $avidity['M']['SUBARU'];
show_window(__($avidity['L']['LYAK']), $ddt->$avidity_m(ubRouting::get($avidity['V']['ZHEKA'])));
} else {
$hMode=ubRouting::get('mode','gigasafe');
switch ($hMode) {
case 'fch':
show_window(__('Forced charges history'),$ddt->renderChargesHistoryContainer());
break;
}

}
}
zb_BillingStats(true);
} else {
Expand Down

0 comments on commit 56da253

Please sign in to comment.