/** * Lists all Order models. * @return mixed */ public function actionIndex() { $searchModelConfig = ['defaultOrder' => ['id' => SORT_DESC], 'model' => Order::className(), 'relations' => ['user' => ['username']], 'partialMatchAttributes' => ['start_date', 'end_date', 'user_username'], 'additionalConditions' => []]; if (intval($this->module->showDeletedOrders) === 0) { $searchModelConfig['additionalConditions'] = [['is_deleted' => 0]]; } /** @var SearchModel $searchModel */ $searchModel = new SearchModel($searchModelConfig); if (intval($this->module->defaultOrderStageFilterBackend) > 0) { $searchModel->order_stage_id = intval($this->module->defaultOrderStageFilterBackend); } $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['dataProvider' => $dataProvider, 'managers' => $this->getManagersList(), 'orderStages' => Helper::getModelMap(OrderStage::className(), 'id', 'name_short'), 'paymentTypes' => Helper::getModelMap(PaymentType::className(), 'id', 'name'), 'searchModel' => $searchModel, 'shippingOptions' => Helper::getModelMap(ShippingOption::className(), 'id', 'name')]); }
?> </th> <td> <?php echo $orderIsImmutable ? Html::encode($model->stage->name_short) : Editable::widget(['attribute' => 'order_stage_id', 'data' => \app\components\Helper::getModelMap(\app\modules\shop\models\OrderStage::className(), 'id', 'name_short'), 'displayValue' => $model->stage !== null ? Html::tag('span', $model->stage->name_short) : Html::tag('em', Yii::t('yii', '(not set)')), 'formOptions' => ['action' => ['update-stage', 'id' => $model->id]], 'inputType' => Editable::INPUT_DROPDOWN_LIST, 'model' => $model]); ?> </td> </tr> <tr> <th><?php echo $model->getAttributeLabel('payment_type_id'); ?> </th> <td> <?php echo $orderIsImmutable ? null !== $model->paymentType ? Html::encode($model->paymentType->name) : Html::tag('em', Yii::t('yii', '(not set)')) : Editable::widget(['attribute' => 'payment_type_id', 'data' => \app\components\Helper::getModelMap(\app\modules\shop\models\PaymentType::className(), 'id', 'name'), 'displayValue' => $model->paymentType !== null ? Html::tag('span', $model->paymentType->name) : Html::tag('em', Yii::t('yii', '(not set)')), 'formOptions' => ['action' => ['update-payment-type', 'id' => $model->id]], 'inputType' => Editable::INPUT_DROPDOWN_LIST, 'model' => $model]); ?> </td> </tr> <?php foreach ($model->abstractModel->attributes as $name => $attribute) { ?> <tr> <th><?php echo $model->abstractModel->getAttributeLabel($name); ?> </th> <td> <button data-toggle="modal" data-target="#custom-fields-modal" class="kv-editable-value kv-editable-link"> <?php echo !empty($attribute) ? Html::encode($attribute) : Html::tag('em', Yii::t('yii', '(not set)'));
public function getPaymentType() { return $this->hasOne(PaymentType::className(), ['id' => 'payment_type_id']); }
return ['class' => 'danger']; } return []; }], 'columns' => [['attribute' => 'id'], ['attribute' => 'user_username', 'label' => Yii::t('app', 'User'), 'value' => function ($model, $key, $index, $column) { if ($model === null || $model->user === null) { return null; } return $model->user->username; }], 'start_date', 'end_date', ['attribute' => 'order_stage_id', 'filter' => Helper::getModelMap(\app\modules\shop\models\OrderStage::className(), 'id', 'name_short'), 'value' => function ($model, $key, $index, $column) { if ($model === null || $model->stage === null) { return null; } return $model->stage->name_short; }], ['attribute' => 'shipping_option_id', 'filter' => Helper::getModelMap(\app\modules\shop\models\ShippingOption::className(), 'id', 'name'), 'value' => function ($model, $key, $index, $column) { if ($model === null || $model->shippingOption === null) { return null; } return $model->shippingOption->name; }], ['attribute' => 'payment_type_id', 'filter' => Helper::getModelMap(\app\modules\shop\models\PaymentType::className(), 'id', 'name'), 'value' => function ($model, $key, $index, $column) { if ($model === null || $model->paymentType === null) { return null; } return $model->paymentType->name; }], 'items_count', 'total_price', ['class' => 'app\\backend\\components\\ActionColumn', 'buttons' => function ($model, $key, $index, $parent) { $result = [['url' => '/shop/backend-order/view', 'icon' => 'eye', 'class' => 'btn-info', 'label' => Yii::t('app', 'View')]]; return $result; }]]]); ?> </div> </div>
<?php /** * @var \yii\web\View $this * @var \app\modules\shop\models\Order $model * @var boolean $immutable * @var array $additional */ $transactionsDataProvider = $additional['transactionsDataProvider']; echo \kartik\dynagrid\DynaGrid::widget(['options' => ['id' => 'transactions-grid'], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $transactionsDataProvider, 'hover' => true, 'panel' => false], 'columns' => [['attribute' => 'id', 'value' => function ($model, $key, $index, $column) { /** @var \app\modules\shop\models\OrderTransaction $model */ return \yii\helpers\Html::a($model->id, \yii\helpers\Url::toRoute(['/shop/payment/transaction', 'id' => $model->id, 'othash' => $model->generateHash()]), ['class' => 'print-without-link']); }, 'format' => 'raw', 'encodeLabel' => false], ['attribute' => 'status', 'value' => function ($model, $key, $index, $column) { /** @var \app\modules\shop\models\OrderTransaction $model */ return $model->getTransactionStatus(); }], 'start_date', 'end_date', 'total_sum', ['attribute' => 'payment_type_id', 'filter' => \app\components\Helper::getModelMap(\app\modules\shop\models\PaymentType::className(), 'id', 'name'), 'value' => function ($model, $key, $index, $column) { if ($model === null || $model->paymentType === null) { return null; } return $model->paymentType->name; }]]]);
/** * Lists all PaymentType models. * @return mixed */ public function actionIndex() { $searchModel = new SearchModel(['model' => PaymentType::className(), 'partialMatchAttributes' => ['name', 'class']]); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }