use yii\data\ActiveDataProvider;
use yii_app\records\WaybillWriteOffs;
+use yii_app\records\WaybillWriteOffsProducts;
class WaybillWriteOffsController extends \yii\web\Controller
{
]);
}
- public function actionView()
+ public function actionView($id)
{
- return $this->render('view');
- }
+ $model = WaybillWriteOffs::findOne($id);
+ if (!$model) {
+ throw new \yii\web\NotFoundHttpException("Документ с ID {$id} не найден.");
+ }
+ $productsDataProvider = new \yii\data\ActiveDataProvider([
+ 'query' => WaybillWriteOffsProducts::find()->where(['waybill_write_offs_id' => $model->id]),
+ 'pagination' => [
+ 'pageSize' => 10, // Количество записей на странице
+ ],
+ ]);
+
+ return $this->render('view', [
+ 'model' => $model,
+ 'productsDataProvider' => $productsDataProvider,
+ ]);
+ }
}
use yii\helpers\Html;
use yii_app\records\Admin;
use yii_app\records\CityStore;
+use yii_app\records\ExportImportTable;
/** @var yii\data\ActiveDataProvider $dataProvider */
'label' => 'Магазин',
'attribute' => 'store_id',
'value' => function ($model) {
- return CityStore::findOne(\yii_app\records\ExportImportTable::findOne(['export_val' => $model->store_guid])->entity_id)->name;
+ return CityStore::findOne(ExportImportTable::findOne(['export_val' => $model->store_guid])
+ ->entity_id)->name;
}
],
'quantity',
'label' => 'Создан пользователем',
'attribute' => 'created_admin_id',
'value' => function ($model) {
- return Admin::findOne( [$model->created_admin_id])->name;
+ return Admin::findOne([$model->created_admin_id])->name;
}
],
[
--- /dev/null
+<?php
+
+use yii\widgets\DetailView;
+use yii\grid\GridView;
+use yii\helpers\Html;
+use yii_app\records\Admin;
+use yii_app\records\CityStore;
+use yii_app\records\ExportImportTable;
+
+/** @var yii_app\records\WaybillWriteOffs $model */
+/** @var yii\data\ActiveDataProvider $productsDataProvider */
+
+$this->title = "Детали документа: {$model->number}";
+$this->params['breadcrumbs'][] = ['label' => 'Список документов', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="waybill-write-offs-view p-4">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <!-- Детали документа -->
+ <?= DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'guid',
+ 'number',
+ 'date',
+ [
+ 'label' => 'Магазин',
+ 'attribute' => 'store_id',
+ 'value' => function ($model) {
+ return CityStore::findOne(ExportImportTable::findOne(['export_val' => $model->store_guid])
+ ->entity_id)->name;
+ }
+ ],
+ 'quantity',
+ 'summ',
+ 'status',
+ [
+ 'label' => 'Создан пользователем',
+ 'attribute' => 'created_admin_id',
+ 'value' => function ($model) {
+ return Admin::findOne([$model->created_admin_id])->name;
+ }
+ ],
+ 'created_at',
+ 'updated_at',
+ 'deleted_at',
+ ],
+ ]) ?>
+
+ <h2>Списываемые товары</h2>
+
+ <!-- Таблица с товарами -->
+ <?= GridView::widget([
+ 'dataProvider' => $productsDataProvider,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+ 'name',
+ 'product_id',
+ 'product_count',
+ 'product_price',
+ 'product_self_cost',
+ 'summ',
+ 'summ_self_cost',
+ 'created_at',
+ ],
+ ]) ?>
+
+</div>