Skip to content

Commit

Permalink
fixing showing domain price, not finished
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Feb 4, 2016
1 parent a815bbd commit f7d6466
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
38 changes: 9 additions & 29 deletions src/controllers/DomainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
* @copyright Copyright (c) 2014-2015, HiQDev (http://hiqdev.com/)
*/

/**
* @link http://hiqdev.com/hipanel-module-domain
*
* @license http://hiqdev.com/hipanel-module-domain/license
* @copyright Copyright (c) 2015 HiQDev
*/
namespace hipanel\modules\domain\controllers;

use hipanel\actions\Action;
Expand Down Expand Up @@ -547,28 +541,11 @@ public function actionCheck()
'state' => 'unavailable'
]);
} else {
// $tariffs = Tariff::find(['scenario' => 'get-available-info'])
// ->joinWith('resources')
// ->andFilterWhere(['type' => 'domain'])
// ->andFilterWhere(['seller' => 'ahnames'])
// ->one();
// $zones = array_filter($tariffs->resources ?: [], function ($resource) {
// return ($resource->zone !== null && $resource->type === Resource::TYPE_DOMAIN_REGISTRATION);
// });
// foreach ($zones as $resource) {
// if ($resource->zone === $line['zone']) {
// $line['tariff'] = $resource;
// break;
// }
// }

return $this->renderAjax('_checkDomainLine', [
'line' => $line,
'state' => 'available'
]);
}


} else {
Yii::$app->end();
}
Expand All @@ -586,12 +563,13 @@ public function actionCheckDomain()
->andFilterWhere(['type' => 'domain'])
->andFilterWhere(['seller' => 'ahnames'])
->one();
$zones = array_filter($tariffs->resources ?: [], function ($resource) {
return ($resource->zone !== null && $resource->type === Resource::TYPE_DOMAIN_REGISTRATION);
});
$resources = [];
$dropDownZones = [];
foreach ($zones as $resource) {
$dropDownZones[$resource->zone] = '.' . $resource->zone;
foreach ($tariffs->resources as $resource) {
if ($resource->zone && $resource->type === Resource::TYPE_DOMAIN_REGISTRATION) {
$dropDownZones[$resource->zone] = '.' . $resource->zone;
$resources[$resource->zone] = $resource;
}
}
uasort($dropDownZones, function($a, $b) { return $a === '.com' ? 0 : 1; });
if ($model->load(Yii::$app->request->get()) && !empty($dropDownZones)) {
Expand All @@ -616,10 +594,12 @@ public function actionCheckDomain()
$domains = array_diff($domains, [$requestedDomain]);
array_unshift($domains, $requestedDomain);
foreach ($domains as $domain) {
$zone = substr($domain, strpos($domain, '.') + 1);
$results[] = [
'domain' => $model->domain,
'full_domain_name' => $domain,
'zone' => substr($domain, strpos($domain, '.') + 1),
'zone' => $zone,
'resource' => $resources[$zone],
];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/views/domain/_checkDomainLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class="domain-zone muted">.<?= $line['zone'] ?></span>
<span class="domain-price">
<?php if ($state === 'available') : ?>
<!--del>0.00 €</del-->
<?= Yii::$app->formatter->format($line['tariff']->price, ['currency', $line['tariff']->currency]) ?>
<?= Yii::$app->formatter->format($line['resource']->price, ['currency', $line['resource']->currency]) ?>
<span class="domain-price-year">/<?= Yii::t('app', 'year') ?></span>

<?php elseif ($state === 'unavailable') : ?>
Expand Down Expand Up @@ -63,4 +63,4 @@ class="domain-zone muted">.<?= $line['zone'] ?></span>
<?php endif; ?>
</div>
</div>
</div>
</div>

0 comments on commit f7d6466

Please sign in to comment.