116 lines
4.5 KiB
PHP
116 lines
4.5 KiB
PHP
<?php
|
|
|
|
use app\models\OrderProduct;
|
|
use app\models\Pages;
|
|
use app\models\Subscriptions;
|
|
use app\services\Formatter;
|
|
use app\widgets\FormWidget;
|
|
use app\widgets\services\Includes;
|
|
use app\widgets\TableWidget;
|
|
|
|
$tab = $_GET['tab'] ?? 'main';
|
|
$_GET['tab'] = $tab;
|
|
|
|
|
|
TableWidget::widget([
|
|
'filter' => [
|
|
[
|
|
'model_id' => ['Абонамент', 'c3', Subscriptions::getList()],
|
|
'user_email' => ['E-mail', 'c2'],
|
|
'status' => ['Статус', 'c2', ['PAID' => 'Платено', 'CANCELED' => 'Отказано плащане']]
|
|
//'event_dates' => ['Дата', 'c2 fDatepicker'],
|
|
//'title' => ['Заглавие на събитието', 'c4'],
|
|
//'partner_id' => ['Организация', 'c3', Partner::partnerList()],
|
|
//'is_for_publish' => ['За публикувне', 'c1', [1 => 'да', 'null' => 'не']],
|
|
//'is_active' => ['Публикувано', 'c1', [1 => 'да', 'null' => 'не']]
|
|
],
|
|
],
|
|
'top' => [
|
|
'title' => 'Абонаменти',
|
|
'data' => [
|
|
'index/dashboard' => 'Начало',
|
|
'products/subscriptions' => 'Дигитален магазин',
|
|
]
|
|
],
|
|
'actions' => [
|
|
//'new' => 'Нов абонамент',
|
|
//'edit' => 'Редакция на абонамент',
|
|
//'delete' => 'Изтриване на абонамент'
|
|
],
|
|
'th' => [
|
|
'№' => 'c0 text-right',
|
|
'Абонамент' => 'c1',
|
|
'Дата' => 'c1',
|
|
'Потребител име' => 'c1',
|
|
'Потребител e-mail' => '',
|
|
'Стойност' => '',
|
|
'Плащане' => ''
|
|
],
|
|
'model' => Subscriptions::class,
|
|
'data' => \app\models\OrderProduct::find()->joinWith('order')->joinWith('order.payment')->where(['model_class' => Subscriptions::class])->andWhere(Yii::$app->getFilterData('or'))->orderBy(['order_date' => SORT_DESC])->loop([
|
|
'id',
|
|
'name_bg',
|
|
function (\app\models\OrderProduct $orderProduct) {
|
|
if ($orderProduct->order) {
|
|
return date('d.m.Y H:i', strtotime($orderProduct->order->order_date));
|
|
}
|
|
},
|
|
function (\app\models\OrderProduct $orderProduct) {
|
|
if ($orderProduct->order) {
|
|
return $orderProduct->order->user_name;
|
|
}
|
|
},
|
|
function (\app\models\OrderProduct $orderProduct) {
|
|
if ($orderProduct->order) {
|
|
return $orderProduct->order->user_email;
|
|
}
|
|
},
|
|
function (OrderProduct $orderProduct) {
|
|
return number_format($orderProduct->order->total_price, 2, '.', '') . ' лв';
|
|
},
|
|
function (OrderProduct $orderProduct) {
|
|
if ($orderProduct->order && $orderProduct->order->payment) {
|
|
$payment = $orderProduct->order->payment;
|
|
return
|
|
'<div>статус: <span style="font-weight: bold">' . $payment->status . '</span></div>
|
|
<div style="margin-top: 4px">дата: ' . date('d.m.Y H:i', strtotime($payment->response_time)) . '</div>';
|
|
}
|
|
}
|
|
|
|
], $_GET['p'] ?? 1, 30)
|
|
]);
|
|
|
|
/*
|
|
FormWidget::widget([
|
|
'top' => [
|
|
'title' => 'Нов абонамент',
|
|
'title_edit' => 'Редакция на абонамент',
|
|
'data' => [
|
|
'index/dashboard' => 'Начало',
|
|
'products/subscriptions' => 'Абонаменти',
|
|
],
|
|
],
|
|
'tabs' => $tabs ?? [],
|
|
'writeView' => "products/tabs/" . Includes::tab($tab) . "/subscriptions_w",
|
|
'model' => Subscriptions::class,
|
|
'validation' => function ($p) use ($tab) {
|
|
if ($tab == 'main') {
|
|
if (empty($p->{"name"}))
|
|
return ["name" => 'Моля, въведете наименование на абонамента'];
|
|
if (empty($p->{"name_en"}))
|
|
return ["name_en" => 'Моля, въведете наименование на абонамента'];
|
|
if(empty($p->{"price"}))
|
|
return ['price' => 'Моля, въведете цена на абонамента'];
|
|
|
|
}
|
|
return null;
|
|
},
|
|
'postService' => function ($p, Subscriptions $model) use ($tab) {
|
|
$model->setPostDataToModel();
|
|
$model->save();
|
|
Yii::$app->flash('success', isset($_GET['id']) ? 'Абонамента е актуализиран успешно' : 'Абонамента е създаден успешно');
|
|
$model->smartRedirect();
|
|
}
|
|
]);
|
|
*/
|