@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | //add filter for item type user roles by current user role |
| 37 | 37 | $selectOptions['where'][] = [ |
| 38 | - [Item\Offer\Price\Type::index(), NULL, 'is'], |
|
| 38 | + [Item\Offer\Price\Type::index(), null, 'is'], |
|
| 39 | 39 | [ |
| 40 | 40 | [Item\Offer\Price\Type::colPrefix() . 'roles', '', '=', 'OR'], |
| 41 | 41 | [Item\Offer\Price\Type::colPrefix() . 'roles', '%|' . \Users\User::$cur->role_id . '|%', 'LIKE', 'OR'], |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <div class="filters"> |
| 2 | 2 | <form> |
| 3 | 3 | <?php |
| 4 | - $min = App::$cur->ecommerce->getItems(['sort' => ['price' => 'asc'], 'count' => 1, 'key' => false]); |
|
| 5 | - $max = App::$cur->ecommerce->getItems(['sort' => ['price' => 'desc'], 'count' => 1, 'key' => false]); |
|
| 6 | - if ($min && $min[0]->getPrice() && $max && $max[0]->getPrice()) { |
|
| 7 | - ?> |
|
| 4 | + $min = App::$cur->ecommerce->getItems(['sort' => ['price' => 'asc'], 'count' => 1, 'key' => false]); |
|
| 5 | + $max = App::$cur->ecommerce->getItems(['sort' => ['price' => 'desc'], 'count' => 1, 'key' => false]); |
|
| 6 | + if ($min && $min[0]->getPrice() && $max && $max[0]->getPrice()) { |
|
| 7 | + ?> |
|
| 8 | 8 | <label>Фильтр по цене</label> |
| 9 | 9 | <div class="form-group"> |
| 10 | 10 | <div class="row"> |
@@ -18,24 +18,24 @@ discard block |
||
| 18 | 18 | ?> |
| 19 | 19 | <div class="filter"> |
| 20 | 20 | <?php |
| 21 | - switch ($option->type) { |
|
| 22 | - case 'radio': |
|
| 21 | + switch ($option->type) { |
|
| 22 | + case 'radio': |
|
| 23 | 23 | echo "<label>{$option->name}</label>"; |
| 24 | - foreach ($option->items as $item) { |
|
| 25 | - $this->widget('Ui\Form/' . $option->type, [ |
|
| 26 | - 'label' => $item->name, |
|
| 27 | - 'name' => "filters[options][{$option->id}]", |
|
| 28 | - !empty($_GET['filters']['options'][$option->id]) && $_GET['filters']['options'][$option->id] == $item->id ? 'checked' : false, |
|
| 29 | - 'options' => [ |
|
| 30 | - 'value' => $item->id, |
|
| 31 | - ] |
|
| 32 | - ]); |
|
| 33 | - } |
|
| 34 | - break; |
|
| 35 | - case 'select': |
|
| 24 | + foreach ($option->items as $item) { |
|
| 25 | + $this->widget('Ui\Form/' . $option->type, [ |
|
| 26 | + 'label' => $item->name, |
|
| 27 | + 'name' => "filters[options][{$option->id}]", |
|
| 28 | + !empty($_GET['filters']['options'][$option->id]) && $_GET['filters']['options'][$option->id] == $item->id ? 'checked' : false, |
|
| 29 | + 'options' => [ |
|
| 30 | + 'value' => $item->id, |
|
| 31 | + ] |
|
| 32 | + ]); |
|
| 33 | + } |
|
| 34 | + break; |
|
| 35 | + case 'select': |
|
| 36 | 36 | echo "<label>{$option->name}</label>"; |
| 37 | - foreach ($option->items as $item) { |
|
| 38 | - ?> |
|
| 37 | + foreach ($option->items as $item) { |
|
| 38 | + ?> |
|
| 39 | 39 | <div class="radio"> |
| 40 | 40 | <label> |
| 41 | 41 | <input type="checkbox" name = 'filters[options][<?= $option->id; ?>][]' value ="<?= $item->id; ?>" <?= !empty($_GET['filters']['options'][$option->id]) && in_array($item->id, $_GET['filters']['options'][$option->id]) ? 'checked' : ''; ?>> |
@@ -16,34 +16,34 @@ discard block |
||
| 16 | 16 | 'type' => 'decimal' |
| 17 | 17 | ] |
| 18 | 18 | ], |
| 19 | - 'viewer' => function($level) {
|
|
| 19 | + 'viewer' => function($level) { |
|
| 20 | 20 | $levelTypes = [ |
| 21 | 21 | 'procent' => 'Процент', |
| 22 | 22 | 'amount' => 'Сумма', |
| 23 | 23 | ]; |
| 24 | 24 | return $levelTypes[$level->params['type']->value] . ': ' . $level->params['amount']->value . ' ' . ($level->params['type']->value == 'procent' ? '%' : ($level->params['currency_id']->value ? \Money\Currency::get($level->params['currency_id']->value)->acronym() : '')); |
| 25 | 25 | }, |
| 26 | - 'rewarder' => function($reward, $sums, $user, $rootUser, $level, $rewardGet) {
|
|
| 26 | + 'rewarder' => function($reward, $sums, $user, $rootUser, $level, $rewardGet) { |
|
| 27 | 27 | $wallets = \App::$cur->money->getUserWallets($user->id); |
| 28 | 28 | $amount = 0; |
| 29 | -if (!empty($wallets[$level->params['currency_id']->value])) {
|
|
| 30 | - switch ($level->params['type']->value) {
|
|
| 29 | +if (!empty($wallets[$level->params['currency_id']->value])) { |
|
| 30 | + switch ($level->params['type']->value) { |
|
| 31 | 31 | case 'procent': |
| 32 | 32 | $finalSum = 0; |
| 33 | - foreach ($sums as $currency_id => $sum) {
|
|
| 34 | - if ($currency_id != $level->params['currency_id']->value) {
|
|
| 33 | + foreach ($sums as $currency_id => $sum) { |
|
| 34 | + if ($currency_id != $level->params['currency_id']->value) { |
|
| 35 | 35 | $rate = \Money\Currency\ExchangeRate::get([ |
| 36 | 36 | ['currency_id', $currency_id], |
| 37 | 37 | ['target_currency_id', $level->params['currency_id']->value], |
| 38 | 38 | ]); |
| 39 | - if ($rate) {
|
|
| 39 | + if ($rate) { |
|
| 40 | 40 | $finalSum += $sum * $rate->rate; |
| 41 | 41 | } |
| 42 | - } else {
|
|
| 42 | + } else { |
|
| 43 | 43 | $finalSum += $sum; |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - switch ($reward->round_type) {
|
|
| 46 | + switch ($reward->round_type) { |
|
| 47 | 47 | case 'round': |
| 48 | 48 | $finalSum = round($finalSum, $reward->round_precision); |
| 49 | 49 | $amount = $finalSum / 100 * (float) $level->params['amount']->value; |
@@ -59,33 +59,33 @@ discard block |
||
| 59 | 59 | case 'amount': |
| 60 | 60 | $amount = (float) $level->params['amount']->value; |
| 61 | 61 | } |
| 62 | - if (!$amount) {
|
|
| 62 | + if (!$amount) { |
|
| 63 | 63 | return 0; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $text = 'Вознаграждение по программе "' . $reward->name . '"'; |
| 67 | - if ($rootUser->id != $user->id) {
|
|
| 67 | + if ($rootUser->id != $user->id) { |
|
| 68 | 68 | $text .= ' от ' . $rootUser->name(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if (!$rewardGet && $reward->block) {
|
|
| 71 | + if (!$rewardGet && $reward->block) { |
|
| 72 | 72 | $block = new \Money\Wallet\Block(); |
| 73 | 73 | $block->wallet_id = $wallets[$level->params['currency_id']->value]->id; |
| 74 | 74 | $block->amount = $amount; |
| 75 | 75 | $block->comment = $text; |
| 76 | 76 | $block->data = 'reward:' . $reward->id; |
| 77 | 77 | $dateGenerators = \App::$cur->money->getSnippets('expiredDateGenerator');
|
| 78 | - if ($reward->block_date_expired && !empty($dateGenerators[$reward->block_date_expired])) {
|
|
| 78 | + if ($reward->block_date_expired && !empty($dateGenerators[$reward->block_date_expired])) { |
|
| 79 | 79 | $date = $dateGenerators[$reward->block_date_expired]($reward, $user); |
| 80 | - if (!empty($date['date'])) {
|
|
| 80 | + if (!empty($date['date'])) { |
|
| 81 | 81 | $block->date_expired = $date['date']; |
| 82 | 82 | } |
| 83 | - if (!empty($date['type'])) {
|
|
| 83 | + if (!empty($date['type'])) { |
|
| 84 | 84 | $block->expired_type = $date['type']; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | $block->save(); |
| 88 | - } else {
|
|
| 88 | + } else { |
|
| 89 | 89 | $wallets[$level->params['currency_id']->value]->diff($amount, $text); |
| 90 | 90 | } |
| 91 | 91 | \App::$cur->users->AddUserActivity($user->id, 4, $text . '<br />' . $amount . ' ' . $wallets[$level->params['currency_id']->value]->currency->acronym()); |
@@ -2,17 +2,17 @@ discard block |
||
| 2 | 2 | <?php |
| 3 | 3 | $currency_id = !empty($_GET['currency_id']) ? (int) $_GET['currency_id'] : 0; |
| 4 | 4 | $wallets = App::$cur->money->getUserWallets(); |
| 5 | -if ($currency_id && empty($wallets[$currency_id])) {
|
|
| 5 | +if ($currency_id && empty($wallets[$currency_id])) { |
|
| 6 | 6 | Msg::add('У вас нет такого кошелька');
|
| 7 | 7 | Msg::show(); |
| 8 | 8 | return; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -if ($currency_id) {
|
|
| 11 | +if ($currency_id) { |
|
| 12 | 12 | $ids = $wallets[$currency_id]->id; |
| 13 | -} else {
|
|
| 13 | +} else { |
|
| 14 | 14 | $ids = []; |
| 15 | - foreach ($wallets as $wallet) {
|
|
| 15 | + foreach ($wallets as $wallet) { |
|
| 16 | 16 | $ids[] = $wallet->id; |
| 17 | 17 | } |
| 18 | 18 | $ids = implode(',', $ids);
|
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'start' => $pages->params['start'], |
| 34 | 34 | 'limit' => $pages->params['limit'], |
| 35 | 35 | ]); |
| 36 | -foreach ($histories as $history) {
|
|
| 36 | +foreach ($histories as $history) { |
|
| 37 | 37 | $amount = $history->amount ? $history->amount : $history->new - $history->old; |
| 38 | 38 | $table->addRow([ |
| 39 | 39 | $history->id, |
@@ -2,17 +2,17 @@ discard block |
||
| 2 | 2 | <?php |
| 3 | 3 | $currency_id = !empty($_GET['currency_id']) ? (int) $_GET['currency_id'] : 0; |
| 4 | 4 | $wallets = App::$cur->money->getUserWallets(); |
| 5 | -if ($currency_id && empty($wallets[$currency_id])) {
|
|
| 5 | +if ($currency_id && empty($wallets[$currency_id])) { |
|
| 6 | 6 | Msg::add('У вас нет такого кошелька');
|
| 7 | 7 | Msg::show(); |
| 8 | 8 | return; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -if ($currency_id) {
|
|
| 11 | +if ($currency_id) { |
|
| 12 | 12 | $ids = $wallets[$currency_id]->id; |
| 13 | -} else {
|
|
| 13 | +} else { |
|
| 14 | 14 | $ids = []; |
| 15 | - foreach ($wallets as $wallet) {
|
|
| 15 | + foreach ($wallets as $wallet) { |
|
| 16 | 16 | $ids[] = $wallet->id; |
| 17 | 17 | } |
| 18 | 18 | $ids = implode(',', $ids);
|
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'start' => $pages->params['start'], |
| 34 | 34 | 'limit' => $pages->params['limit'], |
| 35 | 35 | ]); |
| 36 | -foreach ($histories as $history) {
|
|
| 36 | +foreach ($histories as $history) { |
|
| 37 | 37 | $amount = $history->amount ? $history->amount : $history->new - $history->old; |
| 38 | 38 | $table->addRow([ |
| 39 | 39 | $history->id, |
@@ -13,11 +13,11 @@ |
||
| 13 | 13 | |
| 14 | 14 | class Mysql extends \Object { |
| 15 | 15 | |
| 16 | - public $config = []; // настройки подключения выбраной базы |
|
| 17 | - public $connect = false; // ярлык соединения с MySQL |
|
| 18 | - public $encoding = 'utf-8'; // установленная кодировка |
|
| 19 | - public $db_name = 'test'; // выбраная в данный момент база |
|
| 20 | - public $table_prefix = 'inji_'; // префикс названий таблиц |
|
| 16 | + public $config = []; // настройки подключения выбраной базы |
|
| 17 | + public $connect = false; // ярлык соединения с MySQL |
|
| 18 | + public $encoding = 'utf-8'; // установленная кодировка |
|
| 19 | + public $db_name = 'test'; // выбраная в данный момент база |
|
| 20 | + public $table_prefix = 'inji_'; // префикс названий таблиц |
|
| 21 | 21 | public $pdo = null; |
| 22 | 22 | public $lastQuery = ''; |
| 23 | 23 | public $last_error = ''; |