mirror of
https://github.com/janickiy/yii2-nomer
synced 2025-03-09 15:39:59 +00:00
add files to project
This commit is contained in:
commit
5cac498444
3729 changed files with 836998 additions and 0 deletions
116
views/history/index.php
Normal file
116
views/history/index.php
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $dataProvider \yii\data\ActiveDataProvider */
|
||||
|
||||
use app\models\ResultCache;
|
||||
use yii\grid\GridView;
|
||||
use app\models\SearchRequest;
|
||||
use app\models\RequestResult;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Json;
|
||||
|
||||
$this->title = 'История поиска';
|
||||
|
||||
?>
|
||||
|
||||
<div class="cont clfix" style="margin-top: 30px">
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
'tm',
|
||||
[
|
||||
'format' => 'raw',
|
||||
'attribute' => 'phone',
|
||||
'value' => function(SearchRequest $model) {
|
||||
$phone = preg_replace('/^7/', '8', $model->phone);
|
||||
return '<a href="/' . $phone . '">' . $phone . '</a>';
|
||||
}
|
||||
],
|
||||
[
|
||||
'header' => 'Оператор',
|
||||
'value' => function(SearchRequest $model) {
|
||||
$result = RequestResult::find()->where(['request_id' => $model->id, 'type_id' => ResultCache::TYPE_OPERATOR])->one();
|
||||
if($result) {
|
||||
$operator = Json::decode($result->data);
|
||||
$o = [];
|
||||
$o[] = ArrayHelper::getValue($operator, "operator");
|
||||
$o[] = ArrayHelper::getValue($operator, "region");
|
||||
$o = array_filter($o);
|
||||
return join(", ", $o);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
],
|
||||
[
|
||||
'header' => 'Имена',
|
||||
'content' => function(SearchRequest $model) {
|
||||
$names = [];
|
||||
|
||||
$namesRows = RequestResult::find()->where(["request_id" => $model->id, "type_id" => [
|
||||
ResultCache::TYPE_TRUECALLER,
|
||||
ResultCache::TYPE_NUMBUSTER
|
||||
]])->all();
|
||||
foreach ($namesRows as $namesRow) {
|
||||
$nameData = Json::decode($namesRow->data);
|
||||
if(!is_null($nameData)) {
|
||||
if(array_key_exists("name", $nameData)) {
|
||||
$names[] = ArrayHelper::getValue($nameData, "name");
|
||||
} else {
|
||||
$names = ArrayHelper::merge($names, ArrayHelper::getColumn($nameData, "name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$names = array_unique($names);
|
||||
|
||||
if(count($names) < 2) {
|
||||
$namesRows = RequestResult::find()->where(["request_id" => $model->id, "type_id" => [
|
||||
ResultCache::TYPE_FACEBOOK,
|
||||
ResultCache::TYPE_VK_2012,
|
||||
ResultCache::TYPE_VK_OPEN,
|
||||
ResultCache::TYPE_VIBER,
|
||||
ResultCache::TYPE_TELEGRAM,
|
||||
ResultCache::TYPE_VK,
|
||||
ResultCache::TYPE_AVITO,
|
||||
]])->all();
|
||||
foreach ($namesRows as $namesRow) {
|
||||
$nameData = Json::decode($namesRow->data);
|
||||
if(in_array($namesRow->type_id, [ResultCache::TYPE_TELEGRAM, ResultCache::TYPE_VIBER])) {
|
||||
$names = ArrayHelper::merge($names, [ArrayHelper::getValue($nameData, "name")]);
|
||||
} else {
|
||||
$names = ArrayHelper::merge($names, ArrayHelper::getColumn($nameData, "name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$names = array_unique($names);
|
||||
$names = array_splice($names, 0, 2);
|
||||
|
||||
return join(", ", $names);
|
||||
}
|
||||
],
|
||||
[
|
||||
'header' => 'Стоимость',
|
||||
'value' => function(SearchRequest $model) {
|
||||
$type = "";
|
||||
switch ($model->is_payed) {
|
||||
case 0: $type = "Бесплатный (нет проверок)"; break;
|
||||
case 1: $type = "Платный"; break;
|
||||
case 2: $type = "Бесплатный (не нашли)"; break;
|
||||
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
],
|
||||
[
|
||||
'header' => 'Индекс поиска',
|
||||
'value' => function(SearchRequest $model) {
|
||||
return array_sum(array_map(function(RequestResult $result) {
|
||||
return $result->index;
|
||||
}, $model->results));
|
||||
}
|
||||
],
|
||||
]
|
||||
]) ?>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue