}
return json_encode(["response" => "OK"]);
}
-
}
namespace yii_app\records;
+use app\controllers\MarketplaceOrderStatusTypesController;
use Yii;
/**
*/
class MarketplaceOrders extends \yii\db\ActiveRecord
{
-
+ const STATUSES_1C = [
+ 1 => 'Создан в ЕРП'
+ ];
/**
* {@inheritdoc}
];
}
+ public function getStore()
+ {
+ return $this->hasOne(CityStore::class, ['id' => 'store_id']);
+ }
+
+ public function getStatus()
+ {
+ return $this->hasOne(MarketplaceOrderStatusTypes::class, ['id' => 'status_id']);
+ }
+ public function getSubstatus()
+ {
+ return $this->hasOne(MarketplaceOrderStatusTypes::class, ['id' => 'substatus_id']);
+ }
}
*/
class MarketplaceOrdersSearch extends MarketplaceOrders
{
+
+ public $store_name; // Добавляем свойство для поиска по названию магазина
+ public $status_code; // Добавляем свойство для поиска по коду статуса
+ public $substatus_code; // Добавляем свойство для поиска по коду подстатуса
+
/**
* {@inheritdoc}
*/
{
return [
[['id', 'store_id', 'status_id', 'substatus_id', 'cancel_requested', 'status_1c'], 'integer'],
- [['marketplace_order_id', 'warehouse_guid', 'creation_date', 'updated_at', 'tax_system', 'payment_type', 'payment_method', 'raw_data', 'guid'], 'safe'],
+ [['marketplace_order_id', 'warehouse_guid', 'creation_date', 'updated_at', 'tax_system', 'payment_type', 'payment_method', 'raw_data', 'guid','store_name', 'status_code', 'substatus_code'], 'safe'],
[['total', 'delivery_total', 'buyer_total_before_discount'], 'number'],
];
}
*/
public function search($params, $formName = null)
{
- $query = MarketplaceOrders::find();
-
- // add conditions that should always apply here
+ $query = MarketplaceOrders::find()
+ ->joinWith(['store', 'status statusAlias', 'substatus substatusAlias']);
$dataProvider = new ActiveDataProvider([
'query' => $query,
$this->load($params, $formName);
if (!$this->validate()) {
- // uncomment the following line if you do not want to return any records when validation fails
- // $query->where('0=1');
return $dataProvider;
}
- // grid filtering conditions
+ // Фильтрация по ID и числовым полям
$query->andFilterWhere([
'id' => $this->id,
'store_id' => $this->store_id,
'status_1c' => $this->status_1c,
]);
+ // Фильтрация по строковым полям
$query->andFilterWhere(['ilike', 'marketplace_order_id', $this->marketplace_order_id])
->andFilterWhere(['ilike', 'warehouse_guid', $this->warehouse_guid])
->andFilterWhere(['ilike', 'tax_system', $this->tax_system])
->andFilterWhere(['ilike', 'raw_data', $this->raw_data])
->andFilterWhere(['ilike', 'guid', $this->guid]);
+ // Поиск по названию магазина
+ $query->andFilterWhere(['ilike', 'marketplace_store.name', $this->store_name]);
+
+ // Фильтр по коду статуса (с псевдонимом)
+ $query->andFilterWhere(['ilike', 'statusAlias.code', $this->status_code]);
+
+ // Фильтр по коду подстатуса (с псевдонимом)
+ $query->andFilterWhere(['ilike', 'substatusAlias.code', $this->substatus_code]);
+
return $dataProvider;
}
}
/** @var yii_app\records\MarketplaceOrderDeliverySearch $searchModel */
/** @var yii\data\ActiveDataProvider $dataProvider */
-$this->title = 'Marketplace Order Deliveries';
+$this->title = 'Доставки с заказов';
$this->params['breadcrumbs'][] = $this->title;
?>
-<div class="marketplace-order-delivery-index">
+<div class="marketplace-order-delivery-index p-4">
<h1><?= Html::encode($this->title) ?></h1>
<p>
- <?= Html::a('Create Marketplace Order Delivery', ['create'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Заказы', ['/marketplace-orders/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Элементы заказов', ['/marketplace-order-items/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Истории статусов заказов', ['/marketplace-order-status-history/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Типы статусов заказов', ['/marketplace-order-status-types/index'], ['class' => 'btn btn-success']) ?>
</p>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
'columns' => [
['class' => 'yii\grid\SerialColumn'],
- 'id',
- 'order_id',
+ // 'id',
+ [
+ 'attribute' => 'order_id',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [
+ 'target' => '_blank',
+ 'title' => 'Просмотреть заказ'
+ ]);
+ }
+ ],
'type',
'service_name',
'partner_type',
//'country',
//'postcode',
- //'city',
- //'street',
- //'house',
- //'apartment',
+ 'city',
+ 'street',
+ 'house',
+ 'apartment',
//'latitude',
//'longitude',
- //'delivery_start',
- //'delivery_end',
- //'courier_full_name',
- //'courier_phone',
+ 'delivery_start',
+ 'delivery_end',
+ 'courier_full_name',
+ 'courier_phone',
//'courier_extension',
//'courier_vehicle_number',
//'courier_vehicle_description',
- [
- 'class' => ActionColumn::className(),
+ ['template' => '{view}',
+ 'class' => ActionColumn::class,
'urlCreator' => function ($action, MarketplaceOrderDelivery $model, $key, $index, $column) {
return Url::toRoute([$action, 'id' => $model->id]);
}
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
-<div class="marketplace-order-delivery-view">
-
+<div class="marketplace-order-delivery-view p-4">
+ <?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary my-4']) ?>
<h1><?= Html::encode($this->title) ?></h1>
- <p>
- <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
- <?= Html::a('Delete', ['delete', 'id' => $model->id], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => 'Are you sure you want to delete this item?',
- 'method' => 'post',
- ],
- ]) ?>
- </p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
- 'order_id',
+ [
+ 'attribute' => 'order_id',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [
+ 'target' => '_blank',
+ 'title' => 'Просмотреть заказ'
+ ]);
+ }
+ ],
'type',
'service_name',
'partner_type',
/** @var yii_app\records\MarketplaceOrderItemsSearch $searchModel */
/** @var yii\data\ActiveDataProvider $dataProvider */
-$this->title = 'Marketplace Order Items';
+$this->title = 'Элементы заказа';
$this->params['breadcrumbs'][] = $this->title;
?>
-<div class="marketplace-order-items-index">
+<div class="marketplace-order-items-index p-4">
<h1><?= Html::encode($this->title) ?></h1>
<p>
- <?= Html::a('Create Marketplace Order Items', ['create'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Заказы', ['/marketplace-orders/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Доставки заказов', ['/marketplace-order-delivery/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Истории статусов заказов', ['/marketplace-order-status-history/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Типы статусов заказов', ['/marketplace-order-status-types/index'], ['class' => 'btn btn-success']) ?>
</p>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
['class' => 'yii\grid\SerialColumn'],
'id',
- 'order_id',
+ [
+ 'attribute' => 'order_id',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [
+ 'target' => '_blank',
+ 'title' => 'Просмотреть заказ'
+ ]);
+ }
+ ],
'external_item_id',
'offer_id',
'offer_name',
//'promos:ntext',
//'subsidies:ntext',
[
- 'class' => ActionColumn::className(),
+ 'template' => '{view}',
+ 'class' => ActionColumn::class,
'urlCreator' => function ($action, MarketplaceOrderItems $model, $key, $index, $column) {
return Url::toRoute([$action, 'id' => $model->id]);
}
\yii\web\YiiAsset::register($this);
?>
<div class="marketplace-order-items-view">
-
+ <?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary my-4']) ?>
<h1><?= Html::encode($this->title) ?></h1>
- <p>
- <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
- <?= Html::a('Delete', ['delete', 'id' => $model->id], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => 'Are you sure you want to delete this item?',
- 'method' => 'post',
- ],
- ]) ?>
- </p>
+
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
- 'order_id',
+ [
+ 'attribute' => 'order_id',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [
+ 'target' => '_blank',
+ 'title' => 'Просмотреть заказ'
+ ]);
+ }
+ ],
'external_item_id',
'offer_id',
'offer_name',
$this->title = 'Marketplace Order Status Histories';
$this->params['breadcrumbs'][] = $this->title;
?>
-<div class="marketplace-order-status-history-index">
+<div class="marketplace-order-status-history-index p-4">
<h1><?= Html::encode($this->title) ?></h1>
<p>
- <?= Html::a('Create Marketplace Order Status History', ['create'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Доставки заказов', ['/marketplace-order-delivery/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Элементы заказов', ['/marketplace-order-items/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Заказы', ['/marketplace-orders/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Типы статусов заказов', ['/marketplace-order-status-types/index'], ['class' => 'btn btn-success']) ?>
</p>
-
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<?= GridView::widget([
['class' => 'yii\grid\SerialColumn'],
'id',
- 'order_id',
+ [
+ 'attribute' => 'order_id',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return Html::a($model->order_id, ['marketplace-orders/view', 'id' => $model->order_id], [
+ 'target' => '_blank',
+ 'title' => 'Просмотреть заказ'
+ ]);
+ }
+ ],
'status_id',
'substatus_id',
'active',
- //'date_from',
- //'date_end',
- //'initiator:ntext',
+ 'date_from',
+ 'date_end',
+ 'initiator:ntext',
[
- 'class' => ActionColumn::className(),
+ 'template' => '{view}',
+ 'class' => ActionColumn::class,
'urlCreator' => function ($action, MarketplaceOrderStatusHistory $model, $key, $index, $column) {
return Url::toRoute([$action, 'id' => $model->id]);
}
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
-<div class="marketplace-order-status-history-view">
-
+<div class="marketplace-order-status-history-view p-4">
+ <?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary my-4']) ?>
<h1><?= Html::encode($this->title) ?></h1>
- <p>
- <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
- <?= Html::a('Delete', ['delete', 'id' => $model->id], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => 'Are you sure you want to delete this item?',
- 'method' => 'post',
- ],
- ]) ?>
- </p>
+
<?= DetailView::widget([
'model' => $model,
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="marketplace-order-status-types-index p-4">
-
+ <p>
+ <?= Html::a('Доставки заказов', ['/marketplace-order-delivery/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Элементы заказов', ['/marketplace-order-items/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Истории статусов заказов', ['/marketplace-order-status-history/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Заказы', ['/marketplace-orders/index'], ['class' => 'btn btn-success']) ?>
+ </p>
<h1><?= Html::encode($this->title) ?></h1>
<p>
/** @var yii_app\records\MarketplaceOrdersSearch $searchModel */
/** @var yii\data\ActiveDataProvider $dataProvider */
-$this->title = 'Marketplace Orders';
+$this->title = 'Заказы с маркетплейсов (Яндекс Маркет)';
$this->params['breadcrumbs'][] = $this->title;
?>
-<div class="marketplace-orders-index">
+<div class="marketplace-orders-index p-4">
<h1><?= Html::encode($this->title) ?></h1>
<p>
- <?= Html::a('Create Marketplace Orders', ['create'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Доставки заказов', ['/marketplace-order-delivery/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Элементы заказов', ['/marketplace-order-items/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Истории статусов заказов', ['/marketplace-order-status-history/index'], ['class' => 'btn btn-success']) ?>
+ <?= Html::a('Типы статусов заказов', ['/marketplace-order-status-types/index'], ['class' => 'btn btn-success']) ?>
</p>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
'columns' => [
['class' => 'yii\grid\SerialColumn'],
- 'id',
+ //'id',
'marketplace_order_id',
- 'store_id',
- 'status_id',
- 'substatus_id',
+ [
+ 'attribute' => 'store_id',
+ 'value' => function ($model) {
+ return $model->store->name ?? '-';
+ },
+ 'filter' => Html::input('text', 'MarketplaceOrdersSearch[store_name]', $searchModel->store_name, ['class' => 'form-control']),
+ ],
+ [
+ 'attribute' => 'status_id',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ $status = $model->status->code ?? '';
+ $class = '';
+ if ($status === 'DELIVERED') {
+ $class = 'bg-success text-white';
+ } elseif ($status === 'CANCELLED') {
+ $class = 'bg-danger text-white';
+ }
+ return Html::tag('span', $status, ['class' => "badge $class"]);
+ },
+ 'filter' => Html::input('text', 'MarketplaceOrdersSearch[status_code]', $searchModel->status_code, ['class' => 'form-control']),
+ ],
+ [
+ 'attribute' => 'substatus_id',
+ 'value' => function ($model) {
+ return $model->substatus->code ?? '-';
+ },
+ 'filter' => Html::input('text', 'MarketplaceOrdersSearch[substatus_code]', $searchModel->substatus_code, ['class' => 'form-control']),
+ ],
//'warehouse_guid',
- //'creation_date',
- //'updated_at',
- //'total',
- //'delivery_total',
- //'buyer_total_before_discount',
+ 'creation_date',
+ 'updated_at',
+ 'total',
+ 'delivery_total',
+ 'buyer_total_before_discount',
//'tax_system',
//'payment_type',
//'payment_method',
//'cancel_requested',
//'raw_data:ntext',
- //'guid',
- //'status_1c',
+ 'guid',
+ [
+ 'attribute' => 'status_1c',
+ 'value' => function ($model) {
+ return MarketplaceOrders::STATUSES_1C[$model->status_1c];
+ }
+ ],
[
- 'class' => ActionColumn::className(),
+ 'template' => '{view}',
+ 'class' => ActionColumn::class,
'urlCreator' => function ($action, MarketplaceOrders $model, $key, $index, $column) {
return Url::toRoute([$action, 'id' => $model->id]);
- }
+ }
],
],
]); ?>
use yii\helpers\Html;
use yii\widgets\DetailView;
+use yii_app\records\MarketplaceOrders;
/** @var yii\web\View $this */
/** @var yii_app\records\MarketplaceOrders $model */
-$this->title = $model->id;
+$this->title = 'Заказ магазина ' . $model->store->name . ' от ' . $model->creation_date;
$this->params['breadcrumbs'][] = ['label' => 'Marketplace Orders', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
-<div class="marketplace-orders-view">
-
+<div class="marketplace-orders-view p-4">
+ <?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary my-4']) ?>
<h1><?= Html::encode($this->title) ?></h1>
- <p>
- <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
- <?= Html::a('Delete', ['delete', 'id' => $model->id], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => 'Are you sure you want to delete this item?',
- 'method' => 'post',
- ],
- ]) ?>
- </p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'marketplace_order_id',
- 'store_id',
- 'status_id',
- 'substatus_id',
+ [
+ 'attribute' => 'store_id',
+ 'value' => function ($model) {
+ return $model->store->name;
+ }
+ ],
+ [
+ 'attribute' => 'status_id',
+ 'value' => function ($model) {
+ return $model->status->code;
+ }
+ ],
+ [
+ 'attribute' => 'substatus_id',
+ 'value' => function ($model) {
+ return $model->substatus->code;
+ }
+ ],
'warehouse_guid',
'creation_date',
'updated_at',
'cancel_requested',
'raw_data:ntext',
'guid',
- 'status_1c',
+ [
+ 'attribute' => 'status_1c',
+ 'value' => function ($model) {
+ return MarketplaceOrders::STATUSES_1C[$model->status_1c];
+ }
+ ],
],
]) ?>